From 34797a6f6353d7111043e9a0e814d7b30090c5e1 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 11 Jan 2017 14:09:59 -0800 Subject: fix node attribute "unless" API methods closes #5556 corrects behavior to 12.11.x behavior which was lost in the refactor may address #5715 Signed-off-by: Lamont Granquist --- spec/unit/node_spec.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'spec/unit') diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 59b4b8a1c7..ac227c5479 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -337,14 +337,35 @@ describe Chef::Node do Chef::Config[:treat_deprecation_warnings_as_errors] = false expect(Chef).to receive(:deprecated).with(:attributes, /set is deprecated/) node.set[:snoopy][:is_a_puppy] = true - expect(node[:snoopy][:is_a_puppy]).to eq(true) + expect(node.normal[:snoopy][:is_a_puppy]).to eq(true) end it "set_unless is a deprecated alias for normal_unless" do Chef::Config[:treat_deprecation_warnings_as_errors] = false expect(Chef).to receive(:deprecated).with(:attributes, /set_unless is deprecated/) node.set_unless[:snoopy][:is_a_puppy] = false - expect(node[:snoopy][:is_a_puppy]).to eq(false) + expect(node.normal[:snoopy][:is_a_puppy]).to eq(false) + end + + it "normal_unless sets a value even if default or override attrs are set" do + node.default[:decontamination] = true + node.override[:decontamination] = false + node.normal_unless[:decontamination] = "foo" + expect(node.normal[:decontamination]).to eql("foo") + end + + it "default_unless sets a value even if normal or override attrs are set" do + node.normal[:decontamination] = true + node.override[:decontamination] = false + node.default_unless[:decontamination] = "foo" + expect(node.default[:decontamination]).to eql("foo") + end + + it "override_unless sets a value even if default or normal attrs are set" do + node.default[:decontamination] = true + node.normal[:decontamination] = false + node.override_unless[:decontamination] = "foo" + expect(node.override[:decontamination]).to eql("foo") end end -- cgit v1.2.1