diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-12-05 18:06:55 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-12-05 18:06:55 -0800 |
commit | 091001ae8d27a8a5de03af2c20905e23a8ffefb7 (patch) | |
tree | 28abfa5821f80e2090b8f89988a0bab004b710a5 /spec/unit/node/attribute_spec.rb | |
parent | 8a7b450cb87ef62e9f21d32c91a52accefba6ffd (diff) | |
parent | a45716b67a2168c21b166e4aab38668e9b96d856 (diff) | |
download | chef-merging-master.tar.gz |
Merge branch 'master' into merging-mastermerging-master
Conflicts:
lib/chef/version.rb
Diffstat (limited to 'spec/unit/node/attribute_spec.rb')
-rw-r--r-- | spec/unit/node/attribute_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 39e40a465f..c924ee2811 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -486,6 +486,34 @@ describe Chef::Node::Attribute do expect(hash.class).to eq(Hash) expect(hash["day"]).to eq("sunday") end + + it "should create a deep copy of the node attribute" do + @attributes.default['foo']['bar']['baz'] = 'fizz' + hash = @attributes['foo'].to_hash + expect(hash).to eql({"bar"=>{"baz"=>"fizz"}}) + hash['bar']['baz'] = 'buzz' + expect(hash).to eql({"bar"=>{"baz"=>"buzz"}}) + expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}}) + end + + it "should create a deep copy of arrays in the node attribute" do + @attributes.default['foo']['bar'] = ['fizz'] + hash = @attributes['foo'].to_hash + expect(hash).to eql({"bar"=>[ 'fizz' ]}) + hash['bar'].push('buzz') + expect(hash).to eql({"bar"=>[ 'fizz', 'buzz' ]}) + expect(@attributes.default['foo']).to eql({"bar"=>[ 'fizz' ]}) + end + + it "mutating strings should not mutate the attributes" do + pending "this is a bug that should be fixed" + @attributes.default['foo']['bar']['baz'] = 'fizz' + hash = @attributes['foo'].to_hash + expect(hash).to eql({"bar"=>{"baz"=>"fizz"}}) + hash['bar']['baz'] << 'buzz' + expect(hash).to eql({"bar"=>{"baz"=>"fizzbuzz"}}) + expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}}) + end end describe "dup" do |