simple_deploy 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
 - data/CHANGELOG.md +6 -0
 - data/lib/simple_deploy/aws/cloud_formation/error.rb +32 -0
 - data/lib/simple_deploy/aws/cloud_formation.rb +76 -0
 - data/lib/simple_deploy/aws/instance_reader.rb +59 -0
 - data/lib/simple_deploy/aws/simpledb.rb +52 -0
 - data/lib/simple_deploy/aws.rb +4 -0
 - data/lib/simple_deploy/cli/attributes.rb +7 -18
 - data/lib/simple_deploy/cli/clone.rb +9 -19
 - data/lib/simple_deploy/cli/create.rb +5 -14
 - data/lib/simple_deploy/cli/deploy.rb +8 -11
 - data/lib/simple_deploy/cli/destroy.rb +4 -10
 - data/lib/simple_deploy/cli/environments.rb +1 -1
 - data/lib/simple_deploy/cli/events.rb +5 -11
 - data/lib/simple_deploy/cli/execute.rb +6 -9
 - data/lib/simple_deploy/cli/instances.rb +4 -9
 - data/lib/simple_deploy/cli/list.rb +5 -10
 - data/lib/simple_deploy/cli/outputs.rb +5 -11
 - data/lib/simple_deploy/cli/parameters.rb +5 -11
 - data/lib/simple_deploy/cli/protect.rb +5 -10
 - data/lib/simple_deploy/cli/resources.rb +5 -11
 - data/lib/simple_deploy/cli/shared.rb +6 -6
 - data/lib/simple_deploy/cli/status.rb +5 -11
 - data/lib/simple_deploy/cli/template.rb +8 -13
 - data/lib/simple_deploy/cli/update.rb +6 -10
 - data/lib/simple_deploy/configuration.rb +102 -0
 - data/lib/simple_deploy/entry.rb +71 -0
 - data/lib/simple_deploy/entry_lister.rb +30 -0
 - data/lib/simple_deploy/exceptions.rb +8 -0
 - data/lib/simple_deploy/misc/attribute_merger.rb +2 -5
 - data/lib/simple_deploy/notifier/campfire.rb +15 -12
 - data/lib/simple_deploy/notifier.rb +6 -11
 - data/lib/simple_deploy/stack/deployment/status.rb +5 -3
 - data/lib/simple_deploy/stack/deployment.rb +8 -10
 - data/lib/simple_deploy/stack/execute.rb +2 -3
 - data/lib/simple_deploy/stack/output_mapper.rb +1 -4
 - data/lib/simple_deploy/stack/ssh.rb +4 -4
 - data/lib/simple_deploy/stack/{stack_attribute_formater.rb → stack_attribute_formatter.rb} +4 -6
 - data/lib/simple_deploy/stack/stack_creator.rb +46 -0
 - data/lib/simple_deploy/stack/stack_destroyer.rb +19 -0
 - data/lib/simple_deploy/stack/stack_formatter.rb +25 -0
 - data/lib/simple_deploy/stack/stack_lister.rb +18 -0
 - data/lib/simple_deploy/stack/stack_reader.rb +56 -0
 - data/lib/simple_deploy/stack/stack_updater.rb +67 -0
 - data/lib/simple_deploy/stack/status.rb +53 -0
 - data/lib/simple_deploy/stack.rb +89 -37
 - data/lib/simple_deploy/version.rb +1 -1
 - data/lib/simple_deploy.rb +31 -1
 - data/simple_deploy.gemspec +6 -3
 - data/spec/aws/cloud_formation/error_spec.rb +50 -0
 - data/spec/aws/cloud_formation_spec.rb +207 -0
 - data/spec/aws/instance_reader_spec.rb +96 -0
 - data/spec/aws/simpledb_spec.rb +89 -0
 - data/spec/cli/attributes_spec.rb +5 -15
 - data/spec/cli/clone_spec.rb +14 -27
 - data/spec/cli/create_spec.rb +11 -18
 - data/spec/cli/deploy_spec.rb +24 -63
 - data/spec/cli/destroy_spec.rb +7 -25
 - data/spec/cli/outputs_spec.rb +12 -17
 - data/spec/cli/protect_spec.rb +68 -106
 - data/spec/cli/shared_spec.rb +12 -15
 - data/spec/cli/update_spec.rb +9 -27
 - data/spec/config_spec.rb +47 -14
 - data/spec/contexts/config_contexts.rb +28 -0
 - data/spec/contexts/logger_contexts.rb +9 -0
 - data/spec/contexts/stack_contexts.rb +40 -0
 - data/spec/entry_lister_spec.rb +31 -0
 - data/spec/entry_spec.rb +86 -0
 - data/spec/misc/attribute_merger_spec.rb +3 -8
 - data/spec/notifier/campfire_spec.rb +21 -61
 - data/spec/notifier_spec.rb +18 -40
 - data/spec/spec_helper.rb +10 -0
 - data/spec/stack/deployment/status_spec.rb +13 -13
 - data/spec/stack/deployment_spec.rb +26 -21
 - data/spec/stack/execute_spec.rb +7 -3
 - data/spec/stack/output_mapper_spec.rb +3 -15
 - data/spec/stack/ssh_spec.rb +14 -13
 - data/spec/stack/{stack_attribute_formater_spec.rb → stack_attribute_formatter_spec.rb} +19 -16
 - data/spec/stack/stack_creator_spec.rb +46 -0
 - data/spec/stack/stack_destroyer_spec.rb +18 -0
 - data/spec/stack/stack_formatter_spec.rb +37 -0
 - data/spec/stack/stack_lister_spec.rb +17 -0
 - data/spec/stack/stack_reader_spec.rb +81 -0
 - data/spec/stack/stack_updater_spec.rb +79 -0
 - data/spec/stack/status_spec.rb +106 -0
 - data/spec/stack_spec.rb +160 -133
 - metadata +112 -19
 - data/.rvmrc +0 -1
 - data/lib/simple_deploy/config.rb +0 -87
 
    
        data/spec/cli/attributes_spec.rb
    CHANGED
    
    | 
         @@ -2,27 +2,17 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            describe SimpleDeploy::CLI::Attributes do
         
     | 
| 
      
 5 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'double stubbed stack', :name        => 'my_stack',
         
     | 
| 
      
 8 
     | 
    
         
            +
                                                      :environment => 'my_env'
         
     | 
| 
       5 
9 
     | 
    
         | 
| 
       6 
10 
     | 
    
         
             
              describe 'show' do
         
     | 
| 
       7 
11 
     | 
    
         
             
                before do
         
     | 
| 
       8 
     | 
    
         
            -
                  @config  = mock 'config'
         
     | 
| 
       9 
     | 
    
         
            -
                  @logger  = stub 'logger'
         
     | 
| 
       10 
12 
     | 
    
         
             
                  @options = { :environment => 'my_env',
         
     | 
| 
       11 
13 
     | 
    
         
             
                               :log_level   => 'debug',
         
     | 
| 
       12 
14 
     | 
    
         
             
                               :name        => 'my_stack' }
         
     | 
| 
       13 
     | 
    
         
            -
                  @ 
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                  SimpleDeploy::Config.stub(:new).and_return(@config)
         
     | 
| 
       16 
     | 
    
         
            -
                  @config.should_receive(:environment).with('my_env').and_return(@config)
         
     | 
| 
       17 
     | 
    
         
            -
                  SimpleDeploy::SimpleDeployLogger.should_receive(:new).
         
     | 
| 
       18 
     | 
    
         
            -
                                                   with(:log_level => 'debug').
         
     | 
| 
       19 
     | 
    
         
            -
                                                   and_return(@logger)
         
     | 
| 
       20 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       21 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       22 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       23 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       24 
     | 
    
         
            -
                                           :name        => 'my_stack').
         
     | 
| 
       25 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @stack_stub.stub(:attributes).and_return({ 'foo' => 'bar', 'baz' => 'blah' })
         
     | 
| 
       26 
16 
     | 
    
         
             
                end
         
     | 
| 
       27 
17 
     | 
    
         | 
| 
       28 
18 
     | 
    
         
             
                it 'should output the attributes' do
         
     | 
    
        data/spec/cli/clone_spec.rb
    CHANGED
    
    | 
         @@ -2,6 +2,12 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            describe SimpleDeploy::CLI::Clone do
         
     | 
| 
      
 5 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'clone stack pair', :source_name => 'source_stack',
         
     | 
| 
      
 8 
     | 
    
         
            +
                                                  :source_env  => 'my_env',
         
     | 
| 
      
 9 
     | 
    
         
            +
                                                  :new_name    => 'new_stack',
         
     | 
| 
      
 10 
     | 
    
         
            +
                                                  :new_env     => 'my_env'
         
     | 
| 
       5 
11 
     | 
    
         | 
| 
       6 
12 
     | 
    
         
             
              describe 'clone' do
         
     | 
| 
       7 
13 
     | 
    
         
             
                context 'filter_attributes' do
         
     | 
| 
         @@ -117,8 +123,6 @@ describe SimpleDeploy::CLI::Clone do 
     | 
|
| 
       117 
123 
     | 
    
         | 
| 
       118 
124 
     | 
    
         
             
                context 'stack creation' do
         
     | 
| 
       119 
125 
     | 
    
         
             
                  before do
         
     | 
| 
       120 
     | 
    
         
            -
                    @config  = mock 'config'
         
     | 
| 
       121 
     | 
    
         
            -
                    @logger  = stub 'logger', :info => 'true'
         
     | 
| 
       122 
126 
     | 
    
         
             
                    @options = { :environment => 'my_env',
         
     | 
| 
       123 
127 
     | 
    
         
             
                                 :log_level   => 'debug',
         
     | 
| 
       124 
128 
     | 
    
         
             
                                 :source_name => 'source_stack',
         
     | 
| 
         @@ -127,7 +131,7 @@ describe SimpleDeploy::CLI::Clone do 
     | 
|
| 
       127 
131 
     | 
    
         
             
                                                  'chef_repo_domain=updated_community_chef_repo',
         
     | 
| 
       128 
132 
     | 
    
         
             
                                                  'SolrClientTrafficContainer=solr-client-traffic-container'] }
         
     | 
| 
       129 
133 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                    @ 
     | 
| 
      
 134 
     | 
    
         
            +
                    @source_stack_stub.stub(:attributes).and_return(
         
     | 
| 
       131 
135 
     | 
    
         
             
                      'AmiId' => 'ami-7b6a4e3e',
         
     | 
| 
       132 
136 
     | 
    
         
             
                      'AppEnv' => 'pod-2-cd-1',
         
     | 
| 
       133 
137 
     | 
    
         
             
                      'MaximumAppInstances' => 1,
         
     | 
| 
         @@ -135,36 +139,19 @@ describe SimpleDeploy::CLI::Clone do 
     | 
|
| 
       135 
139 
     | 
    
         
             
                      'chef_repo_bucket_prefix' => 'intu-lc',
         
     | 
| 
       136 
140 
     | 
    
         
             
                      'chef_repo_domain' => 'live_community_chef_repo',
         
     | 
| 
       137 
141 
     | 
    
         
             
                      'deployment_user' => 'rmendes'
         
     | 
| 
       138 
     | 
    
         
            -
                     
     | 
| 
       139 
     | 
    
         
            -
                    @ 
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
                    SimpleDeploy::Config.stub(:new).and_return(@config)
         
     | 
| 
       142 
     | 
    
         
            -
                    @config.should_receive(:environment).with('my_env').and_return(@config)
         
     | 
| 
       143 
     | 
    
         
            -
                    SimpleDeploy::SimpleDeployLogger.should_receive(:new).
         
     | 
| 
       144 
     | 
    
         
            -
                                              with(:log_level => 'debug').
         
     | 
| 
       145 
     | 
    
         
            -
                                              and_return(@logger)
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
                    SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       148 
     | 
    
         
            -
                                                  with(:config      => @config,
         
     | 
| 
       149 
     | 
    
         
            -
                                                       :environment => 'my_env',
         
     | 
| 
       150 
     | 
    
         
            -
                                                       :logger      => @logger,
         
     | 
| 
       151 
     | 
    
         
            -
                                                       :name        => 'source_stack').
         
     | 
| 
       152 
     | 
    
         
            -
                                                  and_return(@source_stack)
         
     | 
| 
       153 
     | 
    
         
            -
                    SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       154 
     | 
    
         
            -
                                                  with(:config      => @config,
         
     | 
| 
       155 
     | 
    
         
            -
                                                       :environment => 'my_env',
         
     | 
| 
       156 
     | 
    
         
            -
                                                       :logger      => @logger,
         
     | 
| 
       157 
     | 
    
         
            -
                                                       :name        => 'new_stack').
         
     | 
| 
       158 
     | 
    
         
            -
                                                  and_return(@new_stack)
         
     | 
| 
      
 142 
     | 
    
         
            +
                    )
         
     | 
| 
      
 143 
     | 
    
         
            +
                    @source_stack_stub.stub(:template).and_return('foo' => 'bah')
         
     | 
| 
      
 144 
     | 
    
         
            +
                    @new_stack_mock.stub(:attributes).and_return({})
         
     | 
| 
       159 
145 
     | 
    
         
             
                  end
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
       161 
147 
     | 
    
         
             
                  it 'should create the new stack using the filtered, merged and added attributes' do
         
     | 
| 
       162 
148 
     | 
    
         
             
                    subject.should_receive(:valid_options?).
         
     | 
| 
       163 
149 
     | 
    
         
             
                            with(:provided => @options,
         
     | 
| 
       164 
150 
     | 
    
         
             
                                 :required => [:environment, :source_name, :new_name])
         
     | 
| 
       165 
151 
     | 
    
         
             
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
      
 152 
     | 
    
         
            +
                    @new_stack_mock.stub(:template).and_return('foo' => 'bah')
         
     | 
| 
       166 
153 
     | 
    
         | 
| 
       167 
     | 
    
         
            -
                    @ 
     | 
| 
      
 154 
     | 
    
         
            +
                    @new_stack_mock.should_receive(:create) do |options|
         
     | 
| 
       168 
155 
     | 
    
         
             
                      options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' },
         
     | 
| 
       169 
156 
     | 
    
         
             
                                                      { 'AppEnv' => 'pod-2-cd-1' },
         
     | 
| 
       170 
157 
     | 
    
         
             
                                                      { 'MaximumAppInstances' => 1 },
         
     | 
| 
         @@ -186,7 +173,7 @@ describe SimpleDeploy::CLI::Clone do 
     | 
|
| 
       186 
173 
     | 
    
         
             
                                  :required => [:environment, :source_name, :new_name])
         
     | 
| 
       187 
174 
     | 
    
         
             
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
       188 
175 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
                    @ 
     | 
| 
      
 176 
     | 
    
         
            +
                    @new_stack_mock.should_receive(:create) do |options|
         
     | 
| 
       190 
177 
     | 
    
         
             
                      options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' },
         
     | 
| 
       191 
178 
     | 
    
         
             
                                                      { 'AppEnv' => 'pod-2-cd-1' },
         
     | 
| 
       192 
179 
     | 
    
         
             
                                                      { 'MaximumAppInstances' => 1 },
         
     | 
    
        data/spec/cli/create_spec.rb
    CHANGED
    
    | 
         @@ -1,12 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'simple_deploy/cli'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            describe SimpleDeploy::CLI::Create do
         
     | 
| 
      
 5 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'stubbed stack', :name        => 'mytest',
         
     | 
| 
      
 8 
     | 
    
         
            +
                                               :environment => 'test'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       4 
10 
     | 
    
         
             
              before do
         
     | 
| 
       5 
     | 
    
         
            -
                @config_object         = mock 'config'
         
     | 
| 
       6 
11 
     | 
    
         
             
                @config_env            = mock 'environment config'
         
     | 
| 
       7 
     | 
    
         
            -
                @stack_mock            = mock 'stack'
         
     | 
| 
       8 
12 
     | 
    
         
             
                @attribute_merger_mock = mock 'attribute merger'
         
     | 
| 
       9 
     | 
    
         
            -
                @logger                = stub 'logger', :info => true
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
       11 
14 
     | 
    
         
             
                @options = { :attributes  => [ 'attr1=val1' ],
         
     | 
| 
       12 
15 
     | 
    
         
             
                             :input_stack => [ 'stack1' ],
         
     | 
| 
         @@ -15,23 +18,13 @@ describe SimpleDeploy::CLI::Create do 
     | 
|
| 
       15 
18 
     | 
    
         
             
                             :log_level   => 'info',
         
     | 
| 
       16 
19 
     | 
    
         
             
                             :template    => '/tmp/test.json' }
         
     | 
| 
       17 
20 
     | 
    
         
             
                Trollop.stub :options => @options
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                SimpleDeploy 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                @config_object.stub :environments => { 'test' => 'config_data' }
         
     | 
| 
       23 
     | 
    
         
            -
                @config_object.should_receive(:environment).with('test').
         
     | 
| 
       24 
     | 
    
         
            -
                               and_return 'config_data'
         
     | 
| 
       25 
     | 
    
         
            -
                SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       26 
     | 
    
         
            -
                                    with(:environment => 'test',
         
     | 
| 
       27 
     | 
    
         
            -
                                         :name        => 'mytest',
         
     | 
| 
       28 
     | 
    
         
            -
                                         :config      => 'config_data',
         
     | 
| 
       29 
     | 
    
         
            -
                                         :logger      => @logger).
         
     | 
| 
       30 
     | 
    
         
            -
                                    and_return(@stack_mock)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                SimpleDeploy.stub(:environments).and_return(@config_env)
         
     | 
| 
      
 23 
     | 
    
         
            +
                @config_env.should_receive(:keys).and_return(['test'])
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       31 
25 
     | 
    
         
             
                SimpleDeploy::Misc::AttributeMerger.stub :new => @attribute_merger_mock
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       32 
27 
     | 
    
         
             
                merge_options = { :attributes   => [ { "attr1" => "val1" } ], 
         
     | 
| 
       33 
     | 
    
         
            -
                                  :config       => 'config_data', 
         
     | 
| 
       34 
     | 
    
         
            -
                                  :logger       => @logger,
         
     | 
| 
       35 
28 
     | 
    
         
             
                                  :environment  => 'test',
         
     | 
| 
       36 
29 
     | 
    
         
             
                                  :template     => '/tmp/test.json',
         
     | 
| 
       37 
30 
     | 
    
         
             
                                  :input_stacks => ["stack1"] }
         
     | 
    
        data/spec/cli/deploy_spec.rb
    CHANGED
    
    | 
         @@ -3,15 +3,16 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            describe SimpleDeploy::CLI::Deploy do
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 8 
     | 
    
         
            +
              include_context 'stubbed stack', :name        => 'my_stack',
         
     | 
| 
      
 9 
     | 
    
         
            +
                                               :environment => 'my_env',
         
     | 
| 
      
 10 
     | 
    
         
            +
                                               :internal    => false
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       6 
12 
     | 
    
         
             
              describe 'deploy' do
         
     | 
| 
       7 
13 
     | 
    
         
             
                before do
         
     | 
| 
       8 
     | 
    
         
            -
                  @ 
     | 
| 
       9 
     | 
    
         
            -
                  @stack    = stub :attributes => {}
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @stack_mock.stub(:attributes).and_return({})
         
     | 
| 
       10 
15 
     | 
    
         
             
                  @notifier = stub
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  SimpleDeploy::SimpleDeployLogger.should_receive(:new).
         
     | 
| 
       13 
     | 
    
         
            -
                                                   with(:log_level => 'debug').
         
     | 
| 
       14 
     | 
    
         
            -
                                                   and_return(@logger)
         
     | 
| 
       15 
16 
     | 
    
         
             
                end
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
18 
     | 
    
         
             
                it "should notify on success" do
         
     | 
| 
         @@ -29,19 +30,11 @@ describe SimpleDeploy::CLI::Deploy do 
     | 
|
| 
       29 
30 
     | 
    
         | 
| 
       30 
31 
     | 
    
         
             
                  SimpleDeploy::Notifier.should_receive(:new).
         
     | 
| 
       31 
32 
     | 
    
         
             
                                      with(:stack_name  => 'my_stack',
         
     | 
| 
       32 
     | 
    
         
            -
                                           :environment => 'my_env' 
     | 
| 
       33 
     | 
    
         
            -
                                           :logger      => @logger).
         
     | 
| 
      
 33 
     | 
    
         
            +
                                           :environment => 'my_env').
         
     | 
| 
       34 
34 
     | 
    
         
             
                                      and_return(@notifier)
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                   
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       39 
     | 
    
         
            -
                                           :name        => 'my_stack',
         
     | 
| 
       40 
     | 
    
         
            -
                                           :internal    => false).
         
     | 
| 
       41 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                  @stack.should_receive(:wait_for_stable)
         
     | 
| 
       44 
     | 
    
         
            -
                  @stack.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @stack_mock.should_receive(:wait_for_stable)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @stack_mock.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
       45 
38 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_start_message)
         
     | 
| 
       46 
39 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_complete_message)
         
     | 
| 
       47 
40 
     | 
    
         | 
| 
         @@ -63,19 +56,11 @@ describe SimpleDeploy::CLI::Deploy do 
     | 
|
| 
       63 
56 
     | 
    
         | 
| 
       64 
57 
     | 
    
         
             
                  SimpleDeploy::Notifier.should_receive(:new).
         
     | 
| 
       65 
58 
     | 
    
         
             
                                      with(:stack_name  => 'my_stack',
         
     | 
| 
       66 
     | 
    
         
            -
                                           :environment => 'my_env' 
     | 
| 
       67 
     | 
    
         
            -
                                           :logger      => @logger).
         
     | 
| 
      
 59 
     | 
    
         
            +
                                           :environment => 'my_env').
         
     | 
| 
       68 
60 
     | 
    
         
             
                                      and_return(@notifier)
         
     | 
| 
       69 
61 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       73 
     | 
    
         
            -
                                           :name        => 'my_stack',
         
     | 
| 
       74 
     | 
    
         
            -
                                           :internal    => false).
         
     | 
| 
       75 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                  @stack.should_receive(:wait_for_stable)
         
     | 
| 
       78 
     | 
    
         
            -
                  @stack.should_receive(:deploy).with(true).and_return(false)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  @stack_mock.should_receive(:wait_for_stable)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  @stack_mock.should_receive(:deploy).with(true).and_return(false)
         
     | 
| 
       79 
64 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_start_message)
         
     | 
| 
       80 
65 
     | 
    
         | 
| 
       81 
66 
     | 
    
         
             
                  begin
         
     | 
| 
         @@ -100,20 +85,12 @@ describe SimpleDeploy::CLI::Deploy do 
     | 
|
| 
       100 
85 
     | 
    
         | 
| 
       101 
86 
     | 
    
         
             
                  SimpleDeploy::Notifier.should_receive(:new).
         
     | 
| 
       102 
87 
     | 
    
         
             
                                      with(:stack_name  => 'my_stack',
         
     | 
| 
       103 
     | 
    
         
            -
                                           :environment => 'my_env' 
     | 
| 
       104 
     | 
    
         
            -
                                           :logger      => @logger).
         
     | 
| 
      
 88 
     | 
    
         
            +
                                           :environment => 'my_env').
         
     | 
| 
       105 
89 
     | 
    
         
             
                                      and_return(@notifier)
         
     | 
| 
       106 
90 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
                   
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                                           :name        => 'my_stack',
         
     | 
| 
       111 
     | 
    
         
            -
                                           :internal    => false).
         
     | 
| 
       112 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                  @stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(true)
         
     | 
| 
       115 
     | 
    
         
            -
                  @stack.should_receive(:wait_for_stable)
         
     | 
| 
       116 
     | 
    
         
            -
                  @stack.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @stack_mock.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(true)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @stack_mock.should_receive(:wait_for_stable)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @stack_mock.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
       117 
94 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_start_message)
         
     | 
| 
       118 
95 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_complete_message)
         
     | 
| 
       119 
96 
     | 
    
         | 
| 
         @@ -135,20 +112,12 @@ describe SimpleDeploy::CLI::Deploy do 
     | 
|
| 
       135 
112 
     | 
    
         | 
| 
       136 
113 
     | 
    
         
             
                  SimpleDeploy::Notifier.should_receive(:new).
         
     | 
| 
       137 
114 
     | 
    
         
             
                                      with(:stack_name  => 'my_stack',
         
     | 
| 
       138 
     | 
    
         
            -
                                           :environment => 'my_env' 
     | 
| 
       139 
     | 
    
         
            -
                                           :logger      => @logger).
         
     | 
| 
      
 115 
     | 
    
         
            +
                                           :environment => 'my_env').
         
     | 
| 
       140 
116 
     | 
    
         
             
                                      and_return(@notifier)
         
     | 
| 
       141 
117 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
                   
     | 
| 
       143 
     | 
    
         
            -
                                      with(:environment => 'my_env',
         
     | 
| 
       144 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       145 
     | 
    
         
            -
                                           :name        => 'my_stack',
         
     | 
| 
       146 
     | 
    
         
            -
                                           :internal    => false).
         
     | 
| 
       147 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                  @stack.should_receive(:update).with(hash_including(:force => true,
         
     | 
| 
      
 118 
     | 
    
         
            +
                  @stack_mock.should_receive(:update).with(hash_including(:force => true,
         
     | 
| 
       150 
119 
     | 
    
         
             
                                                                     :attributes => [{'foo' => 'bah'}])).and_return(false)
         
     | 
| 
       151 
     | 
    
         
            -
                  @ 
     | 
| 
      
 120 
     | 
    
         
            +
                  @stack_mock.should_receive(:wait_for_stable)
         
     | 
| 
       152 
121 
     | 
    
         | 
| 
       153 
122 
     | 
    
         
             
                  begin
         
     | 
| 
       154 
123 
     | 
    
         
             
                    subject.deploy
         
     | 
| 
         @@ -172,20 +141,12 @@ describe SimpleDeploy::CLI::Deploy do 
     | 
|
| 
       172 
141 
     | 
    
         | 
| 
       173 
142 
     | 
    
         
             
                  SimpleDeploy::Notifier.should_receive(:new).
         
     | 
| 
       174 
143 
     | 
    
         
             
                                      with(:stack_name  => 'my_stack',
         
     | 
| 
       175 
     | 
    
         
            -
                                           :environment => 'my_env' 
     | 
| 
       176 
     | 
    
         
            -
                                           :logger      => @logger).
         
     | 
| 
      
 144 
     | 
    
         
            +
                                           :environment => 'my_env').
         
     | 
| 
       177 
145 
     | 
    
         
             
                                      and_return(@notifier)
         
     | 
| 
       178 
146 
     | 
    
         | 
| 
       179 
     | 
    
         
            -
                   
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
                                           :name        => 'my_stack',
         
     | 
| 
       183 
     | 
    
         
            -
                                           :internal    => false).
         
     | 
| 
       184 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
                  @stack.should_not_receive(:update)
         
     | 
| 
       187 
     | 
    
         
            -
                  @stack.should_receive(:wait_for_stable)
         
     | 
| 
       188 
     | 
    
         
            -
                  @stack.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
      
 147 
     | 
    
         
            +
                  @stack_mock.should_not_receive(:update)
         
     | 
| 
      
 148 
     | 
    
         
            +
                  @stack_mock.should_receive(:wait_for_stable)
         
     | 
| 
      
 149 
     | 
    
         
            +
                  @stack_mock.should_receive(:deploy).with(true).and_return(true)
         
     | 
| 
       189 
150 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_start_message)
         
     | 
| 
       190 
151 
     | 
    
         
             
                  @notifier.should_receive(:send_deployment_complete_message)
         
     | 
| 
       191 
152 
     | 
    
         | 
    
        data/spec/cli/destroy_spec.rb
    CHANGED
    
    | 
         @@ -3,21 +3,17 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            describe SimpleDeploy::CLI::Destroy do
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 8 
     | 
    
         
            +
              include_context 'stubbed stack', :name        => 'my_stack',
         
     | 
| 
      
 9 
     | 
    
         
            +
                                               :environment => 'my_env'
         
     | 
| 
       6 
10 
     | 
    
         | 
| 
       7 
11 
     | 
    
         
             
              describe 'destroy' do
         
     | 
| 
       8 
12 
     | 
    
         
             
                before do
         
     | 
| 
       9 
     | 
    
         
            -
                  @config  = mock 'config'
         
     | 
| 
       10 
     | 
    
         
            -
                  @logger  = stub 'logger', 'info' => 'true'
         
     | 
| 
       11 
13 
     | 
    
         
             
                  @options = { :environment => 'my_env',
         
     | 
| 
       12 
14 
     | 
    
         
             
                               :log_level   => 'debug',
         
     | 
| 
       13 
15 
     | 
    
         
             
                               :name        => 'my_stack' }
         
     | 
| 
       14 
     | 
    
         
            -
                  @ 
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  SimpleDeploy::Config.stub(:new).and_return(@config)
         
     | 
| 
       17 
     | 
    
         
            -
                  @config.should_receive(:environment).with('my_env').and_return(@config)
         
     | 
| 
       18 
     | 
    
         
            -
                  SimpleDeploy::SimpleDeployLogger.should_receive(:new).
         
     | 
| 
       19 
     | 
    
         
            -
                                                   with(:log_level => 'debug').
         
     | 
| 
       20 
     | 
    
         
            -
                                                   and_return(@logger)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @stack_mock.stub(:attributes).and_return({})
         
     | 
| 
       21 
17 
     | 
    
         
             
                end
         
     | 
| 
       22 
18 
     | 
    
         | 
| 
       23 
19 
     | 
    
         
             
                it "should exit with 0" do
         
     | 
| 
         @@ -26,14 +22,7 @@ describe SimpleDeploy::CLI::Destroy do 
     | 
|
| 
       26 
22 
     | 
    
         
             
                               :required => [:environment, :name])
         
     | 
| 
       27 
23 
     | 
    
         
             
                  Trollop.stub(:options).and_return(@options)
         
     | 
| 
       28 
24 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                  @ 
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       32 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       33 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       34 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       35 
     | 
    
         
            -
                                           :name        => 'my_stack').
         
     | 
| 
       36 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @stack_mock.should_receive(:destroy).and_return(true)
         
     | 
| 
       37 
26 
     | 
    
         | 
| 
       38 
27 
     | 
    
         
             
                  begin
         
     | 
| 
       39 
28 
     | 
    
         
             
                    subject.destroy
         
     | 
| 
         @@ -48,14 +37,7 @@ describe SimpleDeploy::CLI::Destroy do 
     | 
|
| 
       48 
37 
     | 
    
         
             
                               :required => [:environment, :name])
         
     | 
| 
       49 
38 
     | 
    
         
             
                  Trollop.stub(:options).and_return(@options)
         
     | 
| 
       50 
39 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                  @ 
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       54 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       55 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       56 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       57 
     | 
    
         
            -
                                           :name        => 'my_stack').
         
     | 
| 
       58 
     | 
    
         
            -
                                      and_return(@stack)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @stack_mock.should_receive(:destroy).and_return(false)
         
     | 
| 
       59 
41 
     | 
    
         | 
| 
       60 
42 
     | 
    
         
             
                  begin
         
     | 
| 
       61 
43 
     | 
    
         
             
                    subject.destroy
         
     | 
    
        data/spec/cli/outputs_spec.rb
    CHANGED
    
    | 
         @@ -2,35 +2,30 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            describe SimpleDeploy::CLI::Outputs do
         
     | 
| 
      
 5 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'stubbed stack', :name        => 'mytest',
         
     | 
| 
      
 8 
     | 
    
         
            +
                                               :environment => 'test'
         
     | 
| 
       5 
9 
     | 
    
         | 
| 
       6 
10 
     | 
    
         
             
              before do
         
     | 
| 
       7 
     | 
    
         
            -
                @config_object = mock 'config'
         
     | 
| 
       8 
11 
     | 
    
         
             
                @config_env    = mock 'environment config'
         
     | 
| 
       9 
     | 
    
         
            -
                @stack         = mock 'stack'
         
     | 
| 
       10 
     | 
    
         
            -
                @logger        = stub 'logger'
         
     | 
| 
       11 
12 
     | 
    
         
             
                @options       = { :environment => 'test',
         
     | 
| 
       12 
13 
     | 
    
         
             
                                   :log_level   => 'info',
         
     | 
| 
       13 
14 
     | 
    
         
             
                                   :name        => 'mytest' }
         
     | 
| 
       14 
15 
     | 
    
         
             
                @data          = [{ 'OutputKey' => 'key1', 'OutputValue' => 'value1' },
         
     | 
| 
       15 
16 
     | 
    
         
             
                                  { 'OutputKey' => 'key2', 'OutputValue' => 'value2' }]
         
     | 
| 
       16 
17 
     | 
    
         
             
                Trollop.stub :options => @options
         
     | 
| 
       17 
     | 
    
         
            -
                @ 
     | 
| 
       18 
     | 
    
         
            -
                SimpleDeploy 
     | 
| 
       19 
     | 
    
         
            -
                 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                                                 and_return @logger
         
     | 
| 
       22 
     | 
    
         
            -
                SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       23 
     | 
    
         
            -
                                    with(:environment => 'test',
         
     | 
| 
       24 
     | 
    
         
            -
                                         :name        => 'mytest',
         
     | 
| 
       25 
     | 
    
         
            -
                                         :config      => @config_env,
         
     | 
| 
       26 
     | 
    
         
            -
                                         :logger      => @logger).
         
     | 
| 
       27 
     | 
    
         
            -
                                    and_return(@stack)
         
     | 
| 
       28 
     | 
    
         
            -
                @stack.stub :outputs => @data
         
     | 
| 
       29 
     | 
    
         
            -
                @config_object.should_receive(:environment).with('test').
         
     | 
| 
       30 
     | 
    
         
            -
                                                            and_return @config_env
         
     | 
| 
      
 18 
     | 
    
         
            +
                @config_mock.stub(:environments => { 'test' => 'data' })
         
     | 
| 
      
 19 
     | 
    
         
            +
                SimpleDeploy.stub(:environments).and_return(@config_env)
         
     | 
| 
      
 20 
     | 
    
         
            +
                @config_env.should_receive(:keys).and_return(['test'])
         
     | 
| 
      
 21 
     | 
    
         
            +
                @stack_mock.stub(:outputs).and_return(@data)
         
     | 
| 
       31 
22 
     | 
    
         
             
                @outputs = SimpleDeploy::CLI::Outputs.new
         
     | 
| 
       32 
23 
     | 
    
         
             
              end
         
     | 
| 
       33 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
              after do
         
     | 
| 
      
 26 
     | 
    
         
            +
                SimpleDeploy.release_config
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       34 
29 
     | 
    
         
             
              it "should successfully return the show command with default values" do
         
     | 
| 
       35 
30 
     | 
    
         
             
                @outputs.should_receive(:puts).with('key1: value1')
         
     | 
| 
       36 
31 
     | 
    
         
             
                @outputs.should_receive(:puts).with('key2: value2')
         
     | 
    
        data/spec/cli/protect_spec.rb
    CHANGED
    
    | 
         @@ -3,127 +3,89 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'simple_deploy/cli'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            describe SimpleDeploy::CLI::Protect do
         
     | 
| 
      
 6 
     | 
    
         
            +
              include_context 'cli config'
         
     | 
| 
      
 7 
     | 
    
         
            +
              include_context 'double stubbed logger'
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
              describe 'protect' do
         
     | 
| 
       8 
10 
     | 
    
         
             
                before do
         
     | 
| 
       9 
     | 
    
         
            -
                  @ 
     | 
| 
       10 
     | 
    
         
            -
                  @logger  = stub 'logger', 'info' => 'true'
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  SimpleDeploy::Config.stub(:new).and_return(@config_mock)
         
     | 
| 
       13 
     | 
    
         
            -
                  @config_mock.should_receive(:environment).with('my_env').and_return(@config)
         
     | 
| 
       14 
     | 
    
         
            -
                  SimpleDeploy::SimpleDeployLogger.should_receive(:new).
         
     | 
| 
       15 
     | 
    
         
            -
                                                   with(:log_level => 'debug').
         
     | 
| 
       16 
     | 
    
         
            -
                                                   and_return(@logger)
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                it "should enable protection" do
         
     | 
| 
       20 
     | 
    
         
            -
                  options = { :environment => 'my_env',
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @options = { :environment => 'my_env',
         
     | 
| 
       21 
12 
     | 
    
         
             
                              :log_level   => 'debug',
         
     | 
| 
       22 
     | 
    
         
            -
                              :name        => [' 
     | 
| 
      
 13 
     | 
    
         
            +
                              :name        => ['my_stack1'],
         
     | 
| 
       23 
14 
     | 
    
         
             
                              :protection  => 'on' }
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  subject.should_receive(:valid_options?).
         
     | 
| 
       26 
     | 
    
         
            -
                          with(:provided => options,
         
     | 
| 
       27 
     | 
    
         
            -
                               :required => [:environment, :name])
         
     | 
| 
       28 
     | 
    
         
            -
                  Trollop.stub(:options).and_return(options)
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                  stack   = stub :attributes => { 'protection' => 'on' }
         
     | 
| 
       31 
     | 
    
         
            -
                  stack.should_receive(:update).with(hash_including(:attributes => [{ 'protection' => 'on' }]))
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       34 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       35 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       36 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       37 
     | 
    
         
            -
                                           :name        => 'my_stack').
         
     | 
| 
       38 
     | 
    
         
            -
                                      and_return(stack)
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  subject.protect
         
     | 
| 
       41 
15 
     | 
    
         
             
                end
         
     | 
| 
       42 
16 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                 
     | 
| 
       44 
     | 
    
         
            -
                   
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                context "single stack" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  include_context 'received stack array', 'my_stack', 'my_env', 1
         
     | 
| 
      
 19 
     | 
    
         
            +
                  
         
     | 
| 
      
 20 
     | 
    
         
            +
                  it "should enable protection" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                    subject.should_receive(:valid_options?).
         
     | 
| 
      
 22 
     | 
    
         
            +
                            with(:provided => @options,
         
     | 
| 
      
 23 
     | 
    
         
            +
                                 :required => [:environment, :name])
         
     | 
| 
      
 24 
     | 
    
         
            +
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
       48 
25 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                  Trollop.stub(:options).and_return(options)
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                  stack   = stub :attributes => { 'protection' => 'on' }
         
     | 
| 
       55 
     | 
    
         
            -
                  stack.should_receive(:update).twice.with(hash_including(:attributes => [{ 'protection' => 'on' }]))
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       58 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       59 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       60 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       61 
     | 
    
         
            -
                                           :name        => 'my_stack1').
         
     | 
| 
       62 
     | 
    
         
            -
                                      and_return(stack)
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  SimpleDeploy::Stack.should_receive(:new).
         
     | 
| 
       65 
     | 
    
         
            -
                                      with(:config      => @config,
         
     | 
| 
       66 
     | 
    
         
            -
                                           :environment => 'my_env',
         
     | 
| 
       67 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       68 
     | 
    
         
            -
                                           :name        => 'my_stack2').
         
     | 
| 
       69 
     | 
    
         
            -
                                      and_return(stack)
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                  subject.protect
         
     | 
| 
       72 
     | 
    
         
            -
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @stack_mock1.stub(:attributes).and_return('protection' => 'on')
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @stack_mock1.should_receive(:update).with(
         
     | 
| 
      
 28 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'on' }]))
         
     | 
| 
       73 
29 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                   
     | 
| 
       76 
     | 
    
         
            -
                              :log_level   => 'debug',
         
     | 
| 
       77 
     | 
    
         
            -
                              :name        => ['my_stack'],
         
     | 
| 
       78 
     | 
    
         
            -
                              :protection  => 'off' }
         
     | 
| 
      
 30 
     | 
    
         
            +
                    subject.protect
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
       79 
32 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
                   
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                               :required => [:environment, :name])
         
     | 
| 
       83 
     | 
    
         
            -
                  Trollop.stub(:options).and_return(options)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  it "should disable protection" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @options[:protection]= 'off'
         
     | 
| 
       84 
35 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                    subject.should_receive(:valid_options?).
         
     | 
| 
      
 37 
     | 
    
         
            +
                            with(:provided => @options,
         
     | 
| 
      
 38 
     | 
    
         
            +
                                 :required => [:environment, :name])
         
     | 
| 
      
 39 
     | 
    
         
            +
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
       87 
40 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                                           :logger      => @logger,
         
     | 
| 
       92 
     | 
    
         
            -
                                           :name        => 'my_stack').
         
     | 
| 
       93 
     | 
    
         
            -
                                      and_return(stack)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    @stack_mock1.stub(:attributes).and_return('protection' => 'off')
         
     | 
| 
      
 42 
     | 
    
         
            +
                    @stack_mock1.should_receive(:update).with(
         
     | 
| 
      
 43 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'off' }]))
         
     | 
| 
       94 
44 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
                    subject.protect
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
       96 
47 
     | 
    
         
             
                end
         
     | 
| 
       97 
48 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
                 
     | 
| 
       99 
     | 
    
         
            -
                   
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                   
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
                context "multiple stacks" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  include_context 'received stack array', 'my_stack', 'my_env', 2
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  it "should enable protection" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                    @options[:name] = ['my_stack1', 'my_stack2']
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                    subject.should_receive(:valid_options?).
         
     | 
| 
      
 56 
     | 
    
         
            +
                            with(:provided => @options,
         
     | 
| 
      
 57 
     | 
    
         
            +
                                 :required => [:environment, :name])
         
     | 
| 
      
 58 
     | 
    
         
            +
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    @stack_mock1.stub(:attributes).and_return('protection' => 'on')
         
     | 
| 
      
 61 
     | 
    
         
            +
                    @stack_mock1.should_receive(:update).with(
         
     | 
| 
      
 62 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'on' }]))
         
     | 
| 
      
 63 
     | 
    
         
            +
                    @stack_mock2.stub(:attributes).and_return('protection' => 'on')
         
     | 
| 
      
 64 
     | 
    
         
            +
                    @stack_mock2.should_receive(:update).with(
         
     | 
| 
      
 65 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'on' }]))
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    subject.protect
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                  it "should disable protection" do
         
     | 
| 
      
 71 
     | 
    
         
            +
                    @options[:name] = ['my_stack1', 'my_stack2']
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @options[:protection]= 'off'
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    subject.should_receive(:valid_options?).
         
     | 
| 
      
 75 
     | 
    
         
            +
                            with(:provided => @options,
         
     | 
| 
      
 76 
     | 
    
         
            +
                                 :required => [:environment, :name])
         
     | 
| 
      
 77 
     | 
    
         
            +
                    Trollop.stub(:options).and_return(@options)
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    @stack_mock1.stub(:attributes).and_return('protection' => 'off')
         
     | 
| 
      
 80 
     | 
    
         
            +
                    @stack_mock1.should_receive(:update).with(
         
     | 
| 
      
 81 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'off' }]))
         
     | 
| 
      
 82 
     | 
    
         
            +
                    @stack_mock2.stub(:attributes).and_return('protection' => 'off')
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @stack_mock2.should_receive(:update).with(
         
     | 
| 
      
 84 
     | 
    
         
            +
                      hash_including(:attributes => [{ 'protection' => 'off' }]))
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                    subject.protect
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
       127 
88 
     | 
    
         
             
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
       128 
90 
     | 
    
         
             
              end 
         
     | 
| 
       129 
91 
     | 
    
         
             
            end
         
     |