1 | require 'spec_helper'
|
---|
2 |
|
---|
3 | describe 'delete_values' do
|
---|
4 | it { is_expected.not_to eq(nil) }
|
---|
5 | it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
|
---|
6 | it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
|
---|
7 | it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
|
---|
8 | it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
|
---|
9 | describe 'when the first argument is not a hash' do
|
---|
10 | it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
|
---|
11 | it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError) }
|
---|
12 | it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError) }
|
---|
13 | end
|
---|
14 |
|
---|
15 | describe 'when deleting from a hash' do
|
---|
16 | it { is_expected.to run.with_params({}, 'value').and_return({}) }
|
---|
17 | it { is_expected.to run \
|
---|
18 | .with_params({'key1' => 'value1'}, 'non-existing value') \
|
---|
19 | .and_return({'key1' => 'value1'})
|
---|
20 | }
|
---|
21 | it { is_expected.to run \
|
---|
22 | .with_params({'key1' => 'value1', 'key2' => 'value to delete'}, 'value to delete') \
|
---|
23 | .and_return({'key1' => 'value1'})
|
---|
24 | }
|
---|
25 | it { is_expected.to run \
|
---|
26 | .with_params({'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \
|
---|
27 | .and_return({'key1' => 'value1'})
|
---|
28 | }
|
---|
29 | end
|
---|
30 |
|
---|
31 | it "should leave the original argument intact" do
|
---|
32 | argument = { 'key1' => 'value1', 'key2' => 'value2' }
|
---|
33 | original = argument.dup
|
---|
34 | result = subject.call([argument, 'value2'])
|
---|
35 | expect(argument).to eq(original)
|
---|
36 | end
|
---|
37 | end
|
---|