diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-11 16:24:05 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-12-14 11:04:19 -0800 |
commit | b60ad97446c064c71e5e1b03b94344eb0b5c136d (patch) | |
tree | f1fb8408d148a855d41a83234a688b12c6c7cf90 /spec/unit | |
parent | f08d833465d9d2ea083d12a66958753afa2b1c7e (diff) | |
download | chef-b60ad97446c064c71e5e1b03b94344eb0b5c136d.tar.gz |
Don't warn when setting a property to nil unless its value wouldjk/updates2
actually change. Gets rid of cases where we are initializing a
resource with values from another resource.
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/property/validation_spec.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index 31bb3f0739..a54a38eb85 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -137,12 +137,8 @@ describe "Chef::Resource.property validation" do it "set to invalid value raises ValidationFailed" do expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed end - it "set to nil emits a deprecation warning and does a get" do - expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError - Chef::Config[:treat_deprecation_warnings_as_errors] = false - resource.x 'str' - expect(resource.x nil).to eq 'str' - expect(resource.x).to eq 'str' + it "set to nil emits no warning because the value would not change" do + expect(resource.x nil).to be_nil end end end @@ -534,12 +530,18 @@ describe "Chef::Resource.property validation" do expect(resource.x 1).to eq 1 expect(resource.x).to eq 1 end - it "value nil emits a deprecation warning and does a get" do - expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError - Chef::Config[:treat_deprecation_warnings_as_errors] = false - resource.x 1 - expect(resource.x nil).to eq 1 - expect(resource.x).to eq 1 + it "value nil emits a validation failed error because it must have a value" do + expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed + end + context "and value is set to something other than nil" do + before { resource.x 10 } + it "value nil emits a deprecation warning and does a get" do + expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError + Chef::Config[:treat_deprecation_warnings_as_errors] = false + resource.x 1 + expect(resource.x nil).to eq 1 + expect(resource.x).to eq 1 + end end end |