Add failing test for permalink templates with trailing underscores
This commit is contained in:
parent
51d04cbd00
commit
f27eb77d0b
|
@ -103,6 +103,21 @@ class JekyllUnitTest < Minitest::Test
|
|||
RSpec::Mocks.teardown
|
||||
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 = {})
|
||||
Jekyll::Site.new(site_configuration(overrides))
|
||||
end
|
||||
|
|
|
@ -54,17 +54,7 @@ class TestURL < JekyllUnitTest
|
|||
end
|
||||
|
||||
should "handle UrlDrop as a placeholder in addition to a hash" do
|
||||
site = fixture_site({
|
||||
"collections" => {
|
||||
"methods" => {
|
||||
"output" => true
|
||||
}
|
||||
}
|
||||
})
|
||||
site.read
|
||||
matching_doc = site.collections["methods"].docs.find do |doc|
|
||||
doc.relative_path == "_methods/escape-+ #%20[].md"
|
||||
end
|
||||
_, matching_doc = fixture_document("_methods/escape-+ #%20[].md")
|
||||
assert_equal "/methods/escape-+-20/escape-20.html", URL.new(
|
||||
:template => "/methods/:title/:name:output_ext",
|
||||
:placeholders => matching_doc.url_placeholders
|
||||
|
@ -81,18 +71,16 @@ class TestURL < JekyllUnitTest
|
|||
end
|
||||
end
|
||||
|
||||
should "ignore NoMethodErrors when a placeholder is not found" do
|
||||
site = fixture_site({
|
||||
"collections" => {
|
||||
"methods" => {
|
||||
"output" => true
|
||||
}
|
||||
}
|
||||
})
|
||||
site.read
|
||||
matching_doc = site.collections["methods"].docs.find do |doc|
|
||||
doc.relative_path == "_methods/escape-+ #%20[].md"
|
||||
should "check for key without trailing underscore" do
|
||||
_, matching_doc = fixture_document("_methods/configuration.md")
|
||||
assert_equal "/lol", URL.new(
|
||||
:template => "/:year-:month-:day_:title",
|
||||
:placeholders => matching_doc.url_placeholders
|
||||
).to_s
|
||||
end
|
||||
|
||||
should "raise custom error when URL placeholder doesn't have key" do
|
||||
_, matching_doc = fixture_document("_methods/escape-+ #%20[].md")
|
||||
assert_raises NoMethodError do
|
||||
URL.new(
|
||||
:template => "/methods/:headline",
|
||||
|
|
Loading…
Reference in New Issue