summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/parser/functions')
-rw-r--r--spec/unit/puppet/parser/functions/deep_merge_spec.rb30
-rw-r--r--spec/unit/puppet/parser/functions/merge_spec.rb2
-rw-r--r--spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb4
3 files changed, 32 insertions, 4 deletions
diff --git a/spec/unit/puppet/parser/functions/deep_merge_spec.rb b/spec/unit/puppet/parser/functions/deep_merge_spec.rb
index fffb7f7..f134701 100644
--- a/spec/unit/puppet/parser/functions/deep_merge_spec.rb
+++ b/spec/unit/puppet/parser/functions/deep_merge_spec.rb
@@ -30,7 +30,7 @@ describe Puppet::Parser::Functions.function(:deep_merge) do
end
it 'should accept empty strings as puppet undef' do
- expect { new_hash = scope.function_deep_merge([{}, ''])}.not_to raise_error(Puppet::ParseError, /unexpected argument type String/)
+ expect { new_hash = scope.function_deep_merge([{}, ''])}.not_to raise_error
end
it 'should be able to deep_merge two hashes' do
@@ -73,5 +73,33 @@ describe Puppet::Parser::Functions.function(:deep_merge) do
hash['key1'].should == { 'a' => 1, 'b' => 99 }
hash['key2'].should == { 'c' => 3 }
end
+
+ it 'should not change the original hashes' do
+ hash1 = {'one' => { 'two' => 2 } }
+ hash2 = { 'one' => { 'three' => 3 } }
+ hash = scope.function_deep_merge([hash1, hash2])
+ hash1.should == {'one' => { 'two' => 2 } }
+ hash2.should == { 'one' => { 'three' => 3 } }
+ hash['one'].should == { 'two' => 2, 'three' => 3 }
+ end
+
+ it 'should not change the original hashes 2' do
+ hash1 = {'one' => { 'two' => [1,2] } }
+ hash2 = { 'one' => { 'three' => 3 } }
+ hash = scope.function_deep_merge([hash1, hash2])
+ hash1.should == {'one' => { 'two' => [1,2] } }
+ hash2.should == { 'one' => { 'three' => 3 } }
+ hash['one'].should == { 'two' => [1,2], 'three' => 3 }
+ end
+
+ it 'should not change the original hashes 3' do
+ hash1 = {'one' => { 'two' => [1,2, {'two' => 2} ] } }
+ hash2 = { 'one' => { 'three' => 3 } }
+ hash = scope.function_deep_merge([hash1, hash2])
+ hash1.should == {'one' => { 'two' => [1,2, {'two' => 2}] } }
+ hash2.should == { 'one' => { 'three' => 3 } }
+ hash['one'].should == { 'two' => [1,2, {'two' => 2} ], 'three' => 3 }
+ hash['one']['two'].should == [1,2, {'two' => 2}]
+ end
end
end
diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb
index 8a170bb..15a5d94 100644
--- a/spec/unit/puppet/parser/functions/merge_spec.rb
+++ b/spec/unit/puppet/parser/functions/merge_spec.rb
@@ -30,7 +30,7 @@ describe Puppet::Parser::Functions.function(:merge) do
end
it 'should accept empty strings as puppet undef' do
- expect { new_hash = scope.function_merge([{}, ''])}.not_to raise_error(Puppet::ParseError, /unexpected argument type String/)
+ expect { new_hash = scope.function_merge([{}, ''])}.not_to raise_error
end
it 'should be able to merge two hashes' do
diff --git a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb
index 08aaf78..1c9cce2 100644
--- a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb
+++ b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb
@@ -35,7 +35,7 @@ describe Puppet::Parser::Functions.function(:validate_absolute_path) do
end
valid_paths.each do |path|
it "validate_absolute_path(#{path.inspect}) should not fail" do
- expect { subject.call [path] }.not_to raise_error Puppet::ParseError
+ expect { subject.call [path] }.not_to raise_error
end
end
end
@@ -43,7 +43,7 @@ describe Puppet::Parser::Functions.function(:validate_absolute_path) do
context "Puppet without mocking" do
valid_paths.each do |path|
it "validate_absolute_path(#{path.inspect}) should not fail" do
- expect { subject.call [path] }.not_to raise_error Puppet::ParseError
+ expect { subject.call [path] }.not_to raise_error
end
end
end