Following post step is getting confusing, but it works
This commit is contained in:
parent
829530be36
commit
03f511be61
|
@ -78,10 +78,10 @@ Feature: Post data
|
||||||
And I have the following post in "movies/scifi":
|
And I have the following post in "movies/scifi":
|
||||||
| title | date | layout | content |
|
| title | date | layout | content |
|
||||||
| Star Wars | 3/27/2009 | simple | Luke, I am your father. |
|
| Star Wars | 3/27/2009 | simple | Luke, I am your father. |
|
||||||
And I have a simple layout that contains "Post categories: {{ site.posts.first.categories }}"
|
And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}"
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Post categories: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
|
And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
|
||||||
|
|
||||||
Scenario: Use post.categories variable when category is in YAML
|
Scenario: Use post.categories variable when category is in YAML
|
||||||
Given I have a _posts directory
|
Given I have a _posts directory
|
||||||
|
@ -92,30 +92,31 @@ Feature: Post data
|
||||||
And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}"
|
And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}"
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Post categories: movies" in "_site/movies/2009/03/27/star-wars.html"
|
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||||
|
|
||||||
Scenario: Use post.categories variable when categories are in YAML
|
Scenario: Use post.categories variable when categories are in YAML
|
||||||
Given I have a _posts directory
|
Given I have a _posts directory
|
||||||
And I have a _layouts directory
|
And I have a _layouts directory
|
||||||
And I have the following post:
|
And I have the following post:
|
||||||
| title | date | layout | categories | content |
|
| title | date | layout | categories | content |
|
||||||
| Star Wars | 3/27/2009 | simple | movies, scifi | Luke, I am your father. |
|
| Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. |
|
||||||
And I have a simple layout that contains "Post categories: {{ site.posts.first.categories }}"
|
And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}"
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Post categories: movies scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
|
And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html"
|
||||||
|
|
||||||
Scenario: Use post.topics variable
|
Scenario: Use post.topics variable
|
||||||
Given I have a _posts directory
|
Given I have a _posts directory
|
||||||
And I have a _posts/movies directory
|
And I have a _posts/movies directory
|
||||||
And I have a _posts/movies/scifi directory
|
And I have a _posts/movies/scifi directory
|
||||||
And I have the following post:
|
And I have a _layouts directory
|
||||||
|
And I have the following post under "movies/scifi":
|
||||||
| title | date | layout | content |
|
| title | date | layout | content |
|
||||||
| Star Wars | 3/27/2009 | simple | Luke, I am your father. |
|
| Star Wars | 3/27/2009 | simple | Luke, I am your father. |
|
||||||
And I have a simple layout that contains "Post topics: {{ site.posts.first.topics }}"
|
And I have a simple layout that contains "Post topics: {{ site.posts.first.topics | array_to_sentence_string }}"
|
||||||
When I run jekyll
|
When I run jekyll
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Post topics: movies scifi" in "_site/2009/03/27/star-wars.html"
|
And I should see "Post topics: movies and scifi" in "_site/2009/03/27/star-wars.html"
|
||||||
|
|
||||||
Scenario: Disable a post from being published
|
Scenario: Disable a post from being published
|
||||||
Given I have a _posts directory
|
Given I have a _posts directory
|
||||||
|
|
|
@ -39,14 +39,21 @@ Given /^I have a (.*) directory$/ do |dir|
|
||||||
FileUtils.mkdir(dir)
|
FileUtils.mkdir(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^I have the following posts?(?: in "(.*)")?:$/ do |dir, table|
|
Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, table|
|
||||||
table.hashes.each do |post|
|
table.hashes.each do |post|
|
||||||
date = Date.parse(post['date']).strftime('%Y-%m-%d')
|
date = Date.parse(post['date']).strftime('%Y-%m-%d')
|
||||||
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
||||||
path = File.join(dir || '', '_posts', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
|
||||||
|
if direction && direction == "in"
|
||||||
|
before = folder || '.'
|
||||||
|
elsif direction && direction == "under"
|
||||||
|
after = folder || '.'
|
||||||
|
end
|
||||||
|
|
||||||
|
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
||||||
|
|
||||||
matter_hash = {}
|
matter_hash = {}
|
||||||
%w(title layout tags).each do |key|
|
%w(title layout tags category categories).each do |key|
|
||||||
matter_hash[key] = post[key] if post[key]
|
matter_hash[key] = post[key] if post[key]
|
||||||
end
|
end
|
||||||
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
||||||
|
|
Loading…
Reference in New Issue