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) }
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'})
21 it { is_expected.to run \
22 .with_params({'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete'}, 'value to delete') \
23 .and_return({'ҝếỵ1 ' => 'νâĺūẹ1'})
25 it { is_expected.to run \
26 .with_params({'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė'}, 'νǎŀữ℮ ťớ đêłểťė') \
27 .and_return({'key1' => 'value1'})
29 it { is_expected.to run \
30 .with_params({'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \
31 .and_return({'key1' => 'value1'})
35 it "should leave the original argument intact" do
36 argument = { 'key1' => 'value1', 'key2' => 'value2' }
37 original = argument.dup
38 result = subject.call([argument, 'value2'])
39 expect(argument).to eq(original)