3 describe 'delete_undef_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').and_raise_error(Puppet::ParseError) }
10 describe 'when deleting from an array' do
11 [ :undef, '', nil ].each do |undef_value|
12 describe "when undef is represented by #{undef_value.inspect}" do
14 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
15 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
17 it { is_expected.to run.with_params([undef_value]).and_return([]) }
18 it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) }
19 it { is_expected.to run.with_params(['ớņέ',undef_value,'ŧשּׁō','ŧħґëə']).and_return(['ớņέ','ŧשּׁō','ŧħґëə']) }
22 it "should leave the original argument intact" do
23 argument = ['one',undef_value,'two']
24 original = argument.dup
25 result = subject.call([argument,2])
26 expect(argument).to eq(original)
30 it { is_expected.to run.with_params(['undef']).and_return(['undef']) }
33 describe 'when deleting from a hash' do
34 [ :undef, '', nil ].each do |undef_value|
35 describe "when undef is represented by #{undef_value.inspect}" do
37 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
38 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
40 it { is_expected.to run.with_params({'key' => undef_value}).and_return({}) }
41 it { is_expected.to run \
42 .with_params({'key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2'}) \
43 .and_return({'key1' => 'value1', 'key2' => 'value2'})
47 it "should leave the original argument intact" do
48 argument = { 'key1' => 'value1', 'key2' => undef_value }
49 original = argument.dup
50 result = subject.call([argument,2])
51 expect(argument).to eq(original)
55 it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) }