diff --git a/features/frontmatter_defaults.feature b/features/frontmatter_defaults.feature index 3f2d3cd5..683af655 100644 --- a/features/frontmatter_defaults.feature +++ b/features/frontmatter_defaults.feature @@ -77,3 +77,54 @@ Feature: frontmatter defaults Then I should see "a blog by some guy" in "_site/frontmatter.html" And I should see "nothing" in "_site/override.html" But the "_site/perma.html" file should not exist + + Scenario: Use frontmatter defaults in collections + Given I have a _slides directory + And I have a "index.html" file that contains "nothing" + And I have a "_slides/slide1.html" file with content: + """ + Value: {{ page.myval }} + """ + And I have a "_config.yml" file with content: + """ + collections: + slides: + output: true + defaults: + - + scope: + path: "" + type: slides + values: + myval: "Test" + """ + When I run jekyll build + Then the _site directory should exist + And I should see "Value: Test" in "_site/slides/slide1.html" + + Scenario: Override frontmatter defaults inside a collection + Given I have a _slides directory + And I have a "index.html" file that contains "nothing" + And I have a "_slides/slide2.html" file with content: + """ + --- + myval: Override + --- + Value: {{ page.myval }} + """ + And I have a "_config.yml" file with content: + """ + collections: + slides: + output: true + defaults: + - + scope: + path: "" + type: slides + values: + myval: "Test" + """ + When I run jekyll build + Then the _site directory should exist + And I should see "Value: Override" in "_site/slides/slide2.html" diff --git a/test/test_document.rb b/test/test_document.rb index 794c2117..ee52a280 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -42,6 +42,45 @@ class TestDocument < Test::Unit::TestCase end + context "a document as part of a collection with frontmatter defaults" do + setup do + @site = Site.new(Jekyll.configuration({ + "collections" => ["methods"], + "source" => source_dir, + "destination" => dest_dir, + "defaults" => [{ + "scope"=> {"path"=>"", "type"=>"methods"}, + "values"=> { + "nested"=> { + "test1"=>"default1", + "test2"=>"default1" + } + } + }] + })) + @site.process + @document = @site.collections["methods"].docs.first + end + + should "know the frontmatter defaults" do + assert_equal({ + "title"=>"Jekyll.configuration", + "nested"=> { + "test1"=>"default1", + "test2"=>"default1"}, + "whatever"=>"foo.bar" + }, @document.data) + end + + should "overwrite a default value in the document frontmatter" do + + end + + should "overwrite a nested default value in the document frontmatter" do + + end + end + context " a document part of a rendered collection" do end