summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-24 18:19:33 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-25 12:22:19 -0700
commitc576de210dc42889d796074187a109a8d0dd6a19 (patch)
treecda149d242980851a5334249d2095fa801e22d41 /spec
parente84d5f2f697c51de82b0b83e0892c8d869ae6227 (diff)
downloadchef-c576de210dc42889d796074187a109a8d0dd6a19.tar.gz
Prefer name_property: true over default: nil
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/property_spec.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 369c065aaa..ebf94c1dd0 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -949,11 +949,19 @@ describe "Chef::Resource.property" do
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,
- /Cannot specify keys default, #{name} together on property x--only the first one \(default\) will be obeyed. Please pick one./
+ /Cannot specify keys default, #{name} together on property x--only one \(default\) will be obeyed./
+ end
+ it "emits a deprecation warning for property :x, default: nil, #{name}: true" do
+ expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
+ /Cannot specify keys default, #{name} together on property x--only one \(#{name}\) will be obeyed./
end
it "emits a deprecation warning for property :x, #{name}: true, default: 10" do
expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Cannot specify keys #{name}, default together on property x--only the first one \(#{name}\) will be obeyed. Please pick one./
+ /Cannot specify keys #{name}, default together on property x--only one \(#{name}\) will be obeyed./
+ end
+ it "emits a deprecation warning for property :x, #{name}: true, default: nil" do
+ expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
+ /Cannot specify keys #{name}, default together on property x--only one \(#{name}\) will be obeyed./
end
end
context "default ordering" do
@@ -963,11 +971,21 @@ describe "Chef::Resource.property" do
expect(resource.x).to eq 10
end
end
+ with_property ":x, default: nil, #{name}: true" do
+ it "chooses #{name} over default" do
+ expect(resource.x).to eq 'blah'
+ end
+ end
with_property ":x, #{name}: true, default: 10" do
it "chooses #{name} over default" do
expect(resource.x).to eq 'blah'
end
end
+ with_property ":x, #{name}: true, default: nil" do
+ it "chooses #{name} over default" do
+ expect(resource.x).to eq 'blah'
+ end
+ end
end
with_property ":x, #{name}: true, required: true" do
it "defaults x to resource.name" do