summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-29 20:37:39 -0800
committerTim Smith <tsmith@chef.io>2017-12-29 20:46:31 -0800
commit601c2cabf9cd3101c624e86602a52df58d7b5d11 (patch)
tree5da749fafa256e46a659a4c841979d58c78ffe93 /spec/unit
parentbfe8487a26f99d3cd3e08fffea8cf6457631cf69 (diff)
downloadchef-601c2cabf9cd3101c624e86602a52df58d7b5d11.tar.gz
Improve property warnings in resourcesbetter_resource_errors
Give more details on why people are seeing these problems so they can fix them. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/property_spec.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index b8cf7f5d1b..996585ab98 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -93,7 +93,7 @@ describe "Chef::Resource.property" do
expect(resource.bare_property).to eq 20
end
it "can be set with =" do
- expect(resource.bare_property 10).to eq 10
+ expect(resource.bare_property = 10).to eq 10
expect(resource.bare_property).to eq 10
end
it "can be set to nil with =" do
@@ -1037,20 +1037,20 @@ describe "Chef::Resource.property" do
context "default ordering deprecation warnings" do
it "emits an error for property :x, default: 10, #{name}: true" do
- expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error Chef::Exceptions::ArgumentError,
- /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/
+ expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error ArgumentError,
+ /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
end
it "emits an error for property :x, default: nil, #{name}: true" do
- expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error Chef::Exceptions::ArgumentError,
- /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/
+ expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error ArgumentError,
+ /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
end
it "emits an error for property :x, #{name}: true, default: 10" do
- expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error Chef::Exceptions::ArgumentError,
- /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/
+ expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error ArgumentError,
+ /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
end
it "emits an error for property :x, #{name}: true, default: nil" do
- expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error Chef::Exceptions::ArgumentError,
- /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/
+ expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error ArgumentError,
+ /A property cannot be both a name_property\/name_attribute and have a default value. Use one or the other on property x of resource chef_resource_property_spec_(\d+)/
end
end
end
@@ -1058,13 +1058,13 @@ describe "Chef::Resource.property" do
it "raises an error if both name_property and name_attribute are specified" do
expect { resource_class.property :x, :name_property => false, :name_attribute => 1 }.to raise_error ArgumentError,
- /Cannot specify both name_property and name_attribute together on property x of resource chef_resource_property_spec_(\d+)./
+ /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
expect { resource_class.property :x, :name_property => false, :name_attribute => nil }.to raise_error ArgumentError,
- /Cannot specify both name_property and name_attribute together on property x of resource chef_resource_property_spec_(\d+)./
+ /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
expect { resource_class.property :x, :name_property => false, :name_attribute => false }.to raise_error ArgumentError,
- /Cannot specify both name_property and name_attribute together on property x of resource chef_resource_property_spec_(\d+)./
+ /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
expect { resource_class.property :x, :name_property => true, :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+)./
+ /name_attribute and name_property are functionally identical and both cannot be specified on a property at once. Use just one on property x of resource chef_resource_property_spec_(\d+)./
end
context "property_type" do