Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Green all around, finally.
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Apr 2, 2009
1 parent c52484a commit d590f2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
27 changes: 11 additions & 16 deletions features/site_data.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 protected]"
Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: [email protected]"
When I run jekyll
Then the _site directory should exist
And I should see "Contact: [email protected]" in "_site/index.html"
And I should see "Contact: [email protected]" 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 |
Expand All @@ -31,22 +28,20 @@ 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 |
| Second Post | 3/26/2009 | My Second Post |
| Third Post | 3/27/2009 | My Third Post |
When I run jekyll
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
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' |
Expand Down
12 changes: 6 additions & 6 deletions features/step_definitions/jekyll_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
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
Expand Down Expand Up @@ -96,10 +96,6 @@
end
end

When /^I go to "(.*)"$/ do |address|
pending
end

Then /^the (.*) directory should exist$/ do |dir|
assert File.directory?(dir)
end
Expand All @@ -112,6 +108,10 @@
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
Expand Down

0 comments on commit d590f2a

Please sign in to comment.