Starting on implementing the step defs

This commit is contained in:
Nick Quaranto 2009-03-31 17:26:04 -04:00
parent 6c41f93493
commit c22cd84153
3 changed files with 37 additions and 18 deletions

View File

@ -4,15 +4,13 @@ Feature: Create sites
In order to share my awesome ideas with the interwebs In order to share my awesome ideas with the interwebs
Scenario: Basic site Scenario: Basic site
Given I have a blank site Given I have an "index.html" file that contains "Basic Site"
And I have an "index.html" file that contains "Basic Site"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Basic Site" in "_site/index.html" And I should see "Basic Site" in "_site/index.html"
Scenario: Basic site with a post Scenario: Basic site with a post
Given I have a blank site Given I have a _posts directory
And I have a _posts directory
And I have the following post: And I have the following post:
| title | date | content | | title | date | content |
| Hackers | 3/27/2009 | My First Exploit | | Hackers | 3/27/2009 | My First Exploit |
@ -21,8 +19,7 @@ Feature: Create sites
And I should see "My First Exploit" in "_site/2009/03/27/hackers.html" And I should see "My First Exploit" in "_site/2009/03/27/hackers.html"
Scenario: Basic site with layout and a page Scenario: Basic site with layout and a page
Given I have a blank site Given I have a _layouts directory
And I have a _layouts directory
And I have an "index.html" file with layout "default" that contains "Basic Site with Layout" And I have an "index.html" file with layout "default" that contains "Basic Site with Layout"
And I have a default layout that contains "Page Layout: {{ content }}" And I have a default layout that contains "Page Layout: {{ content }}"
When I run jekyll When I run jekyll
@ -30,8 +27,7 @@ Feature: Create sites
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html" And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
Scenario: Basic site with layout and a post Scenario: Basic site with layout and a post
Given I have a blank site Given I have a _layouts directory
And I have a _layouts directory
And I have a _posts directory And I have a _posts directory
And I have the following post: And I have the following post:
| title | date | layout | content | | title | date | layout | content |
@ -42,8 +38,7 @@ Feature: Create sites
And I should see "Post Layout: Would you like to play a game?" in "_site/2009/03/27/wargames.html" And I should see "Post Layout: Would you like to play a game?" in "_site/2009/03/27/wargames.html"
Scenario: Basic site with include tag Scenario: Basic site with include tag
Given I have a blank site Given I have a _includes directory
And I have a _includes directory
And I have an "index.html" file that contains "Basic Site with include tag: {% include about.html %}" And I have an "index.html" file that contains "Basic Site with include tag: {% include about.html %}"
And I have an "_includes/about.html" file that contains "Generated by Jekyll" And I have an "_includes/about.html" file that contains "Generated by Jekyll"
When I run jekyll When I run jekyll

View File

@ -1,17 +1,37 @@
Given /^I have a blank site(?: in (.*))?$/ do |dir| Before do
pending FileUtils.mkdir(TEST_DIR)
Dir.chdir(TEST_DIR)
end end
Given /^I have an "(.*)" file( with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text| After do
pending Dir.chdir(TEST_DIR)
FileUtils.rm_rf(TEST_DIR)
end
Given /^I have an "(.*)" file(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
File.open(file, 'w') do |f|
if key && value
f.write <<EOF
---
#{key}: #{value}
---
EOF
end
f.write(text)
f.close
end
end end
Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text| Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
pending File.open(layout, 'w') do |f|
f.write(text)
f.close
end
end end
Given /^I have a (.*) directory$/ do |dir| Given /^I have a (.*) directory$/ do |dir|
pending FileUtils.mkdir(dir)
end end
Given /^I have the following posts?(?: in "(.*)")?:$/ do |table, dir| Given /^I have the following posts?(?: in "(.*)")?:$/ do |table, dir|
@ -23,7 +43,7 @@ Given /^I have a configuration file(?: in "(.*)")? with "(.*)" set to "(.*)"$/ d
end end
When /^I run jekyll$/ do When /^I run jekyll$/ do
pending `#{File.join(ENV['PWD'], 'bin', 'jekyll')} >> /dev/null`
end end
When /^I change "(.*)" to contain "(.*)"$/ do |file, text| When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
@ -35,7 +55,7 @@ When /^I go to "(.*)"$/ do |address|
end end
Then /^the (.*) directory should exist$/ do |dir| Then /^the (.*) directory should exist$/ do |dir|
pending pending
end end
Then /^I should see "(.*)"(?: in "(.*)")?$/ do |text, file| Then /^I should see "(.*)"(?: in "(.*)")?$/ do |text, file|

4
features/support/env.rb Normal file
View File

@ -0,0 +1,4 @@
require 'fileutils'
require 'rr'
TEST_DIR = File.join('/', 'tmp', 'jekyll')