spec/unit/knife/cookbook_upload_spec.rb in chef-10.24.4 vs spec/unit/knife/cookbook_upload_spec.rb in chef-10.26.0.beta.0

- old
+ new

@@ -39,11 +39,12 @@ @knife.ui.stub!(:stderr).and_return(@output) end describe 'run' do before(:each) do - @knife.stub!(:upload).and_return(true) + @cookbook_uploader = stub(:upload_cookbooks => nil) + Chef::CookbookUploader.stub(:new => @cookbook_uploader) Chef::CookbookVersion.stub(:list_all_versions).and_return({}) end it 'should print usage and exit when a cookbook name is not provided' do @knife.name_args = [] @@ -123,12 +124,15 @@ end end describe 'when a frozen cookbook exists on the server' do it 'should fail to replace it' do - @knife.stub!(:upload).and_raise(Chef::Exceptions::CookbookFrozen) - @knife.ui.should_receive(:error).with(/Failed to upload 1 cookbook/) + exception = Chef::Exceptions::CookbookFrozen.new + @cookbook_uploader.should_receive(:upload_cookbooks). + and_raise(exception) + @knife.ui.stub(:error) + @knife.ui.should_receive(:error).with(exception) lambda { @knife.run }.should raise_error(SystemExit) end it 'should not update the version constraints for an environment' do @knife.stub!(:assert_environment_valid!).and_return(true) @@ -138,7 +142,7 @@ @knife.ui.should_receive(:warn).with(/Not updating version constraints/) @knife.should_not_receive(:update_version_constraints) lambda { @knife.run }.should raise_error(SystemExit) end end - end -end # run + end # run +end