diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-21 09:42:49 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-21 09:42:49 -0700 |
commit | aa0a01d3da6f07d4a2f2cbf751e4ae47e217e306 (patch) | |
tree | a3ccb84827752866e49471661fc5823e6dd2e6f6 | |
parent | a65147034050361a8b2bf80a54a2532bf9f0413d (diff) | |
download | chef-aa0a01d3da6f07d4a2f2cbf751e4ae47e217e306.tar.gz |
fix error messages for method_missing removal
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/recipe.rb | 10 | ||||
-rw-r--r-- | spec/unit/recipe_spec.rb | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb index 77d82f83ab..967703b629 100644 --- a/lib/chef/recipe.rb +++ b/lib/chef/recipe.rb @@ -1,7 +1,7 @@ #-- # Author:: Adam Jacob (<adam@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -104,5 +104,13 @@ class Chef run_context.node.tags.delete(tag) end end + + def to_s + "cookbook: #{cookbook_name ? cookbook_name : "(none)"}, recipe: #{recipe_name ? recipe_name : "(none)"} " + end + + def inspect + to_s + end end end diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 8e00a82e59..cb500da34a 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -307,7 +307,7 @@ describe Chef::Recipe do it "gives a sane error message when using method_missing" do expect do recipe.no_such_resource("foo") - end.to raise_error(NoMethodError, /undefined method `no_such_resource' for #<Chef::Recipe:.*>/) + end.to raise_error(NoMethodError, /undefined method `no_such_resource' for cookbook: hjk, recipe: test :Chef::Recipe/) end it "gives a sane error message when using method_missing 'bare'" do @@ -316,7 +316,7 @@ describe Chef::Recipe do # Giving an argument will change this from NameError to NoMethodError no_such_resource end - end.to raise_error(NameError, /undefined local variable or method `no_such_resource' for #<Chef::Recipe:.*>/) + end.to raise_error(NameError, /undefined local variable or method `no_such_resource' for cookbook: hjk, recipe: test :Chef::Recipe/) end it "gives a sane error message when using build_resource" do |