spec/cli/destroy_spec.rb in simple_deploy-0.7.2 vs spec/cli/destroy_spec.rb in simple_deploy-0.7.3
- old
+ new
@@ -1,42 +1,31 @@
require 'spec_helper'
require 'simple_deploy/cli'
describe SimpleDeploy::CLI::Destroy do
+ include_context 'cli config'
+ include_context 'double stubbed logger'
+ include_context 'stubbed stack', :name => 'my_stack',
+ :environment => 'my_env'
describe 'destroy' do
before do
- @config = mock 'config'
- @logger = stub 'logger', 'info' => 'true'
@options = { :environment => 'my_env',
:log_level => 'debug',
:name => 'my_stack' }
- @stack = stub :attributes => {}
-
- SimpleDeploy::Config.stub(:new).and_return(@config)
- @config.should_receive(:environment).with('my_env').and_return(@config)
- SimpleDeploy::SimpleDeployLogger.should_receive(:new).
- with(:log_level => 'debug').
- and_return(@logger)
+ @stack_mock.stub(:attributes).and_return({})
end
it "should exit with 0" do
subject.should_receive(:valid_options?).
with(:provided => @options,
:required => [:environment, :name])
Trollop.stub(:options).and_return(@options)
- @stack.should_receive(:destroy).and_return(true)
+ @stack_mock.should_receive(:destroy).and_return(true)
- SimpleDeploy::Stack.should_receive(:new).
- with(:config => @config,
- :environment => 'my_env',
- :logger => @logger,
- :name => 'my_stack').
- and_return(@stack)
-
begin
subject.destroy
rescue SystemExit => e
e.status.should == 0
end
@@ -46,17 +35,10 @@
subject.should_receive(:valid_options?).
with(:provided => @options,
:required => [:environment, :name])
Trollop.stub(:options).and_return(@options)
- @stack.should_receive(:destroy).and_return(false)
-
- SimpleDeploy::Stack.should_receive(:new).
- with(:config => @config,
- :environment => 'my_env',
- :logger => @logger,
- :name => 'my_stack').
- and_return(@stack)
+ @stack_mock.should_receive(:destroy).and_return(false)
begin
subject.destroy
rescue SystemExit => e
e.status.should == 1