diff options
Diffstat (limited to 'spec/unit/knife/cookbook_bulk_delete_spec.rb')
-rw-r--r-- | spec/unit/knife/cookbook_bulk_delete_spec.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index fb4b1d1484..98cd06bbbc 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -28,19 +28,19 @@ describe Chef::Knife::CookbookBulkDelete do @knife.name_args = ["."] @stdout = StringIO.new @stderr = StringIO.new - @knife.ui.stub(:stdout).and_return(@stdout) - @knife.ui.stub(:stderr).and_return(@stderr) - @knife.ui.stub(:confirm).and_return(true) + allow(@knife.ui).to receive(:stdout).and_return(@stdout) + allow(@knife.ui).to receive(:stderr).and_return(@stderr) + allow(@knife.ui).to receive(:confirm).and_return(true) @cookbooks = Hash.new %w{cheezburger pizza lasagna}.each do |cookbook_name| cookbook = Chef::CookbookVersion.new(cookbook_name) @cookbooks[cookbook_name] = cookbook end @rest = double("Chef::REST") - @rest.stub(:get_rest).and_return(@cookbooks) - @rest.stub(:delete_rest).and_return(true) - @knife.stub(:rest).and_return(@rest) - Chef::CookbookVersion.stub(:list).and_return(@cookbooks) + allow(@rest).to receive(:get_rest).and_return(@cookbooks) + allow(@rest).to receive(:delete_rest).and_return(true) + allow(@knife).to receive(:rest).and_return(@rest) + allow(Chef::CookbookVersion).to receive(:list).and_return(@cookbooks) end @@ -49,41 +49,41 @@ describe Chef::Knife::CookbookBulkDelete do describe "when there are several cookbooks on the server" do before do @cheezburger = {'cheezburger' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-cheez", "version" => "1.0.0"}]}} - @rest.stub(:get_rest).with('cookbooks/cheezburger').and_return(@cheezburger) + allow(@rest).to receive(:get_rest).with('cookbooks/cheezburger').and_return(@cheezburger) @pizza = {'pizza' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-pizza", "version" => "2.0.0"}]}} - @rest.stub(:get_rest).with('cookbooks/pizza').and_return(@pizza) + allow(@rest).to receive(:get_rest).with('cookbooks/pizza').and_return(@pizza) @lasagna = {'lasagna' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-lasagna", "version" => "3.0.0"}]}} - @rest.stub(:get_rest).with('cookbooks/lasagna').and_return(@lasagna) + allow(@rest).to receive(:get_rest).with('cookbooks/lasagna').and_return(@lasagna) end it "should print the cookbooks you are about to delete" do expected = @knife.ui.list(@cookbooks.keys.sort, :columns_down) @knife.run - @stdout.string.should match(/#{expected}/) + expect(@stdout.string).to match(/#{expected}/) end it "should confirm you really want to delete them" do - @knife.ui.should_receive(:confirm) + expect(@knife.ui).to receive(:confirm) @knife.run end it "should delete each cookbook" do {"cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => '3.0.0'}.each do |cookbook_name, version| - @rest.should_receive(:delete_rest).with("cookbooks/#{cookbook_name}/#{version}") + expect(@rest).to receive(:delete_rest).with("cookbooks/#{cookbook_name}/#{version}") end @knife.run end it "should only delete cookbooks that match the regex" do @knife.name_args = ["cheezburger"] - @rest.should_receive(:delete_rest).with('cookbooks/cheezburger/1.0.0') + expect(@rest).to receive(:delete_rest).with('cookbooks/cheezburger/1.0.0') @knife.run end end it "should exit if the regex is not provided" do @knife.name_args = [] - lambda { @knife.run }.should raise_error(SystemExit) + expect { @knife.run }.to raise_error(SystemExit) end end |