automan 2.3.6 → 2.3.7

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +5 -0
  5. data/Rakefile +5 -0
  6. data/automan.gemspec +3 -3
  7. data/lib/automan/base.rb +7 -3
  8. data/lib/automan/beanstalk/deployer.rb +1 -1
  9. data/lib/automan/beanstalk/package.rb +1 -1
  10. data/lib/automan/beanstalk/router.rb +1 -1
  11. data/lib/automan/cli/snapper.rb +29 -29
  12. data/lib/automan/cli/stacker.rb +19 -0
  13. data/lib/automan/cloudformation/launcher.rb +6 -3
  14. data/lib/automan/cloudformation/replacer.rb +1 -1
  15. data/lib/automan/cloudformation/terminator.rb +1 -1
  16. data/lib/automan/ec2/image.rb +3 -3
  17. data/lib/automan/elasticache/router.rb +79 -0
  18. data/lib/automan/mixins/aws_caller.rb +21 -7
  19. data/lib/automan/rds/snapshot.rb +35 -14
  20. data/lib/automan/s3/downloader.rb +10 -1
  21. data/lib/automan/version.rb +1 -1
  22. data/lib/automan.rb +1 -0
  23. data/spec/beanstalk/application_spec.rb +17 -17
  24. data/spec/beanstalk/configuration_spec.rb +24 -24
  25. data/spec/beanstalk/deployer_spec.rb +65 -65
  26. data/spec/beanstalk/router_spec.rb +18 -19
  27. data/spec/beanstalk/terminator_spec.rb +16 -16
  28. data/spec/beanstalk/uploader_spec.rb +13 -13
  29. data/spec/beanstalk/version_spec.rb +8 -10
  30. data/spec/cloudformation/launcher_spec.rb +63 -65
  31. data/spec/cloudformation/replacer_spec.rb +10 -10
  32. data/spec/cloudformation/terminator_spec.rb +23 -23
  33. data/spec/cloudformation/uploader_spec.rb +13 -13
  34. data/spec/ec2/image_spec.rb +55 -55
  35. data/spec/ec2/instance_spec.rb +17 -17
  36. data/spec/elasticache/router_spec.rb +29 -0
  37. data/spec/mixins/aws_caller_spec.rb +9 -9
  38. data/spec/mixins/utils_spec.rb +27 -28
  39. data/spec/rds/snapshot_spec.rb +44 -46
  40. data/templates/stacker/.env.example +14 -0
  41. data/templates/stacker/.gitignore +2 -0
  42. data/templates/stacker/.ruby-gemset.tt +1 -0
  43. data/templates/stacker/.ruby-version +1 -0
  44. data/templates/stacker/Gemfile +4 -0
  45. data/templates/stacker/bin/%app_name%.tt +62 -0
  46. data/templates/stacker/bin/launch_%app_name%.sh.tt +12 -0
  47. metadata +20 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba8bf0ad1d6385060e00b45ab199391f2520c179
4
- data.tar.gz: 54e997202865573a99b4b21005869e79a3374977
3
+ metadata.gz: cfb2258dca674b5f5538a66cf62dfb5b85dba8fa
4
+ data.tar.gz: 1eae94e8cacea86e1bec2ed10220a59e59d6b898
5
5
  SHA512:
6
- metadata.gz: af5c94a4677e630eca5ef7e9d2d4fb47b306b7e7dec0ffaa23246f57009855947b6df6378b31748cb671a7110ed1051b7bbd1b76ac6be857e6f2675f38755713
7
- data.tar.gz: a5ca5a4b040037645bd92541bc4e3c1c6800ca6faa3539b28f6cdd7854b192f2c7159a91a3afc39f62eaac25d37f5f52c450c7d45a700a3152f51e1c58362b91
6
+ metadata.gz: 365b6f670a7cffcc09f049132a7d41b123eeca5f0f1d81147dc39122a13566e3e8b0573f7dc20e24f4096a71c7f875d484347e6e2f8f8235091544e6d69bed67
7
+ data.tar.gz: 7019345e8fbf59862b6dfeb8c7b805df644ed817dffd101fd360f17aab0a949142b3c11faa68b539377bf7dbb43fbeef14c2f09b7eae6df3dc8109a90f0c77b6
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ automan
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.2
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.1.2"
4
+ # uncomment this line if your project needs to run something other than `rake`:
5
+ # script: bundle exec rspec spec
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/automan.gemspec CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
21
21
  spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rspec-core", "~> 2.12.2"
23
- spec.add_development_dependency "rspec-mocks", "~> 2.12.2"
24
- spec.add_development_dependency "rspec-expectations", "~> 2.12.1"
22
+ spec.add_development_dependency "rspec-core", "~> 3"
23
+ spec.add_development_dependency "rspec-mocks", "~> 3"
24
+ spec.add_development_dependency "rspec-expectations", "~> 3"
25
25
  spec.add_dependency "aws-sdk", "< 2.0"
26
26
  spec.add_dependency "thor"
27
27
  spec.add_dependency "json"
data/lib/automan/base.rb CHANGED
@@ -12,11 +12,9 @@ module Automan
12
12
 
13
13
  include Automan::Mixins::AwsCaller
14
14
 
15
- def initialize(options=nil)
15
+ def initialize(options={})
16
16
  $stdout.sync = true
17
17
  @logger = Logger.new(STDOUT)
18
- @log_aws_calls = false
19
- #@wait = Wait.new(rescuer: WaitRescuer.new, logger: @logger)
20
18
 
21
19
  if !options.nil?
22
20
  options.each_pair do |k,v|
@@ -24,6 +22,12 @@ module Automan
24
22
  send(accessor, v) if respond_to? accessor
25
23
  end
26
24
  end
25
+
26
+ aws_options = {}
27
+ if options[:log_aws]
28
+ aws_options[:logger] = @logger
29
+ end
30
+ configure_aws(aws_options)
27
31
  end
28
32
 
29
33
  def self.add_option(*args)
@@ -18,7 +18,7 @@ module Automan::Beanstalk
18
18
 
19
19
  include Automan::Mixins::Utils
20
20
 
21
- def initialize(options=nil)
21
+ def initialize(options={})
22
22
  @number_to_keep = 0
23
23
  super
24
24
  end
@@ -13,7 +13,7 @@ module Automan::Beanstalk
13
13
 
14
14
  # verify local package exists
15
15
  unless File.exists? source
16
- raise MissingPackageFile, "package file #{source} does not exist"
16
+ raise MissingPackageFileError, "package file #{source} does not exist"
17
17
  end
18
18
 
19
19
  logger.info "Uploading #{source} to #{destination}"
@@ -10,7 +10,7 @@ module Automan::Beanstalk
10
10
 
11
11
  attr_accessor :attempts_made
12
12
 
13
- def initialize(options=nil)
13
+ def initialize(options={})
14
14
  super
15
15
  @wait = Wait.new({
16
16
  attempts: 10,
@@ -7,28 +7,28 @@ module Automan::Cli
7
7
  desc "create", "create a snapshot"
8
8
 
9
9
  option :environment,
10
- aliases: "-e",
11
- desc: "environment of database to snapshot"
10
+ aliases: "-e",
11
+ desc: "environment of database to snapshot"
12
12
 
13
13
  option :database,
14
- aliases: "-d",
15
- desc: "name of the database to snapshot"
14
+ aliases: "-d",
15
+ desc: "name of the database to snapshot"
16
16
 
17
17
  option :name,
18
- aliases: "-n",
19
- desc: "what to name the snapshot"
18
+ aliases: "-n",
19
+ desc: "what to name the snapshot"
20
20
 
21
21
  option :prune,
22
- aliases: "-p",
23
- type: :boolean,
24
- default: true,
25
- desc: "make this snapshot prunable and delete other prunable snapshots older than 30 days"
22
+ aliases: "-p",
23
+ type: :boolean,
24
+ default: true,
25
+ desc: "make this snapshot prunable and delete other prunable snapshots older than 30 days"
26
26
 
27
27
  option :wait_for_completion,
28
- aliases: "-w",
29
- type: :boolean,
30
- default: false,
31
- desc: "wait until snapshot is finished before exiting script"
28
+ aliases: "-w",
29
+ type: :boolean,
30
+ default: false,
31
+ desc: "wait until snapshot is finished before exiting script"
32
32
 
33
33
  def create
34
34
  if options[:database].nil? && options[:environment].nil?
@@ -37,8 +37,9 @@ module Automan::Cli
37
37
  exit 1
38
38
  end
39
39
 
40
- s = Automan::RDS::Snapshot.new(options)
41
- s.log_aws_calls = true
40
+ aws_opts = options.dup
41
+ aws_opts[:log_aws] = true
42
+ s = Automan::RDS::Snapshot.new(aws_opts)
42
43
  s.prune_snapshots if options[:prune]
43
44
  s.create
44
45
  end
@@ -46,9 +47,9 @@ module Automan::Cli
46
47
  desc "delete", "delete a snapshot"
47
48
 
48
49
  option :name,
49
- required: true,
50
- aliases: "-n",
51
- desc: "name of snapshot to delete"
50
+ required: true,
51
+ aliases: "-n",
52
+ desc: "name of snapshot to delete"
52
53
 
53
54
  def delete
54
55
  Automan::RDS::Snapshot.new(options).delete
@@ -57,12 +58,12 @@ module Automan::Cli
57
58
  desc "latest", "find the most recent snapshot"
58
59
 
59
60
  option :database,
60
- aliases: "-d",
61
- desc: "name of the database to snapshot"
61
+ aliases: "-d",
62
+ desc: "name of the database to snapshot"
62
63
 
63
64
  option :environment,
64
- aliases: "-e",
65
- desc: "environment of database to snapshot"
65
+ aliases: "-e",
66
+ desc: "environment of database to snapshot"
66
67
 
67
68
  def latest
68
69
  if options[:database].nil? && options[:environment].nil?
@@ -77,15 +78,14 @@ module Automan::Cli
77
78
  desc "count", "return the number of snapshots"
78
79
 
79
80
  option :environment,
80
- aliases: "-e",
81
- desc: "environment of database to snapshot"
81
+ aliases: "-e",
82
+ desc: "environment of database to snapshot"
82
83
 
83
84
  option :database,
84
- aliases: "-d",
85
- desc: "name of the database to snapshot"
85
+ aliases: "-d",
86
+ desc: "name of the database to snapshot"
86
87
 
87
88
  def count
88
-
89
89
  if options[:database].nil? && options[:environment].nil?
90
90
  puts "Must specify either database or environment"
91
91
  help "count"
@@ -94,6 +94,6 @@ module Automan::Cli
94
94
 
95
95
  Automan::RDS::Snapshot.new(options).count_snapshots
96
96
  end
97
-
97
+
98
98
  end
99
99
  end
@@ -102,5 +102,24 @@ module Automan::Cli
102
102
  h = Automan::Cloudformation::Launcher.new(options).parse_template_parameters
103
103
  say JSON.pretty_generate h
104
104
  end
105
+
106
+ include Thor::Actions
107
+ def self.source_root
108
+ File.join(File.dirname(__FILE__),'..','..', '..')
109
+ end
110
+
111
+ desc "project APP_NAME", "create stacker project"
112
+
113
+ attr_reader :app_name
114
+
115
+ def project(app_name)
116
+ @app_name = app_name
117
+
118
+ say "\nCreating stacker project: #{app_name}\n", :yellow
119
+ directory 'templates/stacker', app_name
120
+ [app_name, "launch_#{app_name}.sh"].each do |file|
121
+ chmod File.join(app_name, 'bin', file), 0755
122
+ end
123
+ end
105
124
  end
106
125
  end
@@ -16,7 +16,7 @@ module Automan::Cloudformation
16
16
 
17
17
  include Automan::Mixins::Utils
18
18
 
19
- def initialize(options=nil)
19
+ def initialize(options={})
20
20
  @wait_for_completion = false
21
21
  super
22
22
  @wait = Wait.new({
@@ -148,6 +148,8 @@ module Automan::Cloudformation
148
148
 
149
149
  logger.info "updating stack #{name}"
150
150
 
151
+ no_updates_needed = false
152
+
151
153
  # if cfn determines that no updates are to be performed,
152
154
  # it raises a ValidationError
153
155
  begin
@@ -157,10 +159,11 @@ module Automan::Cloudformation
157
159
  raise e
158
160
  else
159
161
  logger.info e.message
162
+ no_updates_needed = true
160
163
  end
161
164
  end
162
165
 
163
- if wait_for_completion
166
+ if !no_updates_needed && wait_for_completion
164
167
  logger.info "waiting for stack #{name} to update"
165
168
  wait_until { stack_update_complete? }
166
169
  end
@@ -193,4 +196,4 @@ module Automan::Cloudformation
193
196
  end
194
197
  end
195
198
 
196
- end
199
+ end
@@ -5,7 +5,7 @@ module Automan::Cloudformation
5
5
  class Replacer < Automan::Base
6
6
  add_option :name
7
7
 
8
- def initialize(options=nil)
8
+ def initialize(options={})
9
9
  super
10
10
  @wait = Wait.new({
11
11
  delay: 60,
@@ -4,7 +4,7 @@ module Automan::Cloudformation
4
4
  class Terminator < Automan::Base
5
5
  add_option :name, :wait_for_completion
6
6
 
7
- def initialize(options=nil)
7
+ def initialize(options={})
8
8
  @wait_for_completion = false
9
9
  super
10
10
  @wait = Wait.new({
@@ -7,7 +7,7 @@ module Automan::Ec2
7
7
 
8
8
  include Automan::Mixins::Utils
9
9
 
10
- def initialize(options=nil)
10
+ def initialize(options={})
11
11
  super
12
12
  @wait = Wait.new({
13
13
  delay: 5,
@@ -45,7 +45,7 @@ module Automan::Ec2
45
45
  end
46
46
 
47
47
  def default_image_name
48
- stime = Time.new.iso8601.gsub(/:/, '-')
48
+ stime = Time.now.utc.iso8601.gsub(/[:+]/, '')
49
49
  return name + "-" + stime
50
50
  end
51
51
 
@@ -134,4 +134,4 @@ module Automan::Ec2
134
134
  end
135
135
 
136
136
  end
137
- end
137
+ end
@@ -0,0 +1,79 @@
1
+ require 'automan'
2
+
3
+ module Automan::ElastiCache
4
+ class Router < Automan::Base
5
+
6
+ add_option :environment,
7
+ :hosted_zone_name,
8
+ :redis_host
9
+
10
+ def node_name_from_elasticache_environment(env)
11
+
12
+ opts = {
13
+ cache_cluster_id: "redis-#{env}",
14
+ show_cache_node_info: true
15
+ }
16
+
17
+ response = ec.client.describe_cache_clusters opts
18
+
19
+ unless response.successful?
20
+ raise RequestFailedError, "describe_cache_clusters failed: #{response.error}"
21
+ end
22
+
23
+ cluster=response.data[:cache_clusters]
24
+ if cluster.empty?
25
+ return nil
26
+ end
27
+
28
+ nodes=Hash[*cluster][:cache_nodes]
29
+ if nodes.empty?
30
+ return nil
31
+ end
32
+
33
+ endpoint=Hash[*nodes][:endpoint]
34
+ if endpoint.empty?
35
+ return nil
36
+ end
37
+
38
+ logger.info "found redis endpoint at #{endpoint[:address]}"
39
+ endpoint[:address]
40
+ end
41
+
42
+ # be sure alias_name ends in period
43
+ def update_dns_alias(zone_name, redis_cname, primary_endpoint)
44
+ zone = r53.hosted_zones.select {|z| z.name == zone_name}.first
45
+ rrset = zone.rrsets[redis_cname + '.', 'CNAME']
46
+
47
+ if rrset.exists?
48
+ logger.info "removing old record at #{redis_cname}"
49
+ rrset.delete
50
+ end
51
+
52
+ logger.info "creating record #{redis_cname} -> #{primary_endpoint}"
53
+ zone.rrsets.create(
54
+ redis_cname + '.',
55
+ 'CNAME',
56
+ :ttl => 300,
57
+ :resource_records => [{:value => primary_endpoint}]
58
+ )
59
+ end
60
+
61
+ def run
62
+ log_options
63
+
64
+ logger.info "getting redis primary node name..."
65
+ primary_endpoint = node_name_from_elasticache_environment environment
66
+
67
+ if primary_endpoint.nil?
68
+ false
69
+ else
70
+ update_dns_alias(
71
+ hosted_zone_name,
72
+ redis_host,
73
+ primary_endpoint
74
+ )
75
+ true
76
+ end
77
+ end
78
+ end
79
+ end
@@ -8,14 +8,20 @@ module Automan
8
8
  ENV['AWS_ACCOUNT_ID']
9
9
  end
10
10
 
11
- attr_reader :log_aws_calls
12
- def log_aws_calls=(value)
13
- if value == true
14
- AWS.config(logger: @logger)
15
- else
16
- AWS.config(logger: nil)
11
+ def configure_aws(options={})
12
+ if ENV['AWS_ROLE']
13
+ sts = AWS::STS.new
14
+
15
+ @logger.info "Assuming role #{ENV['AWS_ROLE']}"
16
+ provider = AWS::Core::CredentialProviders::AssumeRoleProvider.new(
17
+ sts: sts,
18
+ role_arn: ENV['AWS_ROLE'],
19
+ role_session_name: "automan-aws-sdk"
20
+ )
21
+ options[:credential_provider] = provider
17
22
  end
18
- @log_aws_calls = value
23
+
24
+ AWS.config(options)
19
25
  end
20
26
 
21
27
  attr_writer :eb
@@ -102,6 +108,14 @@ module Automan
102
108
  @rds
103
109
  end
104
110
 
111
+ attr_writer :ec
112
+ def ec
113
+ if @ec.nil?
114
+ @ec = AWS::ElastiCache.new
115
+ end
116
+ @ec
117
+ end
118
+
105
119
  attr_writer :ec2
106
120
  def ec2
107
121
  if @ec2.nil?
@@ -12,7 +12,7 @@ module Automan::RDS
12
12
 
13
13
  attr_accessor :max_snapshots
14
14
 
15
- def initialize(options=nil)
15
+ def initialize(options={})
16
16
  @prune = true
17
17
  @wait_for_completion = false
18
18
  super
@@ -33,6 +33,8 @@ module Automan::RDS
33
33
 
34
34
  include Automan::Mixins::Utils
35
35
 
36
+ # TODO move this and dependecies to an RDS utils class
37
+ # so we can re-use it
36
38
  def find_db
37
39
  db = nil
38
40
  if !database.nil?
@@ -63,7 +65,9 @@ module Automan::RDS
63
65
  end
64
66
 
65
67
  def snapshot_count
66
- rds.db_instances[find_db.id].snapshots.count
68
+ AWS.memoize do
69
+ rds.db_instances[find_db.id].snapshots.count
70
+ end
67
71
  end
68
72
 
69
73
  def create
@@ -93,8 +97,8 @@ module Automan::RDS
93
97
  snap = db.create_snapshot(myname)
94
98
 
95
99
  if prune == true
96
- logger.info "Setting snapshot to be prunable"
97
- set_prunable(snap)
100
+ logger.info "Setting snapshot to be prunable and tagging environment"
101
+ set_prunable_and_env(snap,environment)
98
102
  end
99
103
 
100
104
  if wait_for_completion == true
@@ -120,7 +124,7 @@ module Automan::RDS
120
124
 
121
125
  def default_snapshot_name(db)
122
126
  env = db_environment db
123
- stime = Time.new.iso8601.gsub(/:/,'-')
127
+ stime = Time.new.strftime("%Y-%m-%dT%H-%M")
124
128
 
125
129
  return env + "-" + stime
126
130
  end
@@ -145,10 +149,10 @@ module Automan::RDS
145
149
  end
146
150
 
147
151
  # tag with CanPrune
148
- def set_prunable(snapshot)
152
+ def set_prunable_and_env(snapshot,environment)
149
153
  opts = {
150
154
  resource_name: snapshot_arn(snapshot),
151
- tags: [ {key: 'CanPrune', value: 'yes'} ]
155
+ tags: [ {key: 'CanPrune', value: 'yes'}, {key: 'Environment', value: environment} ]
152
156
  }
153
157
  response = rds.client.add_tags_to_resource opts
154
158
 
@@ -185,6 +189,15 @@ module Automan::RDS
185
189
  tagged_can_prune?(snapshot) && available?(snapshot) && manual?(snapshot)
186
190
  end
187
191
 
192
+ def is_env?(snapshot,environment)
193
+ tagged_env?(snapshot,environment) && available?(snapshot) && manual?(snapshot)
194
+ end
195
+
196
+ def tagged_env?(snapshot,environment)
197
+ arn = snapshot_arn(snapshot)
198
+ tags(arn)['Environment'] == environment
199
+ end
200
+
188
201
  def tagged_can_prune?(snapshot)
189
202
  arn = snapshot_arn(snapshot)
190
203
  tags(arn)['CanPrune'] == 'yes'
@@ -208,10 +221,8 @@ module Automan::RDS
208
221
  end
209
222
 
210
223
  def prunable_snapshots
211
- AWS.memoize do
212
- snapshots = get_all_snapshots
213
- snapshots.select { |s| can_prune?(s) }
214
- end
224
+ snapshots = get_all_snapshots
225
+ snapshots.select { |s| can_prune?(s) }
215
226
  end
216
227
 
217
228
  def oldest_prunable_snapshot
@@ -248,10 +259,20 @@ module Automan::RDS
248
259
 
249
260
  def latest
250
261
  log_options
251
- db = find_db
252
- logger.info "Finding most recent snapshot for #{db.id}"
253
- s = db.snapshots.sort_by {|i| i.created_at }.last
262
+ logger.info "Finding most recent snapshot for #{environment}"
263
+
264
+ allsnaps=get_all_snapshots
265
+
266
+ envsnaps=[]
267
+ allsnaps.each do |onesnap|
268
+ if is_env?(onesnap,environment)
269
+ envsnaps.push(onesnap)
270
+ end
271
+ end
272
+
273
+ s=envsnaps.sort_by {|i| i.created_at }.last
254
274
  logger.info "Most recent snapshot is #{s.id}"
275
+ s.id
255
276
  end
256
277
  end
257
278
  end
@@ -9,7 +9,7 @@ module Automan::S3
9
9
  def download
10
10
  log_options
11
11
 
12
- logger.info "uploading #{localfile} to #{s3file}"
12
+ logger.info "downloading #{s3file} to #{localfile}"
13
13
 
14
14
  bucket, key = parse_s3_path s3file
15
15
 
@@ -18,7 +18,16 @@ module Automan::S3
18
18
  file.write(chunk)
19
19
  end
20
20
  end
21
+ end
22
+
23
+ def read
24
+ log_options
25
+
26
+ logger.info "returning contents of #{s3file} as string"
27
+
28
+ bucket, key = parse_s3_path s3file
21
29
 
30
+ s3.buckets[bucket].objects[key].read
22
31
  end
23
32
 
24
33
  end
@@ -1,3 +1,3 @@
1
1
  module Automan
2
- VERSION = "2.3.6"
2
+ VERSION = "2.3.7"
3
3
  end
data/lib/automan.rb CHANGED
@@ -19,6 +19,7 @@ require 'automan/cloudformation/terminator'
19
19
  require 'automan/cloudformation/replacer'
20
20
  require 'automan/cloudformation/uploader'
21
21
  require 'automan/cloudformation/errors'
22
+ require 'automan/elasticache/router'
22
23
  require 'automan/rds/snapshot'
23
24
  require 'automan/rds/errors'
24
25
  require 'automan/ec2/instance'
@@ -1,12 +1,12 @@
1
1
  require "automan"
2
2
 
3
3
  describe Automan::Beanstalk::Application do
4
- it { should respond_to :name }
5
- it { should respond_to :create }
6
- it { should respond_to :delete }
4
+ it { is_expected.to respond_to :name }
5
+ it { is_expected.to respond_to :create }
6
+ it { is_expected.to respond_to :delete }
7
7
 
8
8
  describe '#create' do
9
- subject(:a) do
9
+ subject() do
10
10
  AWS.stub!
11
11
  a = Automan::Beanstalk::Application.new
12
12
  a.logger = Logger.new('/dev/null')
@@ -14,20 +14,20 @@ describe Automan::Beanstalk::Application do
14
14
  end
15
15
 
16
16
  it "does not create if the application already exists" do
17
- a.stub(:application_exists?).and_return(true)
18
- a.should_not_receive(:create_application)
19
- a.create
17
+ allow(subject).to receive(:application_exists?).and_return(true)
18
+ expect(subject).to_not receive(:create_application)
19
+ subject.create
20
20
  end
21
21
 
22
22
  it "does create if the application doesn't exist" do
23
- a.stub(:application_exists?).and_return(false)
24
- a.should_receive(:create_application)
25
- a.create
23
+ allow(subject).to receive(:application_exists?).and_return(false)
24
+ expect(subject).to receive(:create_application)
25
+ subject.create
26
26
  end
27
27
  end
28
28
 
29
29
  describe '#delete' do
30
- subject(:a) do
30
+ subject() do
31
31
  AWS.stub!
32
32
  a = Automan::Beanstalk::Application.new
33
33
  a.logger = Logger.new('/dev/null')
@@ -35,15 +35,15 @@ describe Automan::Beanstalk::Application do
35
35
  end
36
36
 
37
37
  it "does delete if the application already exists" do
38
- a.stub(:application_exists?).and_return(true)
39
- a.should_receive(:delete_application)
40
- a.delete
38
+ allow(subject).to receive(:application_exists?).and_return(true)
39
+ expect(subject).to receive(:delete_application)
40
+ subject.delete
41
41
  end
42
42
 
43
43
  it "does not delete if the application doesn't exist" do
44
- a.stub(:application_exists?).and_return(false)
45
- a.should_not_receive(:delete_application)
46
- a.delete
44
+ allow(subject).to receive(:application_exists?).and_return(false)
45
+ expect(subject).to_not receive(:delete_application)
46
+ subject.delete
47
47
  end
48
48
  end
49
49
  end