summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--spec/unit/knife_spec.rb15
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index fed2ad4cfa..6fa29bea16 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -306,7 +306,7 @@ class Chef
# copy Mixlib::CLI over so that it can be configured in knife.rb
# config file
- Chef::Config[:verbosity] = config[:verbosity]
+ Chef::Config[:verbosity] = config[:verbosity] if config[:verbosity]
end
def parse_options(args)
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 9ccd91775f..5ab8e84eac 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -63,6 +63,12 @@ describe Chef::Knife do
Chef::Knife.reset_config_loader!
end
+ it "does not reset Chef::Config[:verbosity to nil if config[:verbosity] is nil" do
+ Chef::Config[:verbosity] = 2
+ Chef::Knife.new
+ expect(Chef::Config[:verbosity]).to eq(2)
+ end
+
describe "after loading a subcommand" do
before do
Chef::Knife.reset_subcommands!
@@ -309,7 +315,7 @@ describe Chef::Knife do
expect(Chef::Config[:listen]).to be(false)
end
- context "verbosity is greater than zero" do
+ context "verbosity is one" do
let(:fake_config) { "/does/not/exist/knife.rb" }
before do
@@ -327,6 +333,13 @@ describe Chef::Knife do
knife.configure_chef
end
end
+
+ it "does not humanize the exception if Chef::Config[:verbosity] is two" do
+ Chef::Config[:verbosity] = 2
+ allow(knife).to receive(:run).and_raise(Exception)
+ expect(knife).not_to receive(:humanize_exception)
+ expect { knife.run_with_pretty_exceptions }.to raise_error(Exception)
+ end
end
end