summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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