summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2014-02-07 11:20:09 -0800
committerdanielsdeleo <dan@opscode.com>2014-02-07 11:20:09 -0800
commit29e732d97ec7e28b2111aca9f93edfd1bc257c2d (patch)
treea05a3ec70af80f9ae06b1c2822257b1c9b10213b
parentcfca4a26fde79b209542930405026aef1a5a16bb (diff)
parenteeae85b44267c4147ed38f19ef8c4c5d30919198 (diff)
downloadchef-29e732d97ec7e28b2111aca9f93edfd1bc257c2d.tar.gz
Merge branch 'nomethod-gobbling'
Fixes https://tickets.opscode.com/browse/CHEF-5011
-rw-r--r--lib/chef/dsl/recipe.rb12
-rw-r--r--spec/unit/recipe_spec.rb13
2 files changed, 20 insertions, 5 deletions
diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb
index d8d0b158b3..a3b6a8cef0 100644
--- a/lib/chef/dsl/recipe.rb
+++ b/lib/chef/dsl/recipe.rb
@@ -55,12 +55,14 @@ class Chef
# Otherwise, we're rocking the regular resource call route.
declare_resource(method_symbol, args[0], caller[0], &block)
else
- super
+ begin
+ super
+ rescue NoMethodError
+ raise NoMethodError, "No resource or method named `#{method_symbol}' for #{describe_self_for_error}"
+ rescue NameError
+ raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_for_error}"
+ end
end
- rescue NoMethodError
- raise NoMethodError, "No resource or method named `#{method_symbol}' for #{describe_self_for_error}"
- rescue NameError
- raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_for_error}"
end
def has_resource_definition?(name)
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 612eae2b8e..6bea1457f9 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -202,6 +202,19 @@ describe Chef::Recipe do
end
+ describe "when creating a resource that contains an error in the attributes block" do
+
+ it "does not obfuscate the error source" do
+ lambda do
+ @recipe.zen_master("klopp") do
+ this_method_doesnt_exist
+ end
+ end.should raise_error(NoMethodError, "undefined method `this_method_doesnt_exist' for Chef::Resource::ZenMaster")
+
+ end
+
+ end
+
describe "resource definitions" do
it "should execute defined resources" do
crow_define = Chef::ResourceDefinition.new