diff options
Diffstat (limited to 'spec/unit/property_spec.rb')
-rw-r--r-- | spec/unit/property_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 6415286397..de8d493026 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -946,6 +946,19 @@ describe "Chef::Resource.property" do expect(resource.x).to eq 'blah' end end + + with_property ":x, #{name}: false" do + it "defaults to nil" do + expect(resource.x).to be_nil + end + end + + with_property ":x, #{name}: nil" do + it "defaults to nil" do + expect(resource.x).to be_nil + end + end + context "default ordering deprecation warnings" do it "emits a deprecation warning for property :x, default: 10, #{name}: true" do expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error Chef::Exceptions::DeprecatedFeatureError, @@ -964,6 +977,7 @@ describe "Chef::Resource.property" do /Cannot specify keys #{name}, default together on property x. Only one \(#{name}\) will be obeyed./ end end + context "default ordering" do before { Chef::Config[:treat_deprecation_warnings_as_errors] = false } with_property ":x, default: 10, #{name}: true" do @@ -987,6 +1001,33 @@ describe "Chef::Resource.property" do end end end + + context "default ordering when #{name} is nil" do + with_property ":x, #{name}: nil, default: 10" do + it "chooses default" do + expect(resource.x).to eq 10 + end + end + with_property ":x, default: 10, #{name}: nil" do + it "chooses default" do + expect(resource.x).to eq 10 + end + end + end + + context "default ordering when #{name} is false" do + with_property ":x, #{name}: false, default: 10" do + it "chooses default" do + expect(resource.x).to eq 10 + end + end + with_property ":x, default: 10, #{name}: nil" do + it "chooses default" do + expect(resource.x).to eq 10 + end + end + end + with_property ":x, #{name}: true, required: true" do it "defaults x to resource.name" do expect(resource.x).to eq 'blah' |