summaryrefslogtreecommitdiff
path: root/spec/unit/node/attribute_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/node/attribute_spec.rb')
-rw-r--r--spec/unit/node/attribute_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 0869b83e43..3dd0d0f650 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -1244,4 +1244,16 @@ describe Chef::Node::Attribute do
@attributes.default["foo"]["bar"]["baz"] = "quux"
end
end
+
+ describe "frozen immutable strings" do
+ it "strings in hashes should be frozen" do
+ @attributes.default["foo"]["bar"]["baz"] = "fizz"
+ expect { @attributes["foo"]["bar"]["baz"] << "buzz" }.to raise_error(RuntimeError, "can't modify frozen String")
+ end
+
+ it "strings in arrays should be frozen" do
+ @attributes.default["foo"]["bar"] = [ "fizz" ]
+ expect { @attributes["foo"]["bar"][0] << "buzz" }.to raise_error(RuntimeError, "can't modify frozen String")
+ end
+ end
end