diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature new file mode 100644 index 00000000..2254e29d --- /dev/null +++ b/features/post_excerpts.feature @@ -0,0 +1,50 @@ +Feature: Post excerpts + As a hacker who likes to blog + I want to be able to make a static sitej + In order to share my awesome ideas with the interwebs + But some people can only focus for a few moments + So just give them a taste + + Scenario: An excerpt without a layout + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And I should see exactly "
content for entry1.
" in "_site/index.html" + + Scenario: An excerpt from a post with a layout + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have a _layouts directory + And I have a post layout that contains "{{ page.excerpt }}" + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And the _site/2007 directory should exist + And the _site/2007/12 directory should exist + And the _site/2007/12/31 directory should exist + And the "_site/2007/12/31/entry1.html" file should exist + And I should see exactly "content for entry1.
" in "_site/2007/12/31/entry1.html" + And I should see exactly "content for entry1.
" in "_site/index.html" + + Scenario: An excerpt from a post with a layout which has context + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have a _layouts directory + And I have a post layout that contains "{{ page.excerpt }}" + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And the _site/2007 directory should exist + And the _site/2007/12 directory should exist + And the _site/2007/12/31 directory should exist + And the "_site/2007/12/31/entry1.html" file should exist + And I should see exactly "content for entry1.
" in "_site/index.html" + And I should see exactly "content for entry1.
" in "_site/2007/12/31/entry1.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 9208c4ec..136f048d 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -4,6 +4,8 @@ Before do Dir.chdir(TEST_DIR) end +World(Test::Unit::Assertions) + Given /^I have a blank site in "(.*)"$/ do |path| FileUtils.mkdir(path) end @@ -143,6 +145,10 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert Regexp.new(text).match(File.open(file).readlines.join) end +Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file| + assert_equal text, File.open(file).readlines.join.strip +end + Then /^I should not see "(.*)" in "(.*)"$/ do |text, file| assert_no_match Regexp.new(text), File.read(file) end