summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/unit/node_spec.rb28
-rw-r--r--spec/unit/provider/deploy_spec.rb2
3 files changed, 31 insertions, 3 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 47a5ec7f9f..7559e797bc 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -174,13 +174,13 @@ RSpec.configure do |config|
running_platform_arch = `uname -m`.strip unless windows?
- config.filter_run_excluding :arch => lambda {|target_arch|
+ config.filter_run_excluding :arch => lambda { |target_arch|
running_platform_arch != target_arch
}
# Functional Resource tests that are provider-specific:
# context "on platforms that use useradd", :provider => {:user => Chef::Provider::User::Useradd}} do #...
- config.filter_run_excluding :provider => lambda {|criteria|
+ config.filter_run_excluding :provider => lambda { |criteria|
type, target_provider = criteria.first
node = TEST_NODE.dup
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"
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index e69714280c..b30ddb736a 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -556,7 +556,7 @@ describe Chef::Provider::Deploy do
@resource.deploy_to("/my/app")
expect(mock_execution).to receive(:user).with("notCoolMan")
expect(mock_execution).to receive(:group).with("Ggroup")
- expect(mock_execution).to receive(:cwd) {|*args|
+ expect(mock_execution).to receive(:cwd) { |*args|
if args.empty?
nil
else