diff options
author | John Keiser <john@johnkeiser.com> | 2015-07-02 12:51:11 -0600 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-07-02 13:22:17 -0600 |
commit | ed2b0904361448173e5644dddacb48399fd8dc68 (patch) | |
tree | ab595538d6f4c339c144ccdacf9329d2e37d78f2 | |
parent | 21271c84ef78b1aac3b1708dbc9bf7c7a167b71d (diff) | |
download | chef-ed2b0904361448173e5644dddacb48399fd8dc68.tar.gz |
Make required name attributes workjk/required_name_attribute
-rw-r--r-- | lib/chef/mixin/params_validate.rb | 4 | ||||
-rw-r--r-- | spec/unit/property/validation_spec.rb | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb index f7d52a19cf..4ab016249f 100644 --- a/lib/chef/mixin/params_validate.rb +++ b/lib/chef/mixin/params_validate.rb @@ -130,9 +130,9 @@ class Chef # Get the default value else - _pv_required(opts, symbol, required, explicitly_allows_nil?(symbol, validation)) if required _pv_default(opts, symbol, default) unless default == NOT_PASSED _pv_name_property(opts, symbol, name_property) + _pv_required(opts, symbol, required, explicitly_allows_nil?(symbol, validation)) if required if opts.has_key?(symbol) # Handle lazy defaults. @@ -380,7 +380,7 @@ class Chef def _pv_name_property(opts, key, is_name_property=true) if is_name_property if opts[key].nil? - opts[key] = self.instance_variable_get("@name") + opts[key] = self.instance_variable_get(:"@name") end end end diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index e32147bd38..7ce6a45167 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -549,8 +549,8 @@ describe "Chef::Resource.property validation" do end with_property ':x, name_property: true, required: true' do - it "if x is not specified, retrieval fails" do - expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed + it "if x is not specified, retrieval succeeds" do + expect(resource.x).to eq 'blah' end it "value 1 is valid" do expect(resource.x 1).to eq 1 @@ -564,8 +564,8 @@ describe "Chef::Resource.property validation" do end with_property ':x, default: 10, required: true' do - it "if x is not specified, retrieval fails" do - expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed + it "if x is not specified, the default is returned" do + expect(resource.x).to eq 10 end it "value 1 is valid" do expect(resource.x 1).to eq 1 |