summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Roberts <chrisroberts.code@gmail.com>2012-10-17 16:31:54 -0700
committerdanielsdeleo <dan@opscode.com>2013-01-14 17:28:02 -0800
commit2887e0fe804bd21c8b1d1456837d42ec655a0331 (patch)
tree8f5f70d7bec2611acedc7cb3807db24b9a64d2a6
parent416ef57a8e1a1b7effe2d2cf9ab940b8c6fdd6af (diff)
downloadchef-2887e0fe804bd21c8b1d1456837d42ec655a0331.tar.gz
Update stubbing order within config spec
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--spec/unit/knife/configure_spec.rb20
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index a2db94604f..a3c4970545 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -354,7 +354,7 @@ class Chef
Chef::Config[:color] = config[:color]
case Chef::Config[:verbosity]
- when 0
+ when 0, nil
Chef::Config[:log_level] = :error
when 1
Chef::Config[:log_level] = :info
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 85ee996dd5..692fc5ea15 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -2,10 +2,10 @@ require 'spec_helper'
describe Chef::Knife::Configure do
before do
- @original_config = Chef::Config.configuration.dup
-
Chef::Log.logger = Logger.new(StringIO.new)
+ @original_config = Chef::Config.configuration.dup
+
Chef::Config[:node_name] = "webmonkey.example.com"
@knife = Chef::Knife::Configure.new
@rest_client = mock("null rest client", :post_rest => { :result => :true })
@@ -205,12 +205,18 @@ describe Chef::Knife::Configure do
end
it "creates a new client when given the --initial option" do
- File.stub!(:expand_path).with("/home/you/.chef/knife.rb").and_return("/home/you/.chef/knife.rb")
- File.stub!(:expand_path).with("/home/you/.chef/a-new-user.pem").and_return("/home/you/.chef/a-new-user.pem")
- File.stub!(:expand_path).with("/etc/chef/validation.pem").and_return("/etc/chef/validation.pem")
- File.stub!(:expand_path).with("/etc/chef/webui.pem").and_return("/etc/chef/webui.pem")
+ File.should_receive(:expand_path).with("/home/you/.chef/knife.rb").and_return("/home/you/.chef/knife.rb")
+ File.should_receive(:expand_path).with("/home/you/.chef/a-new-user.pem").and_return("/home/you/.chef/a-new-user.pem")
+ File.should_receive(:expand_path).with("/etc/chef/validation.pem").and_return("/etc/chef/validation.pem")
+ File.should_receive(:expand_path).with("/etc/chef/webui.pem").and_return("/etc/chef/webui.pem")
Chef::Config[:node_name] = "webmonkey.example.com"
- client_command = Chef::Knife::ClientCreate.new
+
+
+ client_command_config = {}
+
+ client_command = mock("knife client create command", :config => client_command_config)
+ client_command.should_receive(:name_args=).with(["a-new-user"])
+ client_command.stub!(:name_args).and_return(["a-new-user"])
client_command.should_receive(:run)
Etc.stub!(:getlogin).and_return("a-new-user")