diff --git a/features/embed_filters.feature b/features/embed_filters.feature index d61901c8..9d513ec2 100644 --- a/features/embed_filters.feature +++ b/features/embed_filters.feature @@ -58,3 +58,16 @@ Feature: Embed filters Then the _site directory should exist And I should see "By

Obi-wan

" in "_site/2009/03/27/star-wars.html" + Scenario: Sort by an arbitrary variable + Given I have a _layouts directory + And I have the following page: + | title | layout | value | content | + | Page-1 | default | 8 | Something | + And I have the following page: + | title | layout | value | content | + | Page-2 | default | 6 | Something | + And I have a default layout that contains "{{ site.pages | sort:'value' | map:'title' | join:', ' }}" + When I run jekyll + Then the _site directory should exist + And I should see exactly "Page-2, Page-1" in "_site/page-1.html" + And I should see exactly "Page-2, Page-1" in "_site/page-2.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 43c7e31d..8ff7500e 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -1,3 +1,22 @@ +def file_content_from_hash(input_hash) + matter_hash = input_hash.reject { |k, v| k == "content" } + matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp + + content = if input_hash['input'] && input_hash['filter'] + "{{ #{input_hash['input']} | #{input_hash['filter']} }}" + else + input_hash['content'] + end + + <:" + end + end + context "with pretty url style" do setup do @site.permalink_style = :pretty diff --git a/test/test_post.rb b/test/test_post.rb index a61fc674..418e60d7 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -25,6 +25,34 @@ class TestPost < Test::Unit::TestCase assert !Post.valid?("blah") end + should "make properties accessible through #[]" do + post = setup_post('2013-12-20-properties.text') + + attrs = { + categories: %w(foo bar baz), + content: "All the properties.\n\nPlus an excerpt.\n", + date: Time.new(2013, 12, 20), + dir: "/foo/bar/baz/2013/12/20", + excerpt: "All the properties.\n\n", + foo: 'bar', + id: "/foo/bar/baz/2013/12/20/properties", + layout: 'default', + name: nil, + # path: "properties.html", + permalink: nil, + published: nil, + tags: %w(ay bee cee), + title: 'Properties Post', + url: "/foo/bar/baz/2013/12/20/properties.html" + } + + attrs.each do |attr, val| + attr_str = attr.to_s + result = post[attr_str] + assert_equal val, result, "For :" + end + end + context "processing posts" do setup do @post = Post.allocate diff --git a/test/test_site.rb b/test/test_site.rb index 04e2b3d0..2d45ea7c 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -157,7 +157,7 @@ class TestSite < Test::Unit::TestCase should "sort pages alphabetically" do stub.proxy(Dir).entries { |entries| entries.reverse } @site.process - sorted_pages = %w(.htaccess about.html bar.html contacts.html deal.with.dots.html foo.md index.html index.html sitemap.xml symlinked-file) + sorted_pages = %w(.htaccess about.html bar.html contacts.html deal.with.dots.html foo.md index.html index.html properties.html sitemap.xml symlinked-file) assert_equal sorted_pages, @site.pages.map(&:name) end @@ -183,7 +183,7 @@ class TestSite < Test::Unit::TestCase assert_equal posts.size - @num_invalid_posts, @site.posts.size assert_equal categories, @site.categories.keys.sort - assert_equal 4, @site.categories['foo'].size + assert_equal 5, @site.categories['foo'].size end context 'error handling' do