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
Scenario: Use page variable in a page
Given I have a blank site
And I have an "contact.html" file with title "Contact" that contains "{{ page.title }}: email@me.com"
Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: email@me.com"
When I run jekyll
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
Given I have a blank site
And I have an "index.html" file that contains "Generated on: {{ site.time }}"
Given I have an "index.html" page that contains "Generated on: {{ site.time }}"
When I run jekyll
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
Given I have a blank site
And I have a _posts directory
And I have an "index.html" file that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
Given 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 the following posts:
| title | date | content |
| 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"
Scenario: Use site.posts variable in a loop
Given I have a blank site
And I have a _posts directory
And I have an "index.html" file that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
Given 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 the following posts:
| title | date | content |
| First Post | 3/25/2009 | My First Post |
@ -44,9 +40,8 @@ Feature: Site data
And I should see "Third Post Second Post First Post" in "_site/index.html"
Scenario: Use site.categories.code variable
Given I have a blank site
And I have a _posts directory
And I have an "index.html" file that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
Given 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 the following posts:
| title | date | category | content |
| 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
# 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|
f.write <<EOF
---
layout: #{layout || 'nil'}
#{key || 'layout'}: #{value || 'nil'}
---
#{text}
EOF
@ -96,10 +96,6 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
end
end
When /^I go to "(.*)"$/ do |address|
pending
end
Then /^the (.*) directory should exist$/ do |dir|
assert File.directory?(dir)
end
@ -112,6 +108,10 @@ Then /^the "(.*)" file should not exist$/ do |file|
assert !File.exists?(file)
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|
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
end