Rubocop fixes for test/test_url.rb

This commit is contained in:
Brint O'Hearn 2016-05-19 20:32:56 -05:00
parent 498324bbff
commit 013e2f159d
2 changed files with 22 additions and 25 deletions

View File

@ -84,7 +84,6 @@ AllCops:
- test/test_static_file.rb
- test/test_tags.rb
- test/test_theme.rb
- test/test_url.rb
- test/test_utils.rb
- bin/**/*
- benchmark/**/*

View File

@ -1,8 +1,7 @@
require 'helper'
require "helper"
class TestURL < JekyllUnitTest
context "The URL class" do
should "throw an exception if neither permalink or template is specified" do
assert_raises ArgumentError do
URL.new(:placeholders => {})
@ -11,46 +10,46 @@ class TestURL < JekyllUnitTest
should "replace placeholders in templates" do
assert_equal "/foo/bar", URL.new(
:template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"}
:template => "/:x/:y",
:placeholders => { :x => "foo", :y => "bar" }
).to_s
end
should "handle multiple of the same key in the template" do
assert_equal '/foo/bar/foo/', URL.new(
:template => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"}
assert_equal "/foo/bar/foo/", URL.new(
:template => "/:x/:y/:x/",
:placeholders => { :x => "foo", :y => "bar" }
).to_s
end
should "use permalink if given" do
assert_equal "/le/perma/link", URL.new(
:template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"},
:permalink => "/le/perma/link"
:template => "/:x/:y",
:placeholders => { :x => "foo", :y => "bar" },
:permalink => "/le/perma/link"
).to_s
end
should "replace placeholders in permalinks" do
assert_equal "/foo/bar", URL.new(
:template => "/baz",
:permalink => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"}
:template => "/baz",
:permalink => "/:x/:y",
:placeholders => { :x => "foo", :y => "bar" }
).to_s
end
should "handle multiple of the same key in the permalink" do
assert_equal '/foo/bar/foo/', URL.new(
:template => "/baz",
:permalink => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"}
assert_equal "/foo/bar/foo/", URL.new(
:template => "/baz",
:permalink => "/:x/:y/:x/",
:placeholders => { :x => "foo", :y => "bar" }
).to_s
end
should "handle nil values for keys in the template" do
assert_equal '/foo/bar/', URL.new(
:template => "/:x/:y/:z/",
:placeholders => {:x => "foo", :y => "bar", :z => nil}
assert_equal "/foo/bar/", URL.new(
:template => "/:x/:y/:z/",
:placeholders => { :x => "foo", :y => "bar", :z => nil }
).to_s
end
@ -60,17 +59,16 @@ class TestURL < JekyllUnitTest
"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(
:template => '/methods/:title/:name:output_ext',
assert_equal "/methods/escape-+-20/escape-20.html", URL.new(
:template => "/methods/:title/:name:output_ext",
:placeholders => matching_doc.url_placeholders
).to_s
end
end
end