summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-10-28 02:40:44 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2019-10-28 02:40:44 +0530
commitef2fbf960564d094e8c310dc3991d3fb477ddf30 (patch)
treecdd1d59ee5a659b7a953dc941ccbc69c242ff441
parent18fa2a105001a053be46fd3be1b4dd3f7e2a74ce (diff)
downloadchef-ef2fbf960564d094e8c310dc3991d3fb477ddf30.tar.gz
Add format supported option in values
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/application/knife.rb1
-rw-r--r--spec/unit/application/knife_spec.rb17
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index 6f192a3e1f..10634176c4 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -114,6 +114,7 @@ class Chef::Application::Knife < Chef::Application
short: "-F FORMAT",
long: "--format FORMAT",
description: "Which format to use for output.",
+ in: %w{summary text json yaml pp},
default: "summary"
option :local_mode,
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index ea5083ac15..4b727eef93 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -77,6 +77,23 @@ describe Chef::Application::Knife do
expect(Chef::Config[:color]).to be_truthy
end
+ context "validate --format option" do
+ it "should set the default format summary" do
+ with_argv(*%w{noop knife command}) do
+ expect(@knife).to receive(:exit).with(0)
+ @knife.run
+ expect(@knife.default_config[:format]).to eq("summary")
+ end
+ end
+
+ it "should raise the error for invalid value" do
+ with_argv(*%w{noop knife command -F abc}) do
+ expect(STDOUT).to receive(:puts).at_least(2).times
+ expect { @knife.run }.to raise_error(SystemExit) { |e| expect(e.status).to eq(2) }
+ end
+ end
+ end
+
context "when given fips flags" do
context "when Chef::Config[:fips]=false" do
before do