spec/cli/deploy_spec.rb in simple_deploy-0.7.2 vs spec/cli/deploy_spec.rb in simple_deploy-0.7.3

- old
+ new

@@ -1,19 +1,20 @@ require 'spec_helper' require 'simple_deploy/cli' describe SimpleDeploy::CLI::Deploy do + include_context 'cli config' + include_context 'double stubbed logger' + include_context 'stubbed stack', :name => 'my_stack', + :environment => 'my_env', + :internal => false + describe 'deploy' do before do - @logger = stub 'logger', 'info' => 'true', 'error' => 'true' - @stack = stub :attributes => {} + @stack_mock.stub(:attributes).and_return({}) @notifier = stub - - SimpleDeploy::SimpleDeployLogger.should_receive(:new). - with(:log_level => 'debug'). - and_return(@logger) end it "should notify on success" do options = { :environment => 'my_env', :log_level => 'debug', @@ -27,23 +28,15 @@ :required => [:environment, :name]) Trollop.stub(:options).and_return(options) SimpleDeploy::Notifier.should_receive(:new). with(:stack_name => 'my_stack', - :environment => 'my_env', - :logger => @logger). + :environment => 'my_env'). and_return(@notifier) - SimpleDeploy::Stack.should_receive(:new). - with(:environment => 'my_env', - :logger => @logger, - :name => 'my_stack', - :internal => false). - and_return(@stack) - - @stack.should_receive(:wait_for_stable) - @stack.should_receive(:deploy).with(true).and_return(true) + @stack_mock.should_receive(:wait_for_stable) + @stack_mock.should_receive(:deploy).with(true).and_return(true) @notifier.should_receive(:send_deployment_start_message) @notifier.should_receive(:send_deployment_complete_message) subject.deploy end @@ -61,23 +54,15 @@ :required => [:environment, :name]) Trollop.stub(:options).and_return(options) SimpleDeploy::Notifier.should_receive(:new). with(:stack_name => 'my_stack', - :environment => 'my_env', - :logger => @logger). + :environment => 'my_env'). and_return(@notifier) - SimpleDeploy::Stack.should_receive(:new). - with(:environment => 'my_env', - :logger => @logger, - :name => 'my_stack', - :internal => false). - and_return(@stack) - - @stack.should_receive(:wait_for_stable) - @stack.should_receive(:deploy).with(true).and_return(false) + @stack_mock.should_receive(:wait_for_stable) + @stack_mock.should_receive(:deploy).with(true).and_return(false) @notifier.should_receive(:send_deployment_start_message) begin subject.deploy rescue SystemExit => e @@ -98,24 +83,16 @@ :required => [:environment, :name]) Trollop.stub(:options).and_return(options) SimpleDeploy::Notifier.should_receive(:new). with(:stack_name => 'my_stack', - :environment => 'my_env', - :logger => @logger). + :environment => 'my_env'). and_return(@notifier) - SimpleDeploy::Stack.should_receive(:new). - with(:environment => 'my_env', - :logger => @logger, - :name => 'my_stack', - :internal => false). - and_return(@stack) - - @stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(true) - @stack.should_receive(:wait_for_stable) - @stack.should_receive(:deploy).with(true).and_return(true) + @stack_mock.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(true) + @stack_mock.should_receive(:wait_for_stable) + @stack_mock.should_receive(:deploy).with(true).and_return(true) @notifier.should_receive(:send_deployment_start_message) @notifier.should_receive(:send_deployment_complete_message) subject.deploy end @@ -133,24 +110,16 @@ :required => [:environment, :name]) Trollop.stub(:options).and_return(options) SimpleDeploy::Notifier.should_receive(:new). with(:stack_name => 'my_stack', - :environment => 'my_env', - :logger => @logger). + :environment => 'my_env'). and_return(@notifier) - SimpleDeploy::Stack.should_receive(:new). - with(:environment => 'my_env', - :logger => @logger, - :name => 'my_stack', - :internal => false). - and_return(@stack) - - @stack.should_receive(:update).with(hash_including(:force => true, + @stack_mock.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(false) - @stack.should_receive(:wait_for_stable) + @stack_mock.should_receive(:wait_for_stable) begin subject.deploy rescue SystemExit => e e.status.should == 1 @@ -170,23 +139,15 @@ :required => [:environment, :name]) Trollop.stub(:options).and_return(options) SimpleDeploy::Notifier.should_receive(:new). with(:stack_name => 'my_stack', - :environment => 'my_env', - :logger => @logger). + :environment => 'my_env'). and_return(@notifier) - SimpleDeploy::Stack.should_receive(:new). - with(:environment => 'my_env', - :logger => @logger, - :name => 'my_stack', - :internal => false). - and_return(@stack) - - @stack.should_not_receive(:update) - @stack.should_receive(:wait_for_stable) - @stack.should_receive(:deploy).with(true).and_return(true) + @stack_mock.should_not_receive(:update) + @stack_mock.should_receive(:wait_for_stable) + @stack_mock.should_receive(:deploy).with(true).and_return(true) @notifier.should_receive(:send_deployment_start_message) @notifier.should_receive(:send_deployment_complete_message) subject.deploy end