Rename those Utils functions.

This commit is contained in:
Parker Moore
2014-03-04 15:52:05 -05:00
parent 5e8643d855
commit 7787d64bce
11 changed files with 25 additions and 27 deletions

View File

@@ -29,7 +29,7 @@ class Test::Unit::TestCase
include RR::Adapters::TestUnit
def build_configs(overrides, base_hash = Jekyll::Configuration::DEFAULTS)
Utils.hash_deep_merge(base_hash, overrides)
Utils.deep_merge_hashes(base_hash, overrides)
end
def site_configuration(overrides = {})

View File

@@ -156,7 +156,7 @@ class TestConfiguration < Test::Unit::TestCase
should "load different config if specified" do
mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
mock($stdout).puts("Configuration file: #{@paths[:other]}")
assert_equal Utils.hash_deep_merge(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
end
should "load default config if path passed is empty" do
@@ -186,7 +186,7 @@ class TestConfiguration < Test::Unit::TestCase
mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
mock($stdout).puts("Configuration file: #{@paths[:default]}")
mock($stdout).puts("Configuration file: #{@paths[:other]}")
assert_equal Utils.hash_deep_merge(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] })
assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] })
end
end
end

View File

@@ -35,7 +35,7 @@ class TestKramdown < Test::Unit::TestCase
assert_match /<p>(&#8220;|“)Pit(&#8217;|)hy(&#8221;|”)<\/p>/, @markdown.convert(%{"Pit'hy"}).strip
override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } }
markdown = Converters::Markdown.new(Utils.hash_deep_merge(@config, override))
markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override))
assert_match /<p>(&#171;|«)Pit(&#8250;|)hy(&#187;|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip
end

View File

@@ -7,57 +7,57 @@ class TestUtils < Test::Unit::TestCase
should "return empty array with no values" do
data = {}
assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return empty array with no matching values" do
data = { 'foo' => 'bar' }
assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return empty array with matching nil singular" do
data = { 'foo' => 'bar', 'tag' => nil, 'tags' => ['dog', 'cat'] }
assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return single value array with matching singular" do
data = { 'foo' => 'bar', 'tag' => 'dog', 'tags' => ['dog', 'cat'] }
assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return single value array with matching singular with spaces" do
data = { 'foo' => 'bar', 'tag' => 'dog cat', 'tags' => ['dog', 'cat'] }
assert_equal ['dog cat'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return empty array with matching nil plural" do
data = { 'foo' => 'bar', 'tags' => nil }
assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return empty array with matching empty array" do
data = { 'foo' => 'bar', 'tags' => [] }
assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return single value array with matching plural with single string value" do
data = { 'foo' => 'bar', 'tags' => 'dog' }
assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return multiple value array with matching plural with single string value with spaces" do
data = { 'foo' => 'bar', 'tags' => 'dog cat' }
assert_equal ['dog', 'cat'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog', 'cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return single value array with matching plural with single value array" do
data = { 'foo' => 'bar', 'tags' => ['dog'] }
assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
should "return multiple value array with matching plural with multiple value array" do
data = { 'foo' => 'bar', 'tags' => ['dog', 'cat'] }
assert_equal ['dog', 'cat'], Utils.hash_pluralized_array(data, 'tag', 'tags')
assert_equal ['dog', 'cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags')
end
end