Green all around, finally.

This commit is contained in:
Nick Quaranto 2009-04-01 20:38:59 -04:00
parent c52484a257
commit d590f2ac06
2 changed files with 17 additions and 22 deletions

View File

@ -4,23 +4,20 @@ Feature: Site data
In order to make the site slightly dynamic In order to make the site slightly dynamic
Scenario: Use page variable in a page Scenario: Use page variable in a page
Given I have a blank site Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: email@me.com"
And I have an "contact.html" file with title "Contact" that contains "{{ page.title }}: email@me.com"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Contact: email@me.com" in "_site/index.html" And I should see "Contact: email@me.com" in "_site/contact.html"
Scenario: Use site.time variable Scenario: Use site.time variable
Given I have a blank site Given I have an "index.html" page that contains "Generated on: {{ site.time }}"
And I have an "index.html" file that contains "Generated on: {{ site.time }}"
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Generated on: #{Date.today.strftime('%Y-%m-%d')}" in "_site/index.html" And I should see today's time in "_site/index.html"
Scenario: Use site.posts variable for latest post Scenario: Use site.posts variable for latest post
Given I have a blank site Given I have a _posts directory
And I have a _posts directory And I have an "index.html" page that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
And I have an "index.html" file that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
And I have the following posts: And I have the following posts:
| title | date | content | | title | date | content |
| First Post | 3/25/2009 | My First Post | | First Post | 3/25/2009 | My First Post |
@ -31,9 +28,8 @@ Feature: Site data
And I should see "Third Post: /2009/03/27/third-post.html" in "_site/index.html" And I should see "Third Post: /2009/03/27/third-post.html" in "_site/index.html"
Scenario: Use site.posts variable in a loop Scenario: Use site.posts variable in a loop
Given I have a blank site Given I have a _posts directory
And I have a _posts directory And I have an "index.html" page that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
And I have an "index.html" file that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
And I have the following posts: And I have the following posts:
| title | date | content | | title | date | content |
| First Post | 3/25/2009 | My First Post | | First Post | 3/25/2009 | My First Post |
@ -41,12 +37,11 @@ Feature: Site data
| Third Post | 3/27/2009 | My Third Post | | Third Post | 3/27/2009 | My Third Post |
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "Third Post Second Post First Post" in "_site/index.html" And I should see "Third Post Second Post First Post" in "_site/index.html"
Scenario: Use site.categories.code variable Scenario: Use site.categories.code variable
Given I have a blank site Given I have a _posts directory
And I have a _posts directory And I have an "index.html" page that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
And I have an "index.html" file that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
And I have the following posts: And I have the following posts:
| title | date | category | content | | title | date | category | content |
| Awesome Hack | 3/26/2009 | code | puts 'Hello World' | | Awesome Hack | 3/26/2009 | code | puts 'Hello World' |

View File

@ -13,11 +13,11 @@ Given /^I have a blank site in "(.*)"$/ do |path|
end end
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it # Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
Given /^I have an "(.*)" page(?: with layout "(.*)")? that contains "(.*)"$/ do |file, layout, text| Given /^I have an "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
File.open(file, 'w') do |f| File.open(file, 'w') do |f|
f.write <<EOF f.write <<EOF
--- ---
layout: #{layout || 'nil'} #{key || 'layout'}: #{value || 'nil'}
--- ---
#{text} #{text}
EOF EOF
@ -96,10 +96,6 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
end end
end end
When /^I go to "(.*)"$/ do |address|
pending
end
Then /^the (.*) directory should exist$/ do |dir| Then /^the (.*) directory should exist$/ do |dir|
assert File.directory?(dir) assert File.directory?(dir)
end end
@ -112,6 +108,10 @@ Then /^the "(.*)" file should not exist$/ do |file|
assert !File.exists?(file) assert !File.exists?(file)
end end
Then /^I should see today's time in "(.*)"$/ do |file|
assert_match Regexp.new(Time.now.to_s), File.open(file).readlines.join
end
Then /^I should see today's date in "(.*)"$/ do |file| Then /^I should see today's date in "(.*)"$/ do |file|
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
end end