summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Murphy <josh.murphy@cerner.com>2013-12-20 09:32:44 -0600
committerBryan McLellan <btm@getchef.com>2014-03-19 14:39:24 -0700
commite21a5cd7327f85b9469429a3b722402b951d1f8f (patch)
tree40e202decb3dcb86f12338d05e2b1ee75fa3c4b4
parent8d56b90b7093db91c5ad69e025561ff5c3428700 (diff)
downloadchef-e21a5cd7327f85b9469429a3b722402b951d1f8f.tar.gz
CHEF-4851 - Tested stderr string output compared to what function is being called
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index 0f015693ad..cc27e101e8 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -153,6 +153,8 @@ describe Chef::Knife::CookbookUpload do
end
@knife.stub!(:cookbook_names).and_return(["cookbook_dependency", "test_cookbook"])
Chef::CookbookLoader.stub!(:new).and_return(@cookbook_loader)
+ @stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new
+ @knife.ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {})
end
it 'should exit and not upload the cookbook' do
@@ -163,10 +165,10 @@ describe Chef::Knife::CookbookUpload do
end
it 'should output a message for a single missing dependency' do
- @knife.ui.should_receive(:error).with(/Cookbook test_cookbook depends on cookbooks which are not currently/)
- @knife.ui.should_receive(:error).with(/being uploaded and cannot be found on the server\./)
- @knife.ui.should_receive(:error).with(/The missing cookbook\(s\) are: 'dependency' version '>= 0\.0\.0'/)
expect {@knife.run}.to raise_error(SystemExit)
+ @stderr.string.should include('Cookbook test_cookbook depends on cookbooks which are not currently')
+ @stderr.string.should include('being uploaded and cannot be found on the server.')
+ @stderr.string.should include("The missing cookbook(s) are: 'dependency' version '>= 0.0.0'")
end
it 'should output a message for a multiple missing dependencies which are concatenated' do
@@ -178,10 +180,10 @@ describe Chef::Knife::CookbookUpload do
"dependency2" => @cookbook_dependency2}[ckbk]
end
@knife.stub!(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"])
- @knife.ui.should_receive(:error).with(/Cookbook test_cookbook depends on cookbooks which are not currently/)
- @knife.ui.should_receive(:error).with(/being uploaded and cannot be found on the server\./)
- @knife.ui.should_receive(:error).with(/The missing cookbook\(s\) are: 'dependency' version '>= 0\.0\.0', 'dependency2' version '>= 0\.0\.0'/)
expect {@knife.run}.to raise_error(SystemExit)
+ @stderr.string.should include('Cookbook test_cookbook depends on cookbooks which are not currently')
+ @stderr.string.should include('being uploaded and cannot be found on the server.')
+ @stderr.string.should include("The missing cookbook(s) are: 'dependency' version '>= 0.0.0', 'dependency2' version '>= 0.0.0'")
end
end