diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-20 13:06:49 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-20 13:06:49 -0700 |
commit | e30aa05ac624d812645fceaf00fa7ec3b2176ef8 (patch) | |
tree | 5c4db9f3a47c0d35f34b09a07f836a4c73ff093b | |
parent | 057c450f4aa02e7f97a9cce6d506899a190509c1 (diff) | |
download | chef-e30aa05ac624d812645fceaf00fa7ec3b2176ef8.tar.gz |
add another spec for chef_environment
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-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 |