source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/delete_undef_values_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1require 'spec_helper'
2
3describe '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) }
9
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
13 before 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
16 end
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 end
20
21 it "should leave the original argument intact" do
22 argument = ['one',undef_value,'two']
23 original = argument.dup
24 result = subject.call([argument,2])
25 expect(argument).to eq(original)
26 end
27 end
28
29 it { is_expected.to run.with_params(['undef']).and_return(['undef']) }
30 end
31
32 describe 'when deleting from a hash' do
33 [ :undef, '', nil ].each do |undef_value|
34 describe "when undef is represented by #{undef_value.inspect}" do
35 before do
36 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
37 pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
38 end
39 it { is_expected.to run.with_params({'key' => undef_value}).and_return({}) }
40 it { is_expected.to run \
41 .with_params({'key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2'}) \
42 .and_return({'key1' => 'value1', 'key2' => 'value2'})
43 }
44 end
45
46 it "should leave the original argument intact" do
47 argument = { 'key1' => 'value1', 'key2' => undef_value }
48 original = argument.dup
49 result = subject.call([argument,2])
50 expect(argument).to eq(original)
51 end
52 end
53
54 it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) }
55 end
56end
Note: See TracBrowser for help on using the repository browser.