diff options
author | danielsdeleo <dan@opscode.com> | 2012-10-04 11:53:54 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-10-04 11:53:54 -0700 |
commit | 8b40dd6c037c35c01ecf31b8a37c9cfd7d81a398 (patch) | |
tree | ad8e28162947b90da282b1fcefe0faa9f38519be | |
parent | 1c978db9dd37ad9474d6392e35ce1713efe8664f (diff) | |
download | chef-8b40dd6c037c35c01ecf31b8a37c9cfd7d81a398.tar.gz |
[CHEF-3197] raise NoMethodError for unknown attrsCHEF-3197
Previously ArgumentError was raised, and did not indicate that
incorrect method call could be the issue.
-rw-r--r-- | chef/lib/chef/node/attribute.rb | 2 | ||||
-rw-r--r-- | 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 |