From 8b40dd6c037c35c01ecf31b8a37c9cfd7d81a398 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Thu, 4 Oct 2012 11:53:54 -0700 Subject: [CHEF-3197] raise NoMethodError for unknown attrs Previously ArgumentError was raised, and did not indicate that incorrect method call could be the issue. --- chef/lib/chef/node/attribute.rb | 2 +- chef/spec/unit/node_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chef/lib/chef/node/attribute.rb b/chef/lib/chef/node/attribute.rb index ccd87a1d77..c4556bfeae 100644 --- a/chef/lib/chef/node/attribute.rb +++ b/chef/lib/chef/node/attribute.rb @@ -425,7 +425,7 @@ class Chef self[symbol] = Mash.new self[symbol] else - raise ArgumentError, "Attribute #{symbol} is not defined!" unless auto_vivifiy_on_read + raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'" end elsif symbol.to_s =~ /=$/ key_to_set = symbol.to_s[/^(.+)=$/, 1] || symbol diff --git a/chef/spec/unit/node_spec.rb b/chef/spec/unit/node_spec.rb index a7d44a2f62..77883bab62 100644 --- a/chef/spec/unit/node_spec.rb +++ b/chef/spec/unit/node_spec.rb @@ -249,7 +249,7 @@ describe Chef::Node do end it "should raise an ArgumentError if you ask for an attribute that doesn't exist via method_missing" do - lambda { @node.sunshine }.should raise_error(ArgumentError) + lambda { @node.sunshine }.should raise_error(NoMethodError) end it "should allow you to iterate over attributes with each_attribute" do -- cgit v1.2.1