summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJulian C. Dunn <jdunn@opscode.com>2013-04-11 18:04:25 -0400
committerBryan McLellan <btm@opscode.com>2013-06-18 10:38:31 -0700
commitf33f0f7953d65271ac4e7f81101b7fa50671f096 (patch)
tree08b25cdba224c45bfb2fa273ea788615fc6e5585 /spec
parentdb2730e41d2b99c4f8c52de67278355a60849c1d (diff)
downloadchef-f33f0f7953d65271ac4e7f81101b7fa50671f096.tar.gz
[CHEF-4022] Write tests. Exit with a non-zero code.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index 6ae3fbecd2..bea5c602c8 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -33,6 +33,13 @@ describe Chef::Knife::CookbookDownload do
lambda { @knife.run }.should raise_error(SystemExit)
end
+ it 'should exit with a fatal error when there is no cookbook on the server' do
+ @knife.name_args = ['foobar', nil]
+ @knife.should_receive(:determine_version).and_return(nil)
+ @knife.ui.should_receive(:fatal).with(/versions found for cookbook/)
+ lambda { @knife.run }.should raise_error(SystemExit)
+ end
+
describe 'with a cookbook name' do
before(:each) do
@knife.name_args = ['foobar']
@@ -136,6 +143,13 @@ describe Chef::Knife::CookbookDownload do
end
describe 'determine_version' do
+
+ it 'should return nil if there are no versions' do
+ @knife.should_receive(:available_versions).and_return(nil)
+ @knife.determine_version.should == nil
+ @knife.version.should == nil
+ end
+
it 'should return and set the version if there is only one version' do
@knife.should_receive(:available_versions).at_least(:once).and_return(['1.0.0'])
@knife.determine_version.should == '1.0.0'
@@ -164,7 +178,14 @@ describe Chef::Knife::CookbookDownload do
@knife.cookbook_name = 'foobar'
end
- it 'should return the available vesions' do
+ it 'should return nil if there are no versions' do
+ Chef::CookbookVersion.should_receive(:available_versions).
+ with('foobar').
+ and_return(nil)
+ @knife.available_versions.should == nil
+ end
+
+ it 'should return the available versions' do
Chef::CookbookVersion.should_receive(:available_versions).
with('foobar').
and_return(['1.1.0', '2.0.0', '1.0.0'])