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_static_file.rb
- test/test_tags.rb - test/test_tags.rb
- test/test_theme.rb - test/test_theme.rb
- test/test_url.rb
- test/test_utils.rb - test/test_utils.rb
- bin/**/* - bin/**/*
- benchmark/**/* - benchmark/**/*

View File

@ -1,8 +1,7 @@
require 'helper' require "helper"
class TestURL < JekyllUnitTest class TestURL < JekyllUnitTest
context "The URL class" do context "The URL class" do
should "throw an exception if neither permalink or template is specified" do should "throw an exception if neither permalink or template is specified" do
assert_raises ArgumentError do assert_raises ArgumentError do
URL.new(:placeholders => {}) URL.new(:placeholders => {})
@ -12,21 +11,21 @@ class TestURL < JekyllUnitTest
should "replace placeholders in templates" do should "replace placeholders in templates" do
assert_equal "/foo/bar", URL.new( assert_equal "/foo/bar", URL.new(
:template => "/:x/:y", :template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"} :placeholders => { :x => "foo", :y => "bar" }
).to_s ).to_s
end end
should "handle multiple of the same key in the template" do should "handle multiple of the same key in the template" do
assert_equal '/foo/bar/foo/', URL.new( assert_equal "/foo/bar/foo/", URL.new(
:template => "/:x/:y/:x/", :template => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"} :placeholders => { :x => "foo", :y => "bar" }
).to_s ).to_s
end end
should "use permalink if given" do should "use permalink if given" do
assert_equal "/le/perma/link", URL.new( assert_equal "/le/perma/link", URL.new(
:template => "/:x/:y", :template => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"}, :placeholders => { :x => "foo", :y => "bar" },
:permalink => "/le/perma/link" :permalink => "/le/perma/link"
).to_s ).to_s
end end
@ -35,22 +34,22 @@ class TestURL < JekyllUnitTest
assert_equal "/foo/bar", URL.new( assert_equal "/foo/bar", URL.new(
:template => "/baz", :template => "/baz",
:permalink => "/:x/:y", :permalink => "/:x/:y",
:placeholders => {:x => "foo", :y => "bar"} :placeholders => { :x => "foo", :y => "bar" }
).to_s ).to_s
end end
should "handle multiple of the same key in the permalink" do should "handle multiple of the same key in the permalink" do
assert_equal '/foo/bar/foo/', URL.new( assert_equal "/foo/bar/foo/", URL.new(
:template => "/baz", :template => "/baz",
:permalink => "/:x/:y/:x/", :permalink => "/:x/:y/:x/",
:placeholders => {:x => "foo", :y => "bar"} :placeholders => { :x => "foo", :y => "bar" }
).to_s ).to_s
end end
should "handle nil values for keys in the template" do should "handle nil values for keys in the template" do
assert_equal '/foo/bar/', URL.new( assert_equal "/foo/bar/", URL.new(
:template => "/:x/:y/:z/", :template => "/:x/:y/:z/",
:placeholders => {:x => "foo", :y => "bar", :z => nil} :placeholders => { :x => "foo", :y => "bar", :z => nil }
).to_s ).to_s
end end
@ -60,17 +59,16 @@ class TestURL < JekyllUnitTest
"methods" => { "methods" => {
"output" => true "output" => true
} }
}, }
}) })
site.read site.read
matching_doc = site.collections["methods"].docs.find do |doc| matching_doc = site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/escape-+ #%20[].md" doc.relative_path == "_methods/escape-+ #%20[].md"
end 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
).to_s ).to_s
end end
end end
end end