diff --git a/features/site_configuration.feature b/features/site_configuration.feature index f5974d0b..90afd919 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -116,33 +116,45 @@ Feature: Site configuration And I should see "Post Layout:
content for entry1.
" in "_site/2007/12/31/entry1.html" And I should see "Post Layout:content for entry2.
" in "_site/2020/01/31/entry2.html" - Scenario: Generate proper dates with explicitly set timezone + Scenario: Generate proper dates with explicitly set timezone (which is the same) Given I have a _layouts directory - And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: \"%Y-%m-%d\" }}" + And I have a page layout that contains "Page Layout: {{ site.posts.size }}" And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}" And I have an "index.html" page with layout "page" that contains "site index page" And I have a configuration file with: | key | value | - | time | 2013-04-10 | | timezone | America/New_York | And I have a _posts directory And I have the following posts: - | title | date | layout | content | - | entry1 | "2013-04-09 23:22 -0400" | post | content for entry1. | - | entry2 | "2013-04-10 03:14 -0400" | post | content for entry2. | + | title | date | layout | content | + | entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. | + | entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. | When I run jekyll Then the _site directory should exist - And I should see "Page Layout: 2 on 2013-04-10" in "_site/index.html" + And I should see "Page Layout: 2" in "_site/index.html" And I should see "Post Layout:content for entry1.
built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html" And I should see "Post Layout:content for entry2.
built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html" + + Scenario: Generate proper dates with explicitly set timezone, which is very different + Given I have a _layouts directory + And I have a page layout that contains "Page Layout: {{ site.posts.size }}" + And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}" + And I have an "index.html" page with layout "page" that contains "site index page" And I have a configuration file with: | key | value | | timezone | Australia/Melbourne | + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. | + | entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. | When I run jekyll Then the _site directory should exist - And I should see "Page Layout: 2 on 2013-04-10" in "_site/index.html" - And I should see "Post Layout:content for entry1.
built at 2013-04-10T13:14:00+10:00" in "_site/2013/04/10/entry1.html" - And I should see "Post Layout:content for entry2.
built at 2013-04-10T17:14:00+10:00" in "_site/2013/04/10/entry2.html" + And I should see "Page Layout: 2" in "_site/index.html" + And the "_site/2013/04/10/entry1.html" file should exist + And the "_site/2013/04/10/entry2.html" file should exist + And I should see escaped "Post Layout:content for entry1.
built at 2013-04-10T13:22:00+10:00" in "_site/2013/04/10/entry1.html" + And I should see escaped "Post Layout:content for entry2.
built at 2013-04-10T17:14:00+10:00" in "_site/2013/04/10/entry2.html" Scenario: Limit the number of posts generated by most recent date Given I have a _posts directory diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 65556d37..c56ec42e 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -64,7 +64,15 @@ Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, dire if "draft" == status path = File.join(before || '.', '_drafts', after || '.', "#{title}.#{ext}") else - date = Date.strptime(post['date'], '%m/%d/%Y').strftime('%Y-%m-%d') + date = if post['date'].split.size > 1 + parsed_date = DateTime.strptime(post['date'], '%Y-%m-%d %H:%M %z') + post['date'] = parsed_date.to_s + parsed_date.strftime('%Y-%m-%d') + else + parsed_date = Date.strptime(post['date'], '%m/%d/%Y') # WHY WOULD YOU EVER DO THIS + post['date'] = parsed_date.to_s + parsed_date.strftime('%Y-%m-%d') + end path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{ext}") end @@ -72,6 +80,9 @@ Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, dire %w(title layout tag tags category categories published author path).each do |key| matter_hash[key] = post[key] if post[key] end + if "post" == status + matter_hash["date"] = post["date"] if post["date"] + end matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp content = post['content'] @@ -137,7 +148,11 @@ Then /^the (.*) directory should exist$/ do |dir| end Then /^I should see "(.*)" in "(.*)"$/ do |text, file| - assert_match Regexp.new(text), File.open(file).readlines.join + assert Regexp.new(text).match(File.open(file).readlines.join) +end + +Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file| + assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join) end Then /^the "(.*)" file should exist$/ do |file|