diff options
author | John Keiser <john@johnkeiser.com> | 2015-07-02 12:51:11 -0600 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-07-03 13:10:23 -0600 |
commit | 28f17b36a9d041be8ed50e20ae06fa5f5ea1fb38 (patch) | |
tree | 51bcd8fff1bcde908066f240f29a7f082fd08365 /spec/unit/property/validation_spec.rb | |
parent | ed2b0904361448173e5644dddacb48399fd8dc68 (diff) | |
download | chef-28f17b36a9d041be8ed50e20ae06fa5f5ea1fb38.tar.gz |
Make required name attributes work
Diffstat (limited to 'spec/unit/property/validation_spec.rb')
-rw-r--r-- | spec/unit/property/validation_spec.rb | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index 7ce6a45167..35363b0569 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -111,10 +111,6 @@ describe "Chef::Resource.property validation" do it "get succeeds" do expect(resource.x).to eq 'default' end - it "set(nil) = get" do - expect(resource.x nil).to eq 'default' - expect(resource.x).to eq 'default' - end it "set to valid value succeeds" do expect(resource.x 'str').to eq 'str' expect(resource.x).to eq 'str' @@ -122,15 +118,18 @@ 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' + end end context "when the variable does not have an initial value" do it "get succeeds" do expect(resource.x).to be_nil end - it "set(nil) = get" do - expect(resource.x nil).to be_nil - expect(resource.x).to be_nil - end it "set to valid value succeeds" do expect(resource.x 'str').to eq 'str' expect(resource.x).to eq 'str' @@ -138,6 +137,13 @@ 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' + end end end with_property ":x, [ String, nil ]" do @@ -255,10 +261,10 @@ describe "Chef::Resource.property validation" do [ '', 'abac' ], [ nil ] - # PropertyType - # validation_test 'is: PropertyType.new(is: :a)', - # [ :a ], - # [ :b, nil ] + # Property + validation_test 'is: Chef::Property.new(is: :a)', + [ :a ], + [ :b, nil ] # RSpec Matcher class Globalses @@ -523,10 +529,11 @@ describe "Chef::Resource.property validation" do expect(resource.x 1).to eq 1 expect(resource.x).to eq 1 end - it "value nil does a get" do + 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 - resource.x nil + expect(resource.x nil).to eq 1 expect(resource.x).to eq 1 end end @@ -556,9 +563,11 @@ describe "Chef::Resource.property validation" do expect(resource.x 1).to eq 1 expect(resource.x).to eq 1 end - it "value nil does a get" do + 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 - resource.x nil + expect(resource.x nil).to eq 1 expect(resource.x).to eq 1 end end @@ -571,10 +580,9 @@ describe "Chef::Resource.property validation" do expect(resource.x 1).to eq 1 expect(resource.x).to eq 1 end - it "value nil does a get" do - resource.x 1 - resource.x nil - expect(resource.x).to eq 1 + it "value nil is invalid" do + Chef::Config[:treat_deprecation_warnings_as_errors] = false + expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed end end end @@ -596,11 +604,6 @@ describe "Chef::Resource.property validation" do end end - # it "getting the value causes a deprecation warning" do - # Chef::Config[:treat_deprecation_warnings_as_errors] = true - # expect { resource.x }.to raise_error Chef::Exceptions::DeprecatedFeatureError - # end - it "value 1 is valid" do expect(resource.x 1).to eq 1 expect(resource.x).to eq 1 |