|
73 | 73 | hash['key1'].should == { 'a' => 1, 'b' => 99 } |
74 | 74 | hash['key2'].should == { 'c' => 3 } |
75 | 75 | end |
| 76 | + |
| 77 | + it 'should not change the original hashes' do |
| 78 | + hash1 = {'one' => { 'two' => 2 } } |
| 79 | + hash2 = { 'one' => { 'three' => 3 } } |
| 80 | + hash = scope.function_deep_merge([hash1, hash2]) |
| 81 | + hash1.should == {'one' => { 'two' => 2 } } |
| 82 | + hash2.should == { 'one' => { 'three' => 3 } } |
| 83 | + hash['one'].should == { 'two' => 2, 'three' => 3 } |
| 84 | + end |
| 85 | + |
| 86 | + it 'should not change the original hashes 2' do |
| 87 | + hash1 = {'one' => { 'two' => [1,2] } } |
| 88 | + hash2 = { 'one' => { 'three' => 3 } } |
| 89 | + hash = scope.function_deep_merge([hash1, hash2]) |
| 90 | + hash1.should == {'one' => { 'two' => [1,2] } } |
| 91 | + hash2.should == { 'one' => { 'three' => 3 } } |
| 92 | + hash['one'].should == { 'two' => [1,2], 'three' => 3 } |
| 93 | + end |
| 94 | + |
| 95 | + it 'should not change the original hashes 3' do |
| 96 | + hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } } |
| 97 | + hash2 = { 'one' => { 'three' => 3 } } |
| 98 | + hash = scope.function_deep_merge([hash1, hash2]) |
| 99 | + hash1.should == {'one' => { 'two' => [1,2, {'two' => 2}] } } |
| 100 | + hash2.should == { 'one' => { 'three' => 3 } } |
| 101 | + hash['one'].should == { 'two' => [1,2, {'two' => 2} ], 'three' => 3 } |
| 102 | + hash['one']['two'].should == [1,2, {'two' => 2}] |
| 103 | + end |
76 | 104 | end |
77 | 105 | end |
0 commit comments