diff options
-rw-r--r-- | lib/chef/knife/core/generic_presenter.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/core/ui_spec.rb | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 323c2cf350..3f5c0712d0 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -187,7 +187,7 @@ class Chef nil end end - # necessary for coercing hashable non-attribute objects hanging off the node into real hashes + # necessary (?) for coercing objects (the run_list object?) to hashes ( !data.kind_of?(Array) && data.respond_to?(:to_hash) ) ? data.to_hash : data end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 59c308e692..44b7cb1e5c 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -383,11 +383,18 @@ EOM expect(@ui.format_for_display(input)).to eq( { "chef.localdomain" => { "name" => "chef.localdomain" } }) end + it "should return the chef_environment attribute" do + input = Chef::Node.new + input.chef_environment = "production-partner-load-integration-preview-testing" + @ui.config[:attribute] = "chef_environment" + expect(@ui.format_for_display(input)).to eq( { nil => { "chef_environment" => "production-partner-load-integration-preview-testing" } } ) + end + it "works with arrays" do input = Chef::Node.new input.default["array"] = %w{zero one two} @ui.config[:attribute] = "array.1" - expect(@ui.format_for_display(input)).to eq( nil => { "array.1" => "one" }) + expect(@ui.format_for_display(input)).to eq( { nil => { "array.1" => "one" } } ) end it "returns nil when given an attribute path that isn't a name or attribute" do |