simple_deploy 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGELOG.md +6 -0
  3. data/lib/simple_deploy/aws/cloud_formation/error.rb +32 -0
  4. data/lib/simple_deploy/aws/cloud_formation.rb +76 -0
  5. data/lib/simple_deploy/aws/instance_reader.rb +59 -0
  6. data/lib/simple_deploy/aws/simpledb.rb +52 -0
  7. data/lib/simple_deploy/aws.rb +4 -0
  8. data/lib/simple_deploy/cli/attributes.rb +7 -18
  9. data/lib/simple_deploy/cli/clone.rb +9 -19
  10. data/lib/simple_deploy/cli/create.rb +5 -14
  11. data/lib/simple_deploy/cli/deploy.rb +8 -11
  12. data/lib/simple_deploy/cli/destroy.rb +4 -10
  13. data/lib/simple_deploy/cli/environments.rb +1 -1
  14. data/lib/simple_deploy/cli/events.rb +5 -11
  15. data/lib/simple_deploy/cli/execute.rb +6 -9
  16. data/lib/simple_deploy/cli/instances.rb +4 -9
  17. data/lib/simple_deploy/cli/list.rb +5 -10
  18. data/lib/simple_deploy/cli/outputs.rb +5 -11
  19. data/lib/simple_deploy/cli/parameters.rb +5 -11
  20. data/lib/simple_deploy/cli/protect.rb +5 -10
  21. data/lib/simple_deploy/cli/resources.rb +5 -11
  22. data/lib/simple_deploy/cli/shared.rb +6 -6
  23. data/lib/simple_deploy/cli/status.rb +5 -11
  24. data/lib/simple_deploy/cli/template.rb +8 -13
  25. data/lib/simple_deploy/cli/update.rb +6 -10
  26. data/lib/simple_deploy/configuration.rb +102 -0
  27. data/lib/simple_deploy/entry.rb +71 -0
  28. data/lib/simple_deploy/entry_lister.rb +30 -0
  29. data/lib/simple_deploy/exceptions.rb +8 -0
  30. data/lib/simple_deploy/misc/attribute_merger.rb +2 -5
  31. data/lib/simple_deploy/notifier/campfire.rb +15 -12
  32. data/lib/simple_deploy/notifier.rb +6 -11
  33. data/lib/simple_deploy/stack/deployment/status.rb +5 -3
  34. data/lib/simple_deploy/stack/deployment.rb +8 -10
  35. data/lib/simple_deploy/stack/execute.rb +2 -3
  36. data/lib/simple_deploy/stack/output_mapper.rb +1 -4
  37. data/lib/simple_deploy/stack/ssh.rb +4 -4
  38. data/lib/simple_deploy/stack/{stack_attribute_formater.rb → stack_attribute_formatter.rb} +4 -6
  39. data/lib/simple_deploy/stack/stack_creator.rb +46 -0
  40. data/lib/simple_deploy/stack/stack_destroyer.rb +19 -0
  41. data/lib/simple_deploy/stack/stack_formatter.rb +25 -0
  42. data/lib/simple_deploy/stack/stack_lister.rb +18 -0
  43. data/lib/simple_deploy/stack/stack_reader.rb +56 -0
  44. data/lib/simple_deploy/stack/stack_updater.rb +67 -0
  45. data/lib/simple_deploy/stack/status.rb +53 -0
  46. data/lib/simple_deploy/stack.rb +89 -37
  47. data/lib/simple_deploy/version.rb +1 -1
  48. data/lib/simple_deploy.rb +31 -1
  49. data/simple_deploy.gemspec +6 -3
  50. data/spec/aws/cloud_formation/error_spec.rb +50 -0
  51. data/spec/aws/cloud_formation_spec.rb +207 -0
  52. data/spec/aws/instance_reader_spec.rb +96 -0
  53. data/spec/aws/simpledb_spec.rb +89 -0
  54. data/spec/cli/attributes_spec.rb +5 -15
  55. data/spec/cli/clone_spec.rb +14 -27
  56. data/spec/cli/create_spec.rb +11 -18
  57. data/spec/cli/deploy_spec.rb +24 -63
  58. data/spec/cli/destroy_spec.rb +7 -25
  59. data/spec/cli/outputs_spec.rb +12 -17
  60. data/spec/cli/protect_spec.rb +68 -106
  61. data/spec/cli/shared_spec.rb +12 -15
  62. data/spec/cli/update_spec.rb +9 -27
  63. data/spec/config_spec.rb +47 -14
  64. data/spec/contexts/config_contexts.rb +28 -0
  65. data/spec/contexts/logger_contexts.rb +9 -0
  66. data/spec/contexts/stack_contexts.rb +40 -0
  67. data/spec/entry_lister_spec.rb +31 -0
  68. data/spec/entry_spec.rb +86 -0
  69. data/spec/misc/attribute_merger_spec.rb +3 -8
  70. data/spec/notifier/campfire_spec.rb +21 -61
  71. data/spec/notifier_spec.rb +18 -40
  72. data/spec/spec_helper.rb +10 -0
  73. data/spec/stack/deployment/status_spec.rb +13 -13
  74. data/spec/stack/deployment_spec.rb +26 -21
  75. data/spec/stack/execute_spec.rb +7 -3
  76. data/spec/stack/output_mapper_spec.rb +3 -15
  77. data/spec/stack/ssh_spec.rb +14 -13
  78. data/spec/stack/{stack_attribute_formater_spec.rb → stack_attribute_formatter_spec.rb} +19 -16
  79. data/spec/stack/stack_creator_spec.rb +46 -0
  80. data/spec/stack/stack_destroyer_spec.rb +18 -0
  81. data/spec/stack/stack_formatter_spec.rb +37 -0
  82. data/spec/stack/stack_lister_spec.rb +17 -0
  83. data/spec/stack/stack_reader_spec.rb +81 -0
  84. data/spec/stack/stack_updater_spec.rb +79 -0
  85. data/spec/stack/status_spec.rb +106 -0
  86. data/spec/stack_spec.rb +160 -133
  87. metadata +112 -19
  88. data/.rvmrc +0 -1
  89. data/lib/simple_deploy/config.rb +0 -87
@@ -1,23 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SimpleDeploy::Misc::AttributeMerger do
4
+ include_context 'stubbed config'
4
5
 
5
6
  before do
6
- @config_mock = mock 'config'
7
7
  @mapper_mock = mock 'mapper'
8
- @logger_stub = stub 'logger', :info => true
9
8
 
10
9
  @stacks = ['stack1', 'stack2']
11
- @options = { :config => @config_mock,
12
- :environment => 'default',
13
- :logger => @logger_stub,
10
+ @options = { :environment => 'default',
14
11
  :attributes => [ { 'attrib1' => 'val1' } ],
15
12
  :input_stacks => @stacks,
16
13
  :template => '/tmp/file.json' }
17
14
  SimpleDeploy::Stack::OutputMapper.should_receive(:new).
18
- with(:environment => @options[:environment],
19
- :config => @options[:config],
20
- :logger => @options[:logger]).
15
+ with(:environment => @options[:environment]).
21
16
  and_return @mapper_mock
22
17
  @merger = SimpleDeploy::Misc::AttributeMerger.new
23
18
  end
@@ -1,57 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SimpleDeploy do
3
+ describe SimpleDeploy::Notifier::Campfire do
4
+ include_context 'stubbed config'
5
+ include_context 'double stubbed logger'
6
+ include_context 'stubbed stack', :name => 'my_stack',
7
+ :environment => 'my_env'
8
+
9
+ before do
10
+ @comms_mock = mock 'Campfire communications'
11
+
12
+ @room1_mock = mock 'Esbit room1', :id => 1, :name => 'Room 1'
13
+ @room2_mock = mock 'Esbit room2', :id => 2, :name => 'Room 2'
14
+ @comms_mock.stub(:rooms).and_return([@room1_mock, @room2_mock])
15
+ end
4
16
 
5
17
  describe "with all required configurations" do
6
18
  before do
7
19
  config = { 'campfire' => { 'token' => 'tkn' } }
8
-
9
- @config_mock = mock 'config mock'
10
- @stack_mock = mock 'stack'
11
- @logger_mock = mock 'logger mock'
12
- @tinder_mock = mock 'tinder'
13
- @config_mock.should_receive(:logger).and_return @logger_mock
14
20
  @config_mock.should_receive(:notifications).and_return config
15
- @config_mock.should_receive(:environment).and_return 'env_config'
16
- Stackster::Stack.should_receive(:new).
17
- with(:environment => 'test',
18
- :name => 'stack_name',
19
- :config => 'env_config',
20
- :logger => @logger_mock).
21
- and_return @stack_mock
22
21
 
23
- Tinder::Campfire.should_receive(:new).
24
- with("subdom", { :token=>"tkn", :ssl_options=> { :verify => false } }).and_return @tinder_mock
22
+ Esbit::Campfire.should_receive(:new).with("subdom", "tkn").
23
+ and_return @comms_mock
25
24
  @stack_mock.should_receive(:attributes).
26
25
  and_return( 'campfire_room_ids' => '1,2',
27
26
  'campfire_subdomain' => 'subdom' )
28
- @logger_mock.should_receive(:debug).
29
- with "Campfire subdomain 'subdom'."
30
- @logger_mock.should_receive(:debug).
31
- with "Campfire room ids '1,2'."
32
27
  @campfire = SimpleDeploy::Notifier::Campfire.new :stack_name => 'stack_name',
33
- :environment => 'test',
34
- :config => @config_mock
28
+ :environment => 'test'
35
29
 
36
30
  end
37
31
 
38
32
  it "should send a message to campfire rooms" do
39
- room1_mock = mock 'tinder'
40
- room2_mock = mock 'tinder'
41
- @tinder_mock.should_receive(:find_room_by_id).with(1).
42
- and_return room1_mock
43
- @tinder_mock.should_receive(:find_room_by_id).with(2).
44
- and_return room2_mock
45
- @logger_mock.should_receive(:debug).
46
- with "Sending notification to Campfire room 1."
47
- @logger_mock.should_receive(:debug).
48
- with "Sending notification to Campfire room 2."
49
- @logger_mock.should_receive(:info).
50
- with "Sending Campfire notifications."
51
- @logger_mock.should_receive(:info).
52
- with "Campfire notifications complete."
53
- room1_mock.should_receive(:speak).with :message => "heh you guys!"
54
- room2_mock.should_receive(:speak).with :message => "heh you guys!"
33
+
34
+ @room1_mock.should_receive(:say).with :message => "heh you guys!"
35
+ @room2_mock.should_receive(:say).with :message => "heh you guys!"
36
+
55
37
  @campfire.send(:message => 'heh you guys!')
56
38
  end
57
39
  end
@@ -60,32 +42,10 @@ describe SimpleDeploy do
60
42
  before do
61
43
  config = nil
62
44
 
63
- @config_mock = mock 'config mock'
64
- @stack_mock = mock 'stack'
65
- @logger_mock = mock 'logger mock'
66
- @tinder_mock = mock 'tinder'
67
- @config_mock.should_receive(:logger).and_return @logger_mock
68
- @config_mock.should_receive(:environment).and_return 'env_config'
69
- Stackster::Stack.should_receive(:new).
70
- with(:environment => 'test',
71
- :name => 'stack_name',
72
- :config => 'env_config',
73
- :logger => @logger_mock).
74
- and_return @stack_mock
75
-
76
45
  @stack_mock.should_receive(:attributes).
77
46
  and_return({})
78
- @logger_mock.should_receive(:debug).
79
- with "Campfire subdomain ''."
80
- @logger_mock.should_receive(:debug).
81
- with "Campfire room ids ''."
82
- @logger_mock.should_receive(:info).
83
- with "Sending Campfire notifications."
84
- @logger_mock.should_receive(:info).
85
- with "Campfire notifications complete."
86
47
  @campfire = SimpleDeploy::Notifier::Campfire.new :stack_name => 'stack_name',
87
- :environment => 'test',
88
- :config => @config_mock
48
+ :environment => 'test'
89
49
  end
90
50
 
91
51
  it "should not blow up if campfire_subdom & campfire_room_ids are not present" do
@@ -1,29 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SimpleDeploy do
3
+ describe SimpleDeploy::Notifier do
4
+ include_context 'stubbed config'
5
+ include_context 'stubbed stack', :name => 'stack_name',
6
+ :environment => 'test'
4
7
 
5
8
  describe "with valid settings" do
6
9
  before do
7
- @config_mock = mock 'config mock'
8
- @logger_mock = mock 'logger mock'
9
- SimpleDeploy::Config.should_receive(:new).
10
- with(:logger => @logger_mock).
11
- and_return @config_mock
12
-
13
10
  @config_mock.should_receive(:notifications).
14
11
  exactly(1).times.
15
12
  and_return({ 'campfire' => 'settings' })
16
- @config_mock.should_receive(:logger).
17
- and_return @logger_mock
18
13
  @notifier = SimpleDeploy::Notifier.new :stack_name => 'stack_name',
19
- :environment => 'test',
20
- :logger => @logger_mock
14
+ :environment => 'test'
15
+ end
16
+
17
+ after do
18
+ SimpleDeploy.release_config
21
19
  end
22
20
 
23
21
  it "should support a basic start message" do
24
22
  campfire_mock = mock 'campfire mock'
25
23
 
26
- @config_mock.should_receive(:region).with('test').and_return('us-west-1')
24
+ @config_mock.stub(:region).and_return('us-west-1')
27
25
 
28
26
  SimpleDeploy::Notifier::Campfire.should_receive(:new).and_return campfire_mock
29
27
  campfire_mock.should_receive(:send).with "Deployment to stack_name in us-west-1 started."
@@ -32,24 +30,14 @@ describe SimpleDeploy do
32
30
  end
33
31
 
34
32
  it "should include the github app & chef links in the completed message" do
35
- stack_mock = mock 'stack'
36
33
  campfire_mock = mock 'campfire mock'
37
34
  environment_mock = mock 'environment mock'
38
- @config_mock.should_receive(:environment).
39
- with('test').
40
- and_return environment_mock
41
- @config_mock.should_receive(:region).with('test').and_return('us-west-1')
42
- Stackster::Stack.should_receive(:new).
43
- with(:environment => 'test',
44
- :name => 'stack_name',
45
- :config => environment_mock,
46
- :logger => @logger_mock).
47
- and_return stack_mock
48
- stack_mock.should_receive(:attributes).
49
- and_return({ 'app_github_url' => 'http://github.com/user/app',
50
- 'chef_repo_github_url' => 'http://github.com/user/chef_repo',
51
- 'app' => 'appsha',
52
- 'chef_repo' => 'chefsha' })
35
+ @config_mock.stub(:region).and_return('us-west-1')
36
+ @stack_mock.should_receive(:attributes).
37
+ and_return({ 'app_github_url' => 'http://github.com/user/app',
38
+ 'chef_repo_github_url' => 'http://github.com/user/chef_repo',
39
+ 'app' => 'appsha',
40
+ 'chef_repo' => 'chefsha' })
53
41
  SimpleDeploy::Notifier::Campfire.should_receive(:new).
54
42
  and_return campfire_mock
55
43
  campfire_mock.should_receive(:send).
@@ -61,8 +49,7 @@ describe SimpleDeploy do
61
49
  campfire_mock = mock 'campfire mock'
62
50
  SimpleDeploy::Notifier::Campfire.should_receive(:new).
63
51
  with(:environment => 'test',
64
- :stack_name => 'stack_name',
65
- :config => @config_mock).
52
+ :stack_name => 'stack_name').
66
53
  and_return campfire_mock
67
54
  campfire_mock.should_receive(:send).with 'heh you guys!'
68
55
  @notifier.send 'heh you guys!'
@@ -71,19 +58,10 @@ describe SimpleDeploy do
71
58
  end
72
59
 
73
60
  it "should not blow up if the notification section is missing" do
74
- @config_mock = mock 'config mock'
75
- @logger_mock = mock 'logger mock'
76
- SimpleDeploy::Config.should_receive(:new).
77
- with(:logger => @logger_mock).
78
- and_return @config_mock
79
-
80
61
  @config_mock.should_receive(:notifications).
81
62
  and_return nil
82
- @config_mock.should_receive(:logger).
83
- and_return @logger_mock
84
63
  @notifier = SimpleDeploy::Notifier.new :stack_name => 'stack_name',
85
- :environment => 'test',
86
- :logger => @logger_mock
64
+ :environment => 'test'
87
65
  @notifier.send 'heh you guys!'
88
66
  end
89
67
 
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,19 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'fakefs/safe'
4
+ require 'timecop'
5
+
6
+ require 'simplecov'
7
+ SimpleCov.start do
8
+ add_filter "/spec/"
9
+ end
4
10
 
5
11
  require 'simple_deploy'
6
12
 
13
+ ['contexts'].each do |dir|
14
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),dir,'*.rb'))].each {|f| require f}
15
+ end
16
+
7
17
  RSpec.configure do |config|
8
18
  #spec config
9
19
  end
@@ -1,18 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SimpleDeploy do
3
+ describe SimpleDeploy::Stack::Deployment::Status do
4
+ include_context 'stubbed config'
5
+ include_context 'double stubbed logger'
6
+ include_context 'stubbed stack', :name => 'my_stack',
7
+ :environment => 'my_env'
4
8
 
5
9
  before do
6
- @logger_stub = stub 'logger', :debug => true,
7
- :info => true
8
- @config_mock = mock 'config'
9
- @config_mock.stub :logger => @logger_stub
10
- @stack_mock = mock 'stack'
11
-
12
- options = { :config => @config_mock,
13
- :stack => @stack_mock,
10
+ options = { :stack => @stack_mock,
14
11
  :ssh_user => 'user',
15
12
  :name => 'dastack' }
13
+
16
14
  @status = SimpleDeploy::Stack::Deployment::Status.new options
17
15
  end
18
16
 
@@ -43,8 +41,9 @@ describe SimpleDeploy do
43
41
  describe "clear_deployment_lock" do
44
42
  it "should unset deploy in progress if force & deploy in progress" do
45
43
  @stack_mock.stub :attributes => { 'deployment_in_progress' => 'true' }
46
- @stack_mock.should_receive(:update).
47
- with( { :attributes => [ { 'deployment_in_progress' => 'false'} ] })
44
+ @stack_mock.should_receive(:in_progress_update).
45
+ with( { :attributes => [ { 'deployment_in_progress' => 'false' } ],
46
+ :caller => @status })
48
47
  @status.clear_deployment_lock(true)
49
48
  end
50
49
  end
@@ -60,8 +59,9 @@ describe SimpleDeploy do
60
59
 
61
60
  describe "unset_deployment_in_prgoress" do
62
61
  it "clears deployment in progress" do
63
- @stack_mock.should_receive(:update).
64
- with( { :attributes => [ { 'deployment_in_progress' => 'false'} ] })
62
+ @stack_mock.should_receive(:in_progress_update).
63
+ with( { :attributes => [ { 'deployment_in_progress' => 'false'} ],
64
+ :caller => @status })
65
65
  @status.unset_deployment_in_progress
66
66
  end
67
67
  end
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SimpleDeploy do
3
+ describe SimpleDeploy::Stack::Deployment do
4
+ include_context 'stubbed config'
5
+ include_context 'double stubbed logger'
6
+ include_context 'stubbed stack', :name => 'my_stack',
7
+ :environment => 'my_env'
4
8
 
5
9
  before do
6
10
  @attributes = { 'key' => 'val',
@@ -13,22 +17,14 @@ describe SimpleDeploy do
13
17
  'cookbooks' => 'cookbooks',
14
18
  'cookbooks_bucket_prefix' => 'cookbooks_bp',
15
19
  'cookbooks_domain' => 'cookbooks_d' }
16
- @logger_stub = stub 'logger stub'
17
- @logger_stub.stub :debug => 'true',
18
- :info => 'true',
19
- :error => 'true'
20
20
 
21
- @config_mock = mock 'config mock'
22
- @config_mock.stub(:logger) { @logger_stub }
23
21
  @config_mock.stub(:region) { 'test-us-west-1' }
24
22
 
25
- @stack_mock = mock 'stack mock'
26
23
  @stack_mock.stub(:attributes) { @attributes }
27
24
 
28
25
  @status_mock = mock 'status mock'
29
26
 
30
- options = { :config => @config_mock,
31
- :instances => ['1.2.3.4', '4.3.2.1'],
27
+ options = { :instances => ['1.2.3.4', '4.3.2.1'],
32
28
  :environment => 'test-us-west-1',
33
29
  :ssh_user => 'user',
34
30
  :ssh_key => 'key',
@@ -38,13 +34,16 @@ describe SimpleDeploy do
38
34
  @deployment.stub(:sleep) { false }
39
35
  end
40
36
 
37
+ after do
38
+ SimpleDeploy.release_config
39
+ end
40
+
41
41
  context "manage locks" do
42
42
  before do
43
43
  status_options = { :name => 'stack-name',
44
44
  :environment => 'test-us-west-1',
45
- :ssh_user => 'user',
46
- :config => @config_mock,
47
- :stack => @stack_mock }
45
+ :stack => @stack_mock,
46
+ :ssh_user => 'user' }
48
47
  SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
49
48
  with(status_options).
50
49
  and_return @status_mock
@@ -77,24 +76,22 @@ describe SimpleDeploy do
77
76
 
78
77
  status_options = { :name => 'stack-name',
79
78
  :environment => 'test-us-west-1',
80
- :ssh_user => 'user',
81
- :config => @config_mock,
82
- :stack => @stack_mock }
79
+ :stack => @stack_mock,
80
+ :ssh_user => 'user' }
83
81
  SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
84
82
  with(status_options).
85
83
  and_return @status_mock
86
84
  end
87
85
 
88
- describe "when succesful" do
86
+ describe "when successful" do
89
87
  before do
90
88
  @execute_mock = mock "execute"
91
89
  execute_options = { :name => 'stack-name',
92
90
  :environment => 'test-us-west-1',
93
91
  :instances => ['1.2.3.4', '4.3.2.1'],
92
+ :stack => @stack_mock,
94
93
  :ssh_user => 'user',
95
- :ssh_key => 'key',
96
- :config => @config_mock,
97
- :stack => @stack_mock }
94
+ :ssh_key => 'key' }
98
95
  SimpleDeploy::Stack::Execute.should_receive(:new).
99
96
  with(execute_options).
100
97
  and_return @execute_mock
@@ -120,6 +117,8 @@ describe SimpleDeploy do
120
117
  @status_mock.stub :clear_for_deployment? => true
121
118
  @status_mock.should_receive(:set_deployment_in_progress)
122
119
  @status_mock.should_receive(:unset_deployment_in_progress)
120
+ @stack_mock.should_receive(:raw_instances).at_least(:once).and_return(
121
+ [{ 'instancesSet' => [ { 'privateIpAddress' => '10.1.2.3' } ] }])
123
122
  @deployment.execute(false).should be_true
124
123
  end
125
124
 
@@ -129,6 +128,8 @@ describe SimpleDeploy do
129
128
  :clear_for_deployment? => true
130
129
  @status_mock.should_receive(:set_deployment_in_progress)
131
130
  @status_mock.should_receive(:unset_deployment_in_progress)
131
+ @stack_mock.should_receive(:raw_instances).at_least(:once).and_return(
132
+ [{ 'instancesSet' => [ { 'privateIpAddress' => '10.1.2.3' } ] }])
132
133
  @deployment.execute(true).should be_true
133
134
  end
134
135
  end
@@ -143,6 +144,8 @@ describe SimpleDeploy do
143
144
  @status_mock.stub :clear_for_deployment? => true
144
145
  @status_mock.should_receive(:set_deployment_in_progress)
145
146
  @status_mock.should_receive(:unset_deployment_in_progress)
147
+ @stack_mock.should_receive(:raw_instances).at_least(:once).and_return(
148
+ [{ 'instancesSet' => [ { 'privateIpAddress' => '10.1.2.3' } ] }])
146
149
  @deployment.execute(false).should be_true
147
150
  end
148
151
 
@@ -152,12 +155,14 @@ describe SimpleDeploy do
152
155
  :clear_for_deployment? => true
153
156
  @status_mock.should_receive(:set_deployment_in_progress)
154
157
  @status_mock.should_receive(:unset_deployment_in_progress)
158
+ @stack_mock.should_receive(:raw_instances).at_least(:once).and_return(
159
+ [{ 'instancesSet' => [ { 'privateIpAddress' => '10.1.2.3' } ] }])
155
160
  @deployment.execute(true).should be_true
156
161
  end
157
162
  end
158
163
  end
159
164
 
160
- describe "when unsuccesful" do
165
+ describe "when unsuccessful" do
161
166
  it "should not deploy if the stack is not clear to deploy but forced however does not clear in time" do
162
167
  @status_mock.stub(:clear_for_deployment?) { false }
163
168
  @status_mock.should_receive(:clear_deployment_lock).
@@ -1,16 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SimpleDeploy::Stack::Execute do
4
+ include_context 'stubbed config'
5
+ include_context 'double stubbed stack', :name => 'my_stack',
6
+ :environment => 'my_env'
7
+
4
8
  before do
5
9
  @ssh_mock = mock 'ssh'
6
- options = { :config => @config,
7
- :instances => @instances,
10
+ options = { :instances => @instances,
8
11
  :environment => @environment,
9
12
  :ssh_user => @ssh_user,
10
13
  :ssh_key => @ssh_key,
11
- :stack => @stack,
14
+ :stack => @stack_stub,
12
15
  :name => @name }
13
16
 
17
+
14
18
  SimpleDeploy::Stack::SSH.should_receive(:new).
15
19
  with(options).
16
20
  and_return @ssh_mock