|
7 | 7 |
|
8 | 8 | describe 'when calling deep_merge from puppet' do |
9 | 9 | it "should not compile when no arguments are passed" do |
10 | | - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ |
| 10 | + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ |
11 | 11 | Puppet[:code] = '$x = deep_merge()' |
12 | 12 | expect { |
13 | 13 | scope.compiler.compile |
14 | 14 | }.to raise_error(Puppet::ParseError, /wrong number of arguments/) |
15 | 15 | end |
16 | 16 |
|
17 | 17 | it "should not compile when 1 argument is passed" do |
18 | | - pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ |
| 18 | + skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ |
19 | 19 | Puppet[:code] = "$my_hash={'one' => 1}\n$x = deep_merge($my_hash)" |
20 | 20 | expect { |
21 | 21 | scope.compiler.compile |
|
35 | 35 |
|
36 | 36 | it 'should be able to deep_merge two hashes' do |
37 | 37 | new_hash = scope.function_deep_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}]) |
38 | | - new_hash['one'].should == '1' |
39 | | - new_hash['two'].should == '2' |
40 | | - new_hash['three'].should == '2' |
| 38 | + expect(new_hash['one']).to eq('1') |
| 39 | + expect(new_hash['two']).to eq('2') |
| 40 | + expect(new_hash['three']).to eq('2') |
41 | 41 | end |
42 | 42 |
|
43 | 43 | it 'should deep_merge multiple hashes' do |
44 | 44 | hash = scope.function_deep_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}]) |
45 | | - hash['one'].should == '3' |
| 45 | + expect(hash['one']).to eq('3') |
46 | 46 | end |
47 | 47 |
|
48 | 48 | it 'should accept empty hashes' do |
49 | | - scope.function_deep_merge([{},{},{}]).should == {} |
| 49 | + expect(scope.function_deep_merge([{},{},{}])).to eq({}) |
50 | 50 | end |
51 | 51 |
|
52 | 52 | it 'should deep_merge subhashes' do |
53 | 53 | hash = scope.function_deep_merge([{'one' => 1}, {'two' => 2, 'three' => { 'four' => 4 } }]) |
54 | | - hash['one'].should == 1 |
55 | | - hash['two'].should == 2 |
56 | | - hash['three'].should == { 'four' => 4 } |
| 54 | + expect(hash['one']).to eq(1) |
| 55 | + expect(hash['two']).to eq(2) |
| 56 | + expect(hash['three']).to eq({ 'four' => 4 }) |
57 | 57 | end |
58 | 58 |
|
59 | 59 | it 'should append to subhashes' do |
60 | 60 | hash = scope.function_deep_merge([{'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }]) |
61 | | - hash['one'].should == { 'two' => 2, 'three' => 3 } |
| 61 | + expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 }) |
62 | 62 | end |
63 | 63 |
|
64 | 64 | it 'should append to subhashes 2' do |
65 | 65 | hash = scope.function_deep_merge([{'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, {'two' => 'dos', 'three' => { 'five' => 5 } }]) |
66 | | - hash['one'].should == 1 |
67 | | - hash['two'].should == 'dos' |
68 | | - hash['three'].should == { 'four' => 4, 'five' => 5 } |
| 66 | + expect(hash['one']).to eq(1) |
| 67 | + expect(hash['two']).to eq('dos') |
| 68 | + expect(hash['three']).to eq({ 'four' => 4, 'five' => 5 }) |
69 | 69 | end |
70 | 70 |
|
71 | 71 | it 'should append to subhashes 3' do |
72 | 72 | hash = scope.function_deep_merge([{ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }]) |
73 | | - hash['key1'].should == { 'a' => 1, 'b' => 99 } |
74 | | - hash['key2'].should == { 'c' => 3 } |
| 73 | + expect(hash['key1']).to eq({ 'a' => 1, 'b' => 99 }) |
| 74 | + expect(hash['key2']).to eq({ 'c' => 3 }) |
75 | 75 | end |
76 | 76 |
|
77 | 77 | it 'should not change the original hashes' do |
78 | 78 | hash1 = {'one' => { 'two' => 2 } } |
79 | 79 | hash2 = { 'one' => { 'three' => 3 } } |
80 | 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 } |
| 81 | + expect(hash1).to eq({'one' => { 'two' => 2 } }) |
| 82 | + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) |
| 83 | + expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 }) |
84 | 84 | end |
85 | 85 |
|
86 | 86 | it 'should not change the original hashes 2' do |
87 | 87 | hash1 = {'one' => { 'two' => [1,2] } } |
88 | 88 | hash2 = { 'one' => { 'three' => 3 } } |
89 | 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 } |
| 90 | + expect(hash1).to eq({'one' => { 'two' => [1,2] } }) |
| 91 | + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) |
| 92 | + expect(hash['one']).to eq({ 'two' => [1,2], 'three' => 3 }) |
93 | 93 | end |
94 | 94 |
|
95 | 95 | it 'should not change the original hashes 3' do |
96 | 96 | hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } } |
97 | 97 | hash2 = { 'one' => { 'three' => 3 } } |
98 | 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}] |
| 99 | + expect(hash1).to eq({'one' => { 'two' => [1,2, {'two' => 2}] } }) |
| 100 | + expect(hash2).to eq({ 'one' => { 'three' => 3 } }) |
| 101 | + expect(hash['one']).to eq({ 'two' => [1,2, {'two' => 2} ], 'three' => 3 }) |
| 102 | + expect(hash['one']['two']).to eq([1,2, {'two' => 2}]) |
103 | 103 | end |
104 | 104 | end |
105 | 105 | end |
0 commit comments