|
9 | 9 | end |
10 | 10 |
|
11 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do |
12 | | - expect { scope.function_delete([]) }.to( raise_error(Puppet::ParseError)) |
| 12 | + expect { scope.function_delete([]) }.to(raise_error(Puppet::ParseError)) |
13 | 13 | end |
14 | 14 |
|
15 | 15 | it "should raise a ParseError if there are greater than 2 arguments" do |
16 | | - expect { scope.function_delete([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError)) |
| 16 | + expect { scope.function_delete([[], 'foo', 'bar']) }.to(raise_error(Puppet::ParseError)) |
17 | 17 | end |
18 | 18 |
|
19 | 19 | it "should raise a TypeError if a number is passed as the first argument" do |
20 | | - expect { scope.function_delete([1, 'bar']) }.to( raise_error(TypeError)) |
| 20 | + expect { scope.function_delete([1, 'bar']) }.to(raise_error(TypeError)) |
21 | 21 | end |
22 | 22 |
|
23 | 23 | it "should delete all instances of an element from an array" do |
24 | | - result = scope.function_delete([['a','b','c','b'],'b']) |
25 | | - expect(result).to(eq(['a','c'])) |
| 24 | + result = scope.function_delete([['a', 'b', 'c', 'b'], 'b']) |
| 25 | + expect(result).to(eq(['a', 'c'])) |
26 | 26 | end |
27 | 27 |
|
28 | 28 | it "should delete all instances of a substring from a string" do |
29 | | - result = scope.function_delete(['foobarbabarz','bar']) |
| 29 | + result = scope.function_delete(['foobarbabarz', 'bar']) |
30 | 30 | expect(result).to(eq('foobaz')) |
31 | 31 | end |
32 | 32 |
|
33 | 33 | it "should delete a key from a hash" do |
34 | | - result = scope.function_delete([{ 'a' => 1, 'b' => 2, 'c' => 3 },'b']) |
35 | | - expect(result).to(eq({ 'a' => 1, 'c' => 3 })) |
| 34 | + result = scope.function_delete([{'a' => 1, 'b' => 2, 'c' => 3}, 'b']) |
| 35 | + expect(result).to(eq({'a' => 1, 'c' => 3})) |
| 36 | + end |
| 37 | + |
| 38 | + it 'should accept an array of items to delete' do |
| 39 | + result = scope.function_delete([{'a' => 1, 'b' => 2, 'c' => 3}, ['b', 'c']]) |
| 40 | + expect(result).to(eq({'a' => 1})) |
36 | 41 | end |
37 | 42 |
|
38 | 43 | it "should not change origin array passed as argument" do |
39 | | - origin_array = ['a','b','c','d'] |
| 44 | + origin_array = ['a', 'b', 'c', 'd'] |
40 | 45 | result = scope.function_delete([origin_array, 'b']) |
41 | | - expect(origin_array).to(eq(['a','b','c','d'])) |
| 46 | + expect(origin_array).to(eq(['a', 'b', 'c', 'd'])) |
42 | 47 | end |
43 | 48 |
|
44 | 49 | it "should not change the origin string passed as argument" do |
45 | 50 | origin_string = 'foobarbabarz' |
46 | | - result = scope.function_delete([origin_string,'bar']) |
| 51 | + result = scope.function_delete([origin_string, 'bar']) |
47 | 52 | expect(origin_string).to(eq('foobarbabarz')) |
48 | 53 | end |
49 | 54 |
|
50 | 55 | it "should not change origin hash passed as argument" do |
51 | | - origin_hash = { 'a' => 1, 'b' => 2, 'c' => 3 } |
| 56 | + origin_hash = {'a' => 1, 'b' => 2, 'c' => 3} |
52 | 57 | result = scope.function_delete([origin_hash, 'b']) |
53 | | - expect(origin_hash).to(eq({ 'a' => 1, 'b' => 2, 'c' => 3 })) |
| 58 | + expect(origin_hash).to(eq({'a' => 1, 'b' => 2, 'c' => 3})) |
54 | 59 | end |
55 | 60 |
|
56 | 61 | end |
0 commit comments