fix incorrectly passed arguments to assert_equal (#7134)

Merge pull request 7134
This commit is contained in:
Ashwin Maroli 2018-07-16 01:41:45 +05:30 committed by jekyllbot
parent 16e9820dac
commit 506c764e1e
7 changed files with 52 additions and 60 deletions

View File

@ -15,7 +15,7 @@ class TestAnsi < JekyllUnitTest
end end
should "be able to strip colors" do should "be able to strip colors" do
assert_equal @subject.strip(@subject.yellow(@subject.red("hello"))), "hello" assert_equal "hello", @subject.strip(@subject.yellow(@subject.red("hello")))
end end
should "be able to detect colors" do should "be able to detect colors" do

View File

@ -9,11 +9,11 @@ class TestCollections < JekyllUnitTest
end end
should "sanitize the label name" do should "sanitize the label name" do
assert_equal @collection.label, "....etcpassword" assert_equal "....etcpassword", @collection.label
end end
should "have a sanitized relative path name" do should "have a sanitized relative path name" do
assert_equal @collection.relative_directory, "_....etcpassword" assert_equal "_....etcpassword", @collection.relative_directory
end end
should "have a sanitized full path" do should "have a sanitized full path" do
@ -27,11 +27,11 @@ class TestCollections < JekyllUnitTest
end end
should "sanitize the label name" do should "sanitize the label name" do
assert_equal @collection.label, "methods" assert_equal "methods", @collection.label
end end
should "have default URL template" do should "have default URL template" do
assert_equal @collection.url_template, "/:collection/:path:output_ext" assert_equal "/:collection/:path:output_ext", @collection.url_template
end end
should "contain no docs when initialized" do should "contain no docs when initialized" do
@ -39,7 +39,7 @@ class TestCollections < JekyllUnitTest
end end
should "know its relative directory" do should "know its relative directory" do
assert_equal @collection.relative_directory, "_methods" assert_equal "_methods", @collection.relative_directory
end end
should "know the full path to itself on the filesystem" do should "know the full path to itself on the filesystem" do
@ -48,15 +48,15 @@ class TestCollections < JekyllUnitTest
context "when turned into Liquid" do context "when turned into Liquid" do
should "have a label attribute" do should "have a label attribute" do
assert_equal @collection.to_liquid["label"], "methods" assert_equal "methods", @collection.to_liquid["label"]
end end
should "have a docs attribute" do should "have a docs attribute" do
assert_equal @collection.to_liquid["docs"], [] assert_equal [], @collection.to_liquid["docs"]
end end
should "have a files attribute" do should "have a files attribute" do
assert_equal @collection.to_liquid["files"], [] assert_equal [], @collection.to_liquid["files"]
end end
should "have a directory attribute" do should "have a directory attribute" do
@ -64,18 +64,18 @@ class TestCollections < JekyllUnitTest
end end
should "have a relative_directory attribute" do should "have a relative_directory attribute" do
assert_equal @collection.to_liquid["relative_directory"], "_methods" assert_equal "_methods", @collection.to_liquid["relative_directory"]
end end
should "have a output attribute" do should "have a output attribute" do
assert_equal @collection.to_liquid["output"], false assert_equal false, @collection.to_liquid["output"]
end end
end end
should "know whether it should be written or not" do should "know whether it should be written or not" do
assert_equal @collection.write?, false assert_equal false, @collection.write?
@collection.metadata["output"] = true @collection.metadata["output"] = true
assert_equal @collection.write?, true assert_equal true, @collection.write?
@collection.metadata.delete "output" @collection.metadata.delete "output"
end end
end end
@ -107,7 +107,7 @@ class TestCollections < JekyllUnitTest
end end
should "have custom URL template" do should "have custom URL template" do
assert_equal @collection.url_template, "/awesome/:path/" assert_equal "/awesome/:path/", @collection.url_template
end end
end end
@ -174,7 +174,8 @@ class TestCollections < JekyllUnitTest
end end
should "extract the configuration collection information as metadata" do should "extract the configuration collection information as metadata" do
assert_equal @collection.metadata, "foo" => "bar", "baz" => "whoo" expected = { "foo" => "bar", "baz" => "whoo" }
assert_equal expected, @collection.metadata
end end
end end

View File

@ -154,9 +154,7 @@ class TestCommandsServe < JekyllUnitTest
end end
should "label itself" do should "label itself" do
assert_equal( assert_equal :serve, @merc.name
@merc.name, :serve
)
end end
should "have aliases" do should "have aliases" do
@ -269,11 +267,11 @@ class TestCommandsServe < JekyllUnitTest
context "verbose" do context "verbose" do
should "debug when verbose" do should "debug when verbose" do
assert_equal custom_opts("verbose" => true)[:Logger].level, 5 assert_equal 5, custom_opts("verbose" => true)[:Logger].level
end end
should "warn when not verbose" do should "warn when not verbose" do
assert_equal custom_opts({})[:Logger].level, 3 assert_equal 3, custom_opts({})[:Logger].level
end end
end end
@ -305,8 +303,8 @@ class TestCommandsServe < JekyllUnitTest
) )
assert result[:SSLEnable] assert result[:SSLEnable]
assert_equal result[:SSLPrivateKey], "c2" assert_equal "c2", result[:SSLPrivateKey]
assert_equal result[:SSLCertificate], "c1" assert_equal "c1", result[:SSLCertificate]
end end
end end
end end

View File

@ -17,7 +17,7 @@ class TestConfiguration < JekyllUnitTest
should "merge input over defaults" do should "merge input over defaults" do
result = Configuration.from("source" => "blah") result = Configuration.from("source" => "blah")
refute_equal result["source"], Configuration::DEFAULTS["source"] refute_equal result["source"], Configuration::DEFAULTS["source"]
assert_equal result["source"], "blah" assert_equal "blah", result["source"]
end end
should "return a valid Configuration instance" do should "return a valid Configuration instance" do
@ -26,13 +26,11 @@ class TestConfiguration < JekyllUnitTest
should "add default collections" do should "add default collections" do
result = Configuration.from({}) result = Configuration.from({})
assert_equal( expected = { "posts" => {
result["collections"], "output" => true,
"posts" => { "permalink" => "/:categories/:year/:month/:day/:title:output_ext",
"output" => true, }, }
"permalink" => "/:categories/:year/:month/:day/:title:output_ext", assert_equal expected, result["collections"]
}
)
end end
should "NOT backwards-compatibilize" do should "NOT backwards-compatibilize" do
@ -68,32 +66,29 @@ class TestConfiguration < JekyllUnitTest
should "turn an array into a hash" do should "turn an array into a hash" do
result = Configuration[{ "collections" => %w(methods) }].add_default_collections result = Configuration[{ "collections" => %w(methods) }].add_default_collections
assert_instance_of Hash, result["collections"] assert_instance_of Hash, result["collections"]
assert_equal( expected = { "posts" => { "output" => true }, "methods" => {} }
result["collections"], assert_equal expected, result["collections"]
"posts" => { "output" => true }, "methods" => {}
)
end end
should "only assign collections.posts.permalink if a permalink is specified" do should "only assign collections.posts.permalink if a permalink is specified" do
result = Configuration[{ "permalink" => "pretty", "collections" => {} }] result = Configuration[{ "permalink" => "pretty", "collections" => {} }]
.add_default_collections .add_default_collections
assert_equal( expected = { "posts" => {
result["collections"], "output" => true,
"posts" => { "permalink" => "/:categories/:year/:month/:day/:title/",
"output" => true, }, }
"permalink" => "/:categories/:year/:month/:day/:title/", assert_equal expected, result["collections"]
}
)
result = Configuration[{ "permalink" => nil, "collections" => {} }] result = Configuration[{ "permalink" => nil, "collections" => {} }]
.add_default_collections .add_default_collections
assert_equal result["collections"], "posts" => { "output" => true } expected = { "posts" => { "output" => true } }
assert_equal expected, result["collections"]
end end
should "forces posts to output" do should "forces posts to output" do
result = Configuration[{ "collections" => { "posts" => { "output" => false } } }] result = Configuration[{ "collections" => { "posts" => { "output" => false } } }]
.add_default_collections .add_default_collections
assert_equal result["collections"]["posts"]["output"], true assert_equal true, result["collections"]["posts"]["output"]
end end
end end
@ -216,23 +211,19 @@ class TestConfiguration < JekyllUnitTest
should "transform string exclude into an array" do should "transform string exclude into an array" do
assert @config.key?("exclude") assert @config.key?("exclude")
assert @config.backwards_compatibilize.key?("exclude") assert @config.backwards_compatibilize.key?("exclude")
assert_equal( expected = %w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown)
@config.backwards_compatibilize["exclude"], assert_equal expected, @config.backwards_compatibilize["exclude"]
%w(READ-ME.md Gemfile CONTRIBUTING.hello.markdown)
)
end end
should "transform string include into an array" do should "transform string include into an array" do
assert @config.key?("include") assert @config.key?("include")
assert @config.backwards_compatibilize.key?("include") assert @config.backwards_compatibilize.key?("include")
assert_equal( expected = %w(STOP_THE_PRESSES.txt .heloses .git)
@config.backwards_compatibilize["include"], assert_equal expected, @config.backwards_compatibilize["include"]
%w(STOP_THE_PRESSES.txt .heloses .git)
)
end end
should "set highlighter to pygments" do should "set highlighter to pygments" do
assert @config.key?("pygments") assert @config.key?("pygments")
assert !@config.backwards_compatibilize.key?("pygments") assert !@config.backwards_compatibilize.key?("pygments")
assert_equal @config.backwards_compatibilize["highlighter"], "pygments" assert_equal "pygments", @config.backwards_compatibilize["highlighter"]
end end
should "adjust directory names" do should "adjust directory names" do
assert @config.key?("layouts") assert @config.key?("layouts")
@ -500,12 +491,13 @@ class TestConfiguration < JekyllUnitTest
) )
) )
assert_equal( assert_equal(
config["folded_string"], "This string of text will ignore newlines till the next key.\n",
"This string of text will ignore newlines till the next key.\n" config["folded_string"]
) )
assert_equal( assert_equal(
config["clean_folded_string"], "This string of text will ignore newlines till the next key.",
"This string of text will ignore newlines till the next key." config["clean_folded_string"]
) )
end end

View File

@ -155,7 +155,7 @@ class TestKramdown < JekyllUnitTest
) )
expect(Kramdown::Document).to receive(:new) do |arg1, hash| expect(Kramdown::Document).to receive(:new) do |arg1, hash|
assert_equal hash["syntax_highlighter_opts"]["hello"], "world" assert_equal "world", hash["syntax_highlighter_opts"]["hello"]
original.call(arg1, hash) original.call(arg1, hash)
end end

View File

@ -22,11 +22,11 @@ class TestLiquidExtensions < JekyllUnitTest
end end
should "extract the var properly" do should "extract the var properly" do
assert_equal @template.render("page" => { "name" => "tobi" }), "hi tobi" assert_equal "hi tobi", @template.render("page" => { "name" => "tobi" })
end end
should "return the variable name if the value isn't there" do should "return the variable name if the value isn't there" do
assert_equal @template.render("page" => { "title" => "tobi" }), "hi page.name" assert_equal "hi page.name", @template.render("page" => { "title" => "tobi" })
end end
end end
end end

View File

@ -153,7 +153,8 @@ class TestRegenerator < JekyllUnitTest
assert @regenerator.cache[@path] assert @regenerator.cache[@path]
@regenerator.clear_cache @regenerator.clear_cache
assert_equal @regenerator.cache, {} expected = {}
assert_equal expected, @regenerator.cache
end end
should "write to the metadata file" do should "write to the metadata file" do