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

- old
+ new

@@ -1,9 +1,15 @@ require 'spec_helper' require 'simple_deploy/cli' describe SimpleDeploy::CLI::Clone do + include_context 'cli config' + include_context 'double stubbed logger' + include_context 'clone stack pair', :source_name => 'source_stack', + :source_env => 'my_env', + :new_name => 'new_stack', + :new_env => 'my_env' describe 'clone' do context 'filter_attributes' do before do @source_attributes = { @@ -115,58 +121,39 @@ end end context 'stack creation' do before do - @config = mock 'config' - @logger = stub 'logger', :info => 'true' @options = { :environment => 'my_env', :log_level => 'debug', :source_name => 'source_stack', :new_name => 'new_stack', :attributes => ['chef_repo_bucket_prefix=updated-intu-lc', 'chef_repo_domain=updated_community_chef_repo', 'SolrClientTrafficContainer=solr-client-traffic-container'] } - @source_stack = stub :attributes => { + @source_stack_stub.stub(:attributes).and_return( 'AmiId' => 'ami-7b6a4e3e', 'AppEnv' => 'pod-2-cd-1', 'MaximumAppInstances' => 1, 'MinimumAppInstances' => 1, 'chef_repo_bucket_prefix' => 'intu-lc', 'chef_repo_domain' => 'live_community_chef_repo', 'deployment_user' => 'rmendes' - }, :template => { 'foo' => 'bah' } - @new_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) - - SimpleDeploy::Stack.should_receive(:new). - with(:config => @config, - :environment => 'my_env', - :logger => @logger, - :name => 'source_stack'). - and_return(@source_stack) - SimpleDeploy::Stack.should_receive(:new). - with(:config => @config, - :environment => 'my_env', - :logger => @logger, - :name => 'new_stack'). - and_return(@new_stack) + ) + @source_stack_stub.stub(:template).and_return('foo' => 'bah') + @new_stack_mock.stub(:attributes).and_return({}) end - + it 'should create the new stack using the filtered, merged and added attributes' do subject.should_receive(:valid_options?). with(:provided => @options, :required => [:environment, :source_name, :new_name]) Trollop.stub(:options).and_return(@options) + @new_stack_mock.stub(:template).and_return('foo' => 'bah') - @new_stack.should_receive(:create) do |options| + @new_stack_mock.should_receive(:create) do |options| options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' }, { 'AppEnv' => 'pod-2-cd-1' }, { 'MaximumAppInstances' => 1 }, { 'MinimumAppInstances' => 1 }, { 'chef_repo_bucket_prefix' => 'updated-intu-lc' }, @@ -184,10 +171,10 @@ subject.should_receive(:valid_options?). with(:provided => @options, :required => [:environment, :source_name, :new_name]) Trollop.stub(:options).and_return(@options) - @new_stack.should_receive(:create) do |options| + @new_stack_mock.should_receive(:create) do |options| options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' }, { 'AppEnv' => 'pod-2-cd-1' }, { 'MaximumAppInstances' => 1 }, { 'MinimumAppInstances' => 1 }, { 'chef_repo_bucket_prefix' => 'updated-intu-lc' },