diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-10-20 15:36:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-20 15:36:33 -0700 |
commit | 7ce354488e526500283f18ab11f98574675b8128 (patch) | |
tree | 9299d402e30d7d3148961954a1342d48a086bb1a | |
parent | 5e907c90ed9bcfac69b6511fe0f521ae46bb76a5 (diff) | |
parent | def3b15f65ccfc3331429b53d9b5c0160ca4742f (diff) | |
download | chef-7ce354488e526500283f18ab11f98574675b8128.tar.gz |
Merge pull request #5481 from chef/lcg/node-tests
Attributes: add tests for regression in 12.0 fixed recently
-rw-r--r-- | spec/unit/node_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 2c8fc4408b..4feb236d46 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -243,6 +243,34 @@ describe Chef::Node do expect { node.sunshine = "is bright" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end + it "does not allow modification of node attributes via hash methods" do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + node.default["h4sh"] = { foo: "bar" } + expect { node["h4sh"].delete("foo") }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) + expect { node.h4sh.delete("foo") }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) + end + + it "does not allow modification of node attributes via array methods" do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + node.default["array"] = [] + expect { node["array"] << "boom" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) + expect { node.array << "boom" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) + end + + it "returns merged immutable attributes for arrays" do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + node.default["array"] = [] + expect( node["array"].class ).to eql(Chef::Node::ImmutableArray) + expect( node.array.class ).to eql(Chef::Node::ImmutableArray) + end + + it "returns merged immutable attributes for hashes" do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + node.default["h4sh"] = {} + expect( node["h4sh"].class ).to eql(Chef::Node::ImmutableMash) + expect( node.h4sh.class ).to eql(Chef::Node::ImmutableMash) + end + it "should allow you get get an attribute via method_missing" do Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default.sunshine = "is bright" |