diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-21 09:42:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 09:42:07 -0700 |
commit | a83ebd9424ee1053d6c453317e874ed0dfbfbfe0 (patch) | |
tree | 55589e4ef6c115cc4d2d6dd13ad037eb3e2c9e56 /spec | |
parent | ce694677fdc808143a28457dc44d56e97930b9ec (diff) | |
parent | 50e78d61d00eb0a984d760d5c2035aa8cf3ff291 (diff) | |
download | chef-a83ebd9424ee1053d6c453317e874ed0dfbfbfe0.tar.gz |
Merge pull request #5351 from chef/lcg/node-presenter-tweaks
fix method_access and array handling in node presenter
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/core/ui_spec.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 9f525f22f0..be77fd8501 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -377,12 +377,33 @@ EOM end it "should return the name attribute" do - allow_any_instance_of(Chef::Node).to receive(:name).and_return("chef.localdomain") input = Chef::Node.new + input.name("chef.localdomain") @ui.config[:attribute] = "name" expect(@ui.format_for_display(input)).to eq( { "chef.localdomain" => { "name" => "chef.localdomain" } }) end + it "should return a 'class' attribute and not the node.class" do + input = Chef::Node.new + input.default["class"] = "classy!" + @ui.config[:attribute] = "class" + expect(@ui.format_for_display(input)).to eq( { nil => { "class" => "classy!" } } ) + 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" } } ) + end + it "returns nil when given an attribute path that isn't a name or attribute" do input = { "keys" => { "keys" => "values" }, "hi" => "ho", "id" => "sample-data-bag-item" } non_existing_path = "nope.nada.nothingtoseehere" |