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({}) }
19 .with_params({ 'key1' => 'value1' }, 'non-existing value') \
20 .and_return('key1' => 'value1')
24 .with_params({ 'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete' }, 'value to delete') \
25 .and_return('ҝếỵ1 ' => 'νâĺūẹ1')
29 .with_params({ 'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė' }, 'νǎŀữ℮ ťớ đêłểťė') \
30 .and_return('key1' => 'value1')
34 .with_params({ 'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete' }, 'value to delete') \
35 .and_return('key1' => 'value1')
39 it 'leaves the original argument intact' do
40 argument = { 'key1' => 'value1', 'key2' => 'value2' }
41 original = argument.dup
42 _result = subject.execute(argument, 'value2')
43 expect(argument).to eq(original)