diff options
author | danielsdeleo <dan@opscode.com> | 2012-10-19 14:50:11 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-10-19 16:00:15 -0700 |
commit | bf103e81ee679d6a24cab0b6c100e069abf4eb78 (patch) | |
tree | 253db91ee0679bf3e84c61c9554c862946ea141b /chef/spec/unit | |
parent | 3230ec8da18b8bca42c58d3effeaa7577e931880 (diff) | |
download | chef-bf103e81ee679d6a24cab0b6c100e069abf4eb78.tar.gz |
[CHEF-2737] add more tests for knockout detection
Diffstat (limited to 'chef/spec/unit')
-rw-r--r-- | chef/spec/unit/mixin/deep_merge_spec.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/chef/spec/unit/mixin/deep_merge_spec.rb b/chef/spec/unit/mixin/deep_merge_spec.rb index 2e759261c0..cbc9b1544f 100644 --- a/chef/spec/unit/mixin/deep_merge_spec.rb +++ b/chef/spec/unit/mixin/deep_merge_spec.rb @@ -287,10 +287,28 @@ describe Chef::Mixin::DeepMerge do end describe "role_merge" do - it "errors out if knockout merge use is detected" do + it "errors out if knockout merge use is detected in an array" do hash_dst = {"property" => ["2","4"]} hash_src = {"property" => ["1","!merge:4"]} lambda {@dm.role_merge(hash_dst, hash_src)}.should raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge) end + + it "errors out if knockout merge use is detected in an array (reversed merge order)" do + hash_dst = {"property" => ["1","!merge:4"]} + hash_src = {"property" => ["2","4"]} + lambda {@dm.role_merge(hash_dst, hash_src)}.should raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge) + end + + it "errors out if knockout merge use is detected in a string" do + hash_dst = {"property" => ["2","4"]} + hash_src = {"property" => "!merge"} + lambda {@dm.role_merge(hash_dst, hash_src)}.should raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge) + end + + it "errors out if knockout merge use is detected in a string (reversed merge order)" do + hash_dst = {"property" => "!merge"} + hash_src= {"property" => ["2","4"]} + lambda {@dm.role_merge(hash_dst, hash_src)}.should raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge) + end end end |