|
2 | 2 |
|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 |
| -describe 'mysql::deepmerge' do |
| 5 | +describe 'mysql::deepmerge' do |
6 | 6 | it 'exists' do
|
7 | 7 | is_expected.not_to eq(nil)
|
8 | 8 | end
|
|
12 | 12 | end
|
13 | 13 |
|
14 | 14 | it 'throws error with only one argument' do
|
15 |
| - is_expected.to run.with_params({ 'one' => 1 }).and_raise_error(Puppet::ParseError) |
| 15 | + is_expected.to run.with_params('one' => 1).and_raise_error(Puppet::ParseError) |
16 | 16 | end
|
17 | 17 |
|
18 | 18 | it 'accepts empty strings as puppet undef' do
|
|
22 | 22 | index_values = %w[one two three]
|
23 | 23 | expected_values_one = %w[1 2 2]
|
24 | 24 | it 'is able to mysql_deepmerge two hashes' do
|
25 |
| - new_hash = subject.execute({ 'one' => '1', 'two' => '1' }, { 'two' => '2', 'three' => '2' }) |
| 25 | + new_hash = subject.execute({ 'one' => '1', 'two' => '1' }, 'two' => '2', 'three' => '2') |
26 | 26 | index_values.each_with_index do |index, expected|
|
27 | 27 | expect(new_hash[index]).to eq(expected_values_one[expected])
|
28 | 28 | end
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | it 'mysql_deepmerges multiple hashes' do
|
32 |
| - hash = subject.execute({ 'one' => 1 }, { 'one' => '2' }, { 'one' => '3' }) |
| 32 | + hash = subject.execute({ 'one' => 1 }, { 'one' => '2' }, 'one' => '3') |
33 | 33 | expect(hash['one']).to eq('3')
|
34 | 34 | end
|
35 | 35 |
|
|
39 | 39 |
|
40 | 40 | expected_values_two = [1, 2, 'four' => 4]
|
41 | 41 | it 'mysql_deepmerges subhashes' do
|
42 |
| - hash = subject.execute({ 'one' => 1 }, { 'two' => 2, 'three' => { 'four' => 4 } }) |
| 42 | + hash = subject.execute({ 'one' => 1 }, 'two' => 2, 'three' => { 'four' => 4 }) |
43 | 43 | index_values.each_with_index do |index, expected|
|
44 | 44 | expect(hash[index]).to eq(expected_values_two[expected])
|
45 | 45 | end
|
46 | 46 | end
|
47 | 47 |
|
48 | 48 | it 'appends to subhashes' do
|
49 |
| - hash = subject.execute({ 'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }) |
| 49 | + hash = subject.execute({ 'one' => { 'two' => 2 } }, 'one' => { 'three' => 3 }) |
50 | 50 | expect(hash['one']).to eq('two' => 2, 'three' => 3)
|
51 | 51 | end
|
52 | 52 |
|
53 | 53 | expected_values_three = [1, 'dos', { 'four' => 4, 'five' => 5 }]
|
54 | 54 | it 'appends to subhashes 2' do
|
55 |
| - hash = subject.execute({ 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, { 'two' => 'dos', 'three' => { 'five' => 5 } }) |
| 55 | + hash = subject.execute({ 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, 'two' => 'dos', 'three' => { 'five' => 5 }) |
56 | 56 | index_values.each_with_index do |index, expected|
|
57 | 57 | expect(hash[index]).to eq(expected_values_three[expected])
|
58 | 58 | end
|
|
61 | 61 | index_values_two = %w[key1 key2]
|
62 | 62 | expected_values_four = [{ 'a' => 1, 'b' => 99 }, 'c' => 3]
|
63 | 63 | it 'appends to subhashes 3' do
|
64 |
| - hash = subject.execute({ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }) |
| 64 | + hash = subject.execute({ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, 'key1' => { 'b' => 99 }) |
65 | 65 | index_values_two.each_with_index do |index, expected|
|
66 | 66 | expect(hash[index]).to eq(expected_values_four[expected])
|
67 | 67 | end
|
68 | 68 | end
|
69 | 69 |
|
70 | 70 | it 'equates keys mod dash and underscore #value' do
|
71 |
| - hash = subject.execute({ 'a-b-c' => 1 }, { 'a_b_c' => 10 }) |
| 71 | + hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10) |
72 | 72 | expect(hash['a_b_c']).to eq(10)
|
73 | 73 | end
|
74 | 74 | it 'equates keys mod dash and underscore #not' do
|
75 |
| - hash = subject.execute({ 'a-b-c' => 1 }, { 'a_b_c' => 10 }) |
| 75 | + hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10) |
76 | 76 | expect(hash).not_to have_key('a-b-c')
|
77 | 77 | end
|
78 | 78 |
|
|
81 | 81 | index_values_error = ['a-b-c', 'b_c_d']
|
82 | 82 | index_values_three.each_with_index do |index, expected|
|
83 | 83 | it 'keeps style of the last when keys are equal mod dash and underscore #value' do
|
84 |
| - hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, { 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } }) |
| 84 | + hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 }) |
85 | 85 | expect(hash[index]).to eq(expected_values_five[expected])
|
86 | 86 | end
|
87 | 87 | it 'keeps style of the last when keys are equal mod dash and underscore #not' do
|
88 |
| - hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, { 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } }) |
| 88 | + hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 }) |
89 | 89 | expect(hash).not_to have_key(index_values_error[expected])
|
90 | 90 | end
|
91 | 91 | end
|
|
0 commit comments