summaryrefslogtreecommitdiff
path: root/spec/unit/property_spec.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-25 13:10:58 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-25 13:10:58 -0700
commit2c083878547343a4ed423e7d20ecbf6059285721 (patch)
tree25edb7f8a7c1a2f5cad9a6640f67832acf48bc74 /spec/unit/property_spec.rb
parentff54a6dd7ef781f242f1ab5b513f90a76902f5b8 (diff)
downloadchef-2c083878547343a4ed423e7d20ecbf6059285721.tar.gz
If both name_attribute and name_property are specified, raise an error.jk/property-default-nil
Diffstat (limited to 'spec/unit/property_spec.rb')
-rw-r--r--spec/unit/property_spec.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index de8d493026..64638d9be9 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -962,19 +962,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 one \(default\) will be obeyed./
+ /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). 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./
+ /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) 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 one \(#{name}\) will be obeyed./
+ /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) 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./
+ /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) will be obeyed./
end
end
@@ -1028,11 +1028,11 @@ describe "Chef::Resource.property" do
end
end
- with_property ":x, #{name}: true, required: true" do
- it "defaults x to resource.name" do
- expect(resource.x).to eq 'blah'
- end
- end
end
end
+
+ it "raises an error if both name_property and name_attribute are specified (even if they are false or nil)" do
+ expect { resource_class.property :x, :name_property => false, :name_attribute => true }.to raise_error ArgumentError,
+ /Cannot specify both name_property and name_attribute together on property x of resource chef_resource_property_spec_(\d+)./
+ end
end