diff options
author | Pierre Ynard <p.ynard@criteo.com> | 2014-01-10 10:32:06 +0100 |
---|---|---|
committer | Pierre Ynard <p.ynard@criteo.com> | 2014-01-10 10:32:06 +0100 |
commit | 68f99fc6c65cba739dad20f95df1c558ede66946 (patch) | |
tree | c33ac10372f0b7ce4816ace17b50c0b39a3c29ff /spec/unit/node | |
parent | cbbf8f8f2169945451da6fff76c75bd79da307e1 (diff) | |
download | chef-68f99fc6c65cba739dad20f95df1c558ede66946.tar.gz |
[CHEF-4799] Handle non-dupable elements when duping attribute arrays
Diffstat (limited to 'spec/unit/node')
-rw-r--r-- | spec/unit/node/attribute_spec.rb | 7 | ||||
-rw-r--r-- | spec/unit/node/immutable_collections_spec.rb | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 70905d334b..72afe20b97 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -488,6 +488,13 @@ describe Chef::Node::Attribute do end end + describe "dup" do + it "array can be duped even if some elements can't" do + @attributes.default[:foo] = %w[foo bar baz] + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ] + @attributes.default[:foo].dup + end + end + describe "has_key?" do it "should return true if an attribute exists" do @attributes.has_key?("music").should == true diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 0c2b878cd2..f30c1970f7 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -86,7 +86,7 @@ end describe Chef::Node::ImmutableArray do before do - @immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz]) + @immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz] + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ]) end ## @@ -130,6 +130,10 @@ describe Chef::Node::ImmutableArray do end end + it "can be duped even if some elements can't" do + @immutable_array.dup + end + it "returns a mutable version of itself when duped" do mutable = @immutable_array.dup mutable[0] = :value |