summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-11-19 11:23:26 -0800
committerSerdar Sutay <serdar@opscode.com>2014-11-19 15:42:31 -0800
commitb44006c690388d78de641fce80b6f819857d92b1 (patch)
treedd3eed6bf0bd929af4641d4ab4c59c3deccfb4b7
parent5ab8294a46b815edab432f5fdfa93e278732af38 (diff)
downloadchef-b44006c690388d78de641fce80b6f819857d92b1.tar.gz
add specs busted by dup removal
-rw-r--r--spec/unit/node/attribute_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 67a491595d..008fef4a3e 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -1128,6 +1128,40 @@ describe Chef::Node::Attribute do
end
end
+ describe "when deep-merging between precedence levels" do
+ it "correctly deep merges hashes and preserves the original contents" do
+ @attributes.default = { "arglebargle" => { "foo" => "bar" } }
+ @attributes.override = { "arglebargle" => { "fizz" => "buzz" } }
+ expect(@attributes.merged_attributes[:arglebargle]).to eq({ "foo" => "bar", "fizz" => "buzz" })
+ expect(@attributes.default[:arglebargle]).to eq({ "foo" => "bar" })
+ expect(@attributes.override[:arglebargle]).to eq({ "fizz" => "buzz" })
+ end
+
+ it "does not deep merge arrays, and preserves the original contents" do
+ @attributes.default = { "arglebargle" => [ 1, 2, 3 ] }
+ @attributes.override = { "arglebargle" => [ 4, 5, 6 ] }
+ expect(@attributes.merged_attributes[:arglebargle]).to eq([ 4, 5, 6 ])
+ expect(@attributes.default[:arglebargle]).to eq([ 1, 2, 3 ])
+ expect(@attributes.override[:arglebargle]).to eq([ 4, 5, 6 ])
+ end
+
+ it "correctly deep merges hashes and preserves the original contents when merging default and role_default" do
+ @attributes.default = { "arglebargle" => { "foo" => "bar" } }
+ @attributes.role_default = { "arglebargle" => { "fizz" => "buzz" } }
+ expect(@attributes.merged_attributes[:arglebargle]).to eq({ "foo" => "bar", "fizz" => "buzz" })
+ expect(@attributes.default[:arglebargle]).to eq({ "foo" => "bar" })
+ expect(@attributes.role_efault[:arglebargle]).to eq({ "fizz" => "buzz" })
+ end
+
+ it "correctly deep merges arrays, and preserves the original contents when merging default and role_default" do
+ @attributes.default = { "arglebargle" => [ 1, 2, 3 ] }
+ @attributes.role_default = { "arglebargle" => [ 4, 5, 6 ] }
+ expect(@attributes.merged_attributes[:arglebargle]).to eq([ 1, 2, 3, 4, 5, 6 ])
+ expect(@attributes.default[:arglebargle]).to eq([ 1, 2, 3 ])
+ expect(@attributes.role_default[:arglebargle]).to eq([ 4, 5, 6 ])
+ end
+ end
+
describe "when attemping to write without specifying precedence" do
it "raises an error when using []=" do
expect { @attributes[:new_key] = "new value" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)