summaryrefslogtreecommitdiff
path: root/spec/unit/property_spec.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-22 22:39:41 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-22 22:50:28 -0700
commit71fc5c5650f8bd3ec819087d6a5ca7f4eaeb1158 (patch)
tree226bda12feeb960b147177a5150d1efee731bbc0 /spec/unit/property_spec.rb
parentd8f7ca4d08f00db96fbf1e98a7f1ed763c7bab01 (diff)
downloadchef-71fc5c5650f8bd3ec819087d6a5ca7f4eaeb1158.tar.gz
Add deprecation warning for properties that specify default and name_propertyjk/default-ignoring
Diffstat (limited to 'spec/unit/property_spec.rb')
-rw-r--r--spec/unit/property_spec.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 533f0f4e4d..369c065aaa 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -946,14 +946,27 @@ describe "Chef::Resource.property" do
expect(resource.x).to eq 'blah'
end
end
- with_property ":x, default: 10, #{name}: true" do
- it "chooses default over #{name}" do
- expect(resource.x).to eq 10
+ 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./
+ 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./
end
end
- with_property ":x, #{name}: true, default: 10" do
- it "chooses #{name} over default" do
- expect(resource.x).to eq 'blah'
+ context "default ordering" do
+ before { Chef::Config[:treat_deprecation_warnings_as_errors] = false }
+ with_property ":x, default: 10, #{name}: true" do
+ it "chooses default over #{name}" do
+ expect(resource.x).to eq 10
+ end
+ end
+ with_property ":x, #{name}: true, default: 10" do
+ it "chooses #{name} over default" do
+ expect(resource.x).to eq 'blah'
+ end
end
end
with_property ":x, #{name}: true, required: true" do