diff options
Diffstat (limited to 'spec/unit/property_spec.rb')
-rw-r--r-- | spec/unit/property_spec.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 095dcc8e98..4a90298b70 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -79,12 +79,18 @@ describe "Chef::Resource.property" do expect(resource.bare_property 10).to eq 10 expect(resource.bare_property).to eq 10 end - it "emits a deprecation warning and does a get, if set to nil" do - expect(resource.bare_property 10).to eq 10 - expect { resource.bare_property nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(resource.bare_property nil).to eq 10 - expect(resource.bare_property).to eq 10 + context "when it already has a value" do + before { resource.bare_property 10 } + it "emits a deprecation warning and does a get, if set to nil" do + expect { resource.bare_property nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError + Chef::Config[:treat_deprecation_warnings_as_errors] = false + expect(resource.bare_property nil).to eq 10 + expect(resource.bare_property).to eq 10 + end + end + it "does a get, if set to nil" do + expect(resource.bare_property nil).to be_nil + expect(resource.property_is_set?(:bare_property)).to be_falsey end it "can be updated" do expect(resource.bare_property 10).to eq 10 @@ -922,7 +928,7 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 1 end it "does not emit a deprecation warning if set to nil" do - expect(resource.x nil).to eq "1" + expect(resource.x nil).to eq nil end it "coercion sets the value (and coercion does not run on get)" do expect(resource.x 10).to eq "101" |