diff options
author | tyler-ball <tyleraball@gmail.com> | 2015-02-11 18:20:44 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2015-02-11 18:20:44 -0800 |
commit | 0af05294137e652979db5effa0cb50d512a2d3a9 (patch) | |
tree | cecaeda0e590d4bb38a61e0a5bdebf51d37fbf75 | |
parent | 3743da85e48f2fc57e48ed62c014c1070bb69f38 (diff) | |
download | chef-0af05294137e652979db5effa0cb50d512a2d3a9.tar.gz |
Completing tests for https://github.com/chef/chef/pull/2310, fixes https://github.com/chef/chef/issues/1562tball/complete-2310
-rw-r--r-- | lib/chef/node/attribute.rb | 4 | ||||
-rw-r--r-- | spec/unit/node/attribute_spec.rb | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 9d8738f637..45f2ef01ee 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -475,6 +475,10 @@ class Chef end end + def to_s + merged_attributes.to_s + end + def inspect "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map{|iv| "#{iv}=#{instance_variable_get(iv).inspect}" diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index c924ee2811..250b8c630c 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -1108,6 +1108,26 @@ describe Chef::Node::Attribute do end end + describe "to_s" do + it "should output simple attributes" do + attributes = Chef::Node::Attribute.new(nil, nil, nil, nil) + expect(attributes.to_s).to eq("{}") + end + + it "should output merged attributes" do + default_hash = { + "a" => 1, + "b" => 2 + } + override_hash = { + "b" => 3, + "c" => 4 + } + attributes = Chef::Node::Attribute.new(nil, default_hash, override_hash, nil) + expect(attributes.to_s).to eq('{"a"=>1, "b"=>3, "c"=>4}') + end + end + describe "inspect" do it "should be readable" do # NOTE: previous implementation hid the values, showing @automatic={...} |