mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-29 16:58:01 -05:00
This removes the following warnings: - /lib/jekyll/configuration.rb:151: warning: instance variable @default_config_file not initialized - /lib/jekyll/converter.rb:12: warning: instance variable @highlighter_prefix not initialized - /lib/jekyll/converter.rb:24: warning: instance variable @highlighter_suffix not initialized - /lib/jekyll/converters/markdown.rb:9: warning: instance variable @setup not initialized - /lib/jekyll/converters/markdown/kramdown_parser.rb:60: warning: instance variable @highlighter not initialized - /lib/jekyll/frontmatter_defaults.rb:97: warning: shadowing outer local variable - path - /lib/jekyll/plugin.rb:66: warning: instance variable @safe not initialized - /lib/jekyll/regenerator.rb:147: warning: instance variable @disabled not initialized - /test/test_convertible.rb:40: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_filters.rb:154: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_new_command.rb:84: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_site.rb:234: warning: assigned but unused variable - site - /test/test_site.rb:240: warning: assigned but unused variable - site - /test/test_site.rb:522: warning: assigned but unused variable - source - /test/test_tags.rb:153: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:425: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:449: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:496: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:496: warning: instance variable @result not initialized - /test/test_tags.rb:511: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:773: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_tags.rb:773: warning: instance variable @result not initialized - /test/test_tags.rb:788: warning: ambiguous first argument; put parentheses or a space even after `/' operator - /test/test_url.rb:66: warning: shadowing outer local variable - doc - /lib/jekyll/url.rb:119:in `escape_path': warning: URI.escape is obsolete
77 lines
2.1 KiB
Ruby
77 lines
2.1 KiB
Ruby
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 => {})
|
|
end
|
|
end
|
|
|
|
should "replace placeholders in templates" do
|
|
assert_equal "/foo/bar", URL.new(
|
|
: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"}
|
|
).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"
|
|
).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"}
|
|
).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"}
|
|
).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}
|
|
).to_s
|
|
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
|
|
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
|