From 182f3760dd4d81033d57cfc4d36b2fb6fc848e32 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Tue, 26 May 2015 12:47:33 -0700 Subject: Test format_for_display when given keys don't exist at all --- spec/unit/knife/core/ui_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/unit') diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 1fe46eb85b..ab420518a3 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -375,6 +375,13 @@ EOM @ui.config[:attribute] = "name" expect(@ui.format_for_display(input)).to eq( {"chef.localdomain"=>{"name"=>"chef.localdomain"} }) 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" + @ui.config[:attribute] = non_existing_path + expect(@ui.format_for_display(input)).to eq({ "sample-data-bag-item" => { non_existing_path => nil } }) + end end describe "with --run-list passed" do -- cgit v1.2.1