mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Rename those Utils functions.
This commit is contained in:
@@ -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 = {})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -35,7 +35,7 @@ class TestKramdown < Test::Unit::TestCase
|
||||
assert_match /<p>(“|“)Pit(’|’)hy(”|”)<\/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>(«|«)Pit(›|›)hy(»|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user