Add failing test for permalink templates with trailing underscores

This commit is contained in:
Parker Moore 2016-11-10 15:20:11 -08:00
parent 51d04cbd00
commit f27eb77d0b
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
2 changed files with 26 additions and 23 deletions

View File

@ -103,6 +103,21 @@ class JekyllUnitTest < Minitest::Test
RSpec::Mocks.teardown RSpec::Mocks.teardown
end end
def fixture_document(relative_path)
site = fixture_site({
"collections" => {
"methods" => {
"output" => true
}
}
})
site.read
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == relative_path
end
[site, matching_doc]
end
def fixture_site(overrides = {}) def fixture_site(overrides = {})
Jekyll::Site.new(site_configuration(overrides)) Jekyll::Site.new(site_configuration(overrides))
end end

View File

@ -54,17 +54,7 @@ class TestURL < JekyllUnitTest
end end
should "handle UrlDrop as a placeholder in addition to a hash" do should "handle UrlDrop as a placeholder in addition to a hash" do
site = fixture_site({ _, matching_doc = fixture_document("_methods/escape-+ #%20[].md")
"collections" => {
"methods" => {
"output" => true
}
}
})
site.read
matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_equal "/methods/escape-+-20/escape-20.html", URL.new( assert_equal "/methods/escape-+-20/escape-20.html", URL.new(
:template => "/methods/:title/:name:output_ext", :template => "/methods/:title/:name:output_ext",
:placeholders => matching_doc.url_placeholders :placeholders => matching_doc.url_placeholders
@ -81,18 +71,16 @@ class TestURL < JekyllUnitTest
end end
end end
should "ignore NoMethodErrors when a placeholder is not found" do should "check for key without trailing underscore" do
site = fixture_site({ _, matching_doc = fixture_document("_methods/configuration.md")
"collections" => { assert_equal "/lol", URL.new(
"methods" => { :template => "/:year-:month-:day_:title",
"output" => true :placeholders => matching_doc.url_placeholders
} ).to_s
} end
})
site.read should "raise custom error when URL placeholder doesn't have key" do
matching_doc = site.collections["methods"].docs.find do |doc| _, matching_doc = fixture_document("_methods/escape-+ #%20[].md")
doc.relative_path == "_methods/escape-+ #%20[].md"
end
assert_raises NoMethodError do assert_raises NoMethodError do
URL.new( URL.new(
:template => "/methods/:headline", :template => "/methods/:headline",