summaryrefslogtreecommitdiff
path: root/spec/integration/recipes
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-07-06 13:04:46 -0600
committerJohn Keiser <john@johnkeiser.com>2015-07-06 13:04:46 -0600
commit2408528f13ce5b47c18f0db4c6b6d3cf58d25c0a (patch)
tree9243002f6b6d294e4f1bb21a4bc714c9d577c1a1 /spec/integration/recipes
parentcb163f4b69e0378b9dc4c60b935b891e05706ccc (diff)
downloadchef-2408528f13ce5b47c18f0db4c6b6d3cf58d25c0a.tar.gz
Deprecate passing more than 1 argument to create a resourcejk/3634
Diffstat (limited to 'spec/integration/recipes')
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index 1ab01fb20e..a4de6ae542 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -19,6 +19,7 @@ describe "Recipe DSL methods" do
default_action :create
class<<self
+ attr_accessor :created_name
attr_accessor :created_resource
attr_accessor :created_provider
end
@@ -30,6 +31,7 @@ describe "Recipe DSL methods" do
def load_current_resource
end
def action_create
+ BaseThingy.created_name = new_resource.name
BaseThingy.created_resource = new_resource.class
BaseThingy.created_provider = self.class
end
@@ -52,6 +54,7 @@ describe "Recipe DSL methods" do
base_thingy 'blah' do; end
}
expect(recipe.logged_warnings).to eq ''
+ expect(BaseThingy.created_name).to eq 'blah'
expect(BaseThingy.created_resource).to eq BaseThingy
end
@@ -61,10 +64,15 @@ describe "Recipe DSL methods" do
}.to raise_error(ArgumentError, 'You must supply a name when declaring a base_thingy resource')
end
- it "errors out when you call base_thingy 'foo', 'bar' do ... end in a recipe" do
- expect_converge {
- base_thingy 'foo', 'bar' do; end
- }.to raise_error(ArgumentError, 'wrong number of arguments (2 for 0..1)')
+ it "emits a warning when you call base_thingy 'foo', 'bar' do ... end in a recipe" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ recipe = converge {
+ base_thingy 'foo', 'bar' do
+ end
+ }
+ expect(recipe.logged_warnings).to match(/Cannot create resource base_thingy with more than one argument. All arguments except the name \("foo"\) will be ignored. This will cause an error in Chef 13. Arguments: \["foo", "bar"\]/)
+ expect(BaseThingy.created_name).to eq 'foo'
+ expect(BaseThingy.created_resource).to eq BaseThingy
end
context "Deprecated automatic resource DSL" do