diff options
Diffstat (limited to 'spec/unit/knife/cookbook_site_share_spec.rb')
-rw-r--r-- | spec/unit/knife/cookbook_site_share_spec.rb | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index 051a3ed168..c8777312cb 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -22,7 +22,6 @@ require "chef/cookbook_uploader" require "chef/cookbook_site_streaming_uploader" describe Chef::Knife::CookbookSiteShare do - before(:each) do @knife = Chef::Knife::CookbookSiteShare.new # Merge default settings in. @@ -50,7 +49,6 @@ describe Chef::Knife::CookbookSiteShare do end describe "run" do - before(:each) do allow(@knife).to receive(:do_upload).and_return(true) @category_response = { @@ -145,8 +143,8 @@ describe Chef::Knife::CookbookSiteShare do it "should list files in the tarball" do allow(@knife).to receive(:tar_cmd).and_return("footar") - expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", {:cwd => "/var/tmp/dummy"}) - expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", {:cwd => "/var/tmp/dummy"}) + expect(@knife).to receive(:shell_out!).with("footar -czf #{@cookbook.name}.tgz #{@cookbook.name}", { :cwd => "/var/tmp/dummy" }) + expect(@knife).to receive(:shell_out!).with("footar -tzf #{@cookbook.name}.tgz", { :cwd => "/var/tmp/dummy" }) @knife.run end @@ -159,7 +157,6 @@ describe Chef::Knife::CookbookSiteShare do end describe "do_upload" do - before(:each) do @upload_response = double("Net::HTTPResponse") allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response) @@ -172,7 +169,7 @@ describe Chef::Knife::CookbookSiteShare do end it 'should post the cookbook to "https://supermarket.chef.io"' do - response_text = Chef::JSONCompat.to_json({:uri => "https://supermarket.chef.io/cookbooks/cookbook_name"}) + response_text = Chef::JSONCompat.to_json({ :uri => "https://supermarket.chef.io/cookbooks/cookbook_name" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(201) expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything()) @@ -180,7 +177,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should alert the user when a version already exists" do - response_text = Chef::JSONCompat.to_json({:error_messages => ["Version already exists"]}) + response_text = Chef::JSONCompat.to_json({ :error_messages => ["Version already exists"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(409) expect { @knife.run }.to raise_error(SystemExit) @@ -188,7 +185,7 @@ describe Chef::Knife::CookbookSiteShare do end it "should pass any errors on to the user" do - response_text = Chef::JSONCompat.to_json({:error_messages => ["You're holding it wrong"]}) + response_text = Chef::JSONCompat.to_json({ :error_messages => ["You're holding it wrong"] }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(403) expect { @knife.run }.to raise_error(SystemExit) @@ -196,14 +193,12 @@ describe Chef::Knife::CookbookSiteShare do end it "should print the body if no errors are exposed on failure" do - response_text = Chef::JSONCompat.to_json({:system_error => "Your call was dropped", :reason => "There's a map for that"}) + response_text = Chef::JSONCompat.to_json({ :system_error => "Your call was dropped", :reason => "There's a map for that" }) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(500) expect(@knife.ui).to receive(:error).with(/#{Regexp.escape(response_text)}/)#.ordered expect(@knife.ui).to receive(:error).with(/Unknown error/)#.ordered expect { @knife.run }.to raise_error(SystemExit) end - end - end |