Sha256: 4df96fa43ad5cba6f637ea267e39f835163fb9c04bcde8ad7ac12391c61b4f4f
Contents?: true
Size: 1.75 KB
Versions: 14
Compression:
Stored size: 1.75 KB
Contents
require 'test/unit' require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/ext/Hash+Extensions') class TestHashExtensions < Test::Unit::TestCase def test_deep_merge! h1 = {key: 'value', key2: ['value1', 'value2']} h2 = {key3: {subkey1: 'value1'}, key: 'another_value'} exp_result = {:key=>"another_value", :key2=>["value1", "value2"], :key3=>{:subkey1=>"value1"}} actual_result = h1.deep_merge!(h2) assert_equal(exp_result, actual_result) end def test_deep_stringify_keys h = {key: {subkey1: 'value1', subkey2: {subsubkey1: 'value'}}} exp_result = {'key' => {'subkey1' => 'value1', 'subkey2' => {'subsubkey1' => 'value'}}} actual_result = h.deep_stringify_keys assert_not_equal(h, actual_result) assert_equal(exp_result, actual_result) end def test_deep_stringify_keys! h = {key: {subkey1: 'value1', subkey2: {subsubkey1: 'value'}}} exp_result = {'key' => {'subkey1' => 'value1', 'subkey2' => {'subsubkey1' => 'value'}}} actual_result = h.deep_stringify_keys! assert_equal(h, actual_result) assert_equal(exp_result, actual_result) end def test_deep_symbolize_keys h = {'key' => {'subkey1' => 'value1', 'subkey2' => {'subsubkey1' => 'value'}}} exp_result = {key: {subkey1: 'value1', subkey2: {subsubkey1: 'value'}}} actual_result = h.deep_symbolize_keys assert_not_equal(h, actual_result) assert_equal(exp_result, actual_result) end def test_deep_symbolize_keys! h = {'key' => {'subkey1' => 'value1', 'subkey2' => {'subsubkey1' => 'value'}}} exp_result = {key: {subkey1: 'value1', subkey2: {subsubkey1: 'value'}}} actual_result = h.deep_symbolize_keys! assert_equal(h, actual_result) assert_equal(exp_result, actual_result) end end
Version data entries
14 entries across 14 versions & 1 rubygems