summaryrefslogtreecommitdiff
path: root/spec/unit/recipe_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-04-18 11:48:11 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-11-16 10:37:04 -0800
commitf0f89d3e3330bfa084d5d6b6d1b95fc72120e582 (patch)
treed8b9c14557f48be4f41232ef84e9ee589d732b50 /spec/unit/recipe_spec.rb
parenta17be0f1c1d073f0619328d6a0971bbebf845e6a (diff)
downloadchef-f0f89d3e3330bfa084d5d6b6d1b95fc72120e582.tar.gz
add global and per-resource toggles for resource cloning behavior
let us turn on and off resource cloning
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r--spec/unit/recipe_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index eea1a41998..e1e3e0ad72 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -193,6 +193,38 @@ describe Chef::Recipe do
end
end
+ describe "when resource cloning is disabled" do
+ def not_expect_warning
+ expect(Chef::Log).not_to receive(:warn).with(/3694/)
+ expect(Chef::Log).not_to receive(:warn).with(/Previous/)
+ expect(Chef::Log).not_to receive(:warn).with(/Current/)
+ end
+
+ before do
+ Chef::Config[:resource_cloning] = false
+ end
+
+ it "should emit a 3694 warning when attributes change" do
+ recipe.zen_master "klopp" do
+ something "bvb"
+ end
+ not_expect_warning
+ recipe.zen_master "klopp" do
+ something "vbv"
+ end
+ end
+
+ it "should not copy attributes from a prior resource" do
+ recipe.zen_master "klopp" do
+ something "bvb"
+ end
+ not_expect_warning
+ recipe.zen_master "klopp"
+ expect(run_context.resource_collection.first.something).to eql("bvb")
+ expect(run_context.resource_collection[1].something).to be nil
+ end
+ end
+
describe "when cloning resources" do
def expect_warning
expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/)