Includes tests for frontmatter defaults in documents

This commit is contained in:
Jens Nazarenus 2014-05-17 01:21:57 +02:00
parent c8786b7b28
commit e868a8437f
2 changed files with 90 additions and 0 deletions

View File

@ -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"

View File

@ -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