paratrooper 2.0.0.beta1 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cdee8a2553bcc4297a5201449429d4be4c9075e
4
- data.tar.gz: 95a19b97249116f577655ab60298af1d396c3a92
3
+ metadata.gz: 58da6246caf420f2f0c79c01abc7491105659c22
4
+ data.tar.gz: 5937e0abbdc79eb182c1b8e5c764407e1526f4c2
5
5
  SHA512:
6
- metadata.gz: c617517de7e35016f00629f22e5567ac6d57129bcdecb07ce1c6545e32f25d06245d207c53143c8f1df3c0dade39dbfa69b006248b8f001b207ca8a7b16e12e2
7
- data.tar.gz: 939942fc3004f1deb0134ded9e71b515ce11bd324fc347b2a8df9d52ef380212ec1aabad287eddea0cb852139ae0ab4963d832d2c91fa43ce92bafd09cdabc11
6
+ metadata.gz: bdbbf7413098608585c59257ad2a50d9ce19199b739ccf51515d55710371da6c7b910fe41394915ec314e5215a6f285b5593d1970659e3d4c52b786c53361b6f
7
+ data.tar.gz: 9e367345b3608a1bf2ada353fdaaffd86294125f26e9559a955adf4aa7ee7660ea55812654f60783c002f1cc02bdd72dab52aba96d5c43ad3fd89a20dbd2eb8a
@@ -1,8 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0.beta1
4
+
5
+ - Callbacks are fired around deployment methods for an easy way to hook into
6
+ the deploy process
7
+ - Ruby 1.9.2+ is required
8
+ - Added 'MIT' license to gem
9
+ - Options can now be set by options passed into contstructor or block syntax
10
+ - `match_tag_to` option has been changed to `match_tag`
11
+ - Disabling the use of maintenance mode as an option
12
+
3
13
  ## 1.4.2
4
14
 
5
- - Fixed incorrect pushing of a tag called 'master' to heroku on first deploy.
15
+ - Fixed incorrect pushing of a tag called 'master' to heroku on first deploy
6
16
  - Small README change regarding migrations
7
17
 
8
18
  ## 1.4.1
@@ -1,15 +1,11 @@
1
1
  module Paratrooper
2
2
  module Callbacks
3
- def callback(name, &block)
4
- execute_callback("before_#{name}".to_sym)
5
- block.call if block_given?
6
- execute_callback("after_#{name}".to_sym)
7
- end
8
-
9
- def execute_callback(name)
10
- callbacks[name].each(&:call)
11
- end
12
3
 
4
+ # Public: Add misc. function to be called at a later time
5
+ #
6
+ # name - String name of callback
7
+ # Example: before_[method_name], after_[method_name]
8
+ # block - Code to be executed during callback
13
9
  def add_callback(name, &block)
14
10
  callbacks[name] << block
15
11
  end
@@ -17,5 +13,17 @@ module Paratrooper
17
13
  def callbacks
18
14
  @callbacks ||= Hash.new { |hash, key| hash[key] = [] }
19
15
  end
16
+
17
+ private
18
+
19
+ def build_callback(name, context = nil, &block)
20
+ execute_callback("before_#{name}".to_sym, context)
21
+ block.call if block_given?
22
+ execute_callback("after_#{name}".to_sym, context)
23
+ end
24
+
25
+ def execute_callback(name, context)
26
+ callbacks[name].each { |c| c.call(context) }
27
+ end
20
28
  end
21
29
  end
@@ -13,7 +13,7 @@ module Paratrooper
13
13
 
14
14
  attr_accessor :app_name, :notifiers, :system_caller, :heroku, :tag_name,
15
15
  :match_tag_name, :protocol, :deployment_host, :migration_check, :debug,
16
- :maintenance_mode
16
+ :screen_notifier
17
17
 
18
18
  alias_method :tag=, :tag_name=
19
19
  alias_method :match_tag=, :match_tag_name=
@@ -22,13 +22,15 @@ module Paratrooper
22
22
  #
23
23
  # app_name - A String naming the Heroku application to be interacted with.
24
24
  # options - The Hash options is used to provide additional functionality.
25
+ # :screen_notifier - Object used for outputting to screen
26
+ # (optional).
25
27
  # :notifiers - Array of objects interested in being
26
28
  # notified of steps in deployment process
27
29
  # (optional).
28
30
  # :heroku - Object wrapper around heroku-api (optional).
29
31
  # :tag - String name to be used as a git reference
30
32
  # point (optional).
31
- # :match_tag_to - String name of git reference point to match
33
+ # :match_tag - String name of git reference point to match
32
34
  # :tag to (optional).
33
35
  # :system_caller - Object responsible for calling system
34
36
  # commands (optional).
@@ -38,38 +40,35 @@ module Paratrooper
38
40
  # (optional, default: 'heroku.com').
39
41
  # :migration_check - Object responsible for checking pending
40
42
  # migrations (optional).
41
- # :maintenance_mode - Boolean whether to trigger maintenance
42
- # mode on and off during deployment
43
- # (default: true)
44
43
  # :api_key - String version of heroku api key.
45
- # (default: looks in local Netrc file)
44
+ # (default: looks in local Netrc file).
46
45
  def initialize(app_name, options = {}, &block)
47
- @app_name = app_name
48
- @notifiers = options[:notifiers] || [Notifiers::ScreenNotifier.new]
49
- @heroku = options[:heroku] || HerokuWrapper.new(app_name, options)
50
- @tag_name = options[:tag]
51
- @match_tag_name = options[:match_tag] || 'master'
52
- @system_caller = options[:system_caller] || SystemCaller.new(debug)
53
- @protocol = options[:protocol] || 'http'
54
- @deployment_host = options[:deployment_host] || 'heroku.com'
55
- @debug = options[:debug] || false
56
- @maintenance_mode = options.fetch(:maintenance_mode, true)
57
- self.migration_check = options[:migration_check]
58
- block.call(self) if block_given?
59
- end
46
+ @app_name = app_name
47
+ @screen_notifier = options[:screen_notifier] || Notifiers::ScreenNotifier.new
48
+ @notifiers = options[:notifiers] || [@screen_notifier]
49
+ @heroku = options[:heroku] || HerokuWrapper.new(app_name, options)
50
+ @tag_name = options[:tag]
51
+ @match_tag_name = options[:match_tag] || 'master'
52
+ @system_caller = options[:system_caller] || SystemCaller.new(debug)
53
+ @protocol = options[:protocol] || 'http'
54
+ @deployment_host = options[:deployment_host] || 'heroku.com'
55
+ @debug = options[:debug] || false
56
+ @migration_check = options[:migration_check] || PendingMigrationCheck.new(match_tag_name, heroku, system_caller)
60
57
 
61
- def notify(step, options = {})
62
- notifiers.each do |notifier|
63
- notifier.notify(step, default_payload.merge(options))
64
- end
58
+ block.call(self) if block_given?
65
59
  end
66
60
 
61
+ # Public: Hook method called first in the deploy process.
62
+ #
67
63
  def setup
68
64
  callback(:setup) do
69
65
  notify(:setup)
66
+ migration_check.last_deployed_commit
70
67
  end
71
68
  end
72
69
 
70
+ # Public: Hook method called last in the deploy process.
71
+ #
73
72
  def teardown
74
73
  callback(:teardown) do
75
74
  notify(:teardown)
@@ -79,7 +78,7 @@ module Paratrooper
79
78
  # Public: Activates Heroku maintenance mode.
80
79
  #
81
80
  def activate_maintenance_mode
82
- return unless maintenance_mode?
81
+ return unless pending_migrations?
83
82
  callback(:activate_maintenance_mode) do
84
83
  notify(:activate_maintenance_mode)
85
84
  heroku.app_maintenance_on
@@ -89,7 +88,7 @@ module Paratrooper
89
88
  # Public: Deactivates Heroku maintenance mode.
90
89
  #
91
90
  def deactivate_maintenance_mode
92
- return unless maintenance_mode?
91
+ return unless pending_migrations?
93
92
  callback(:deactivate_maintenance_mode) do
94
93
  notify(:deactivate_maintenance_mode)
95
94
  heroku.app_maintenance_off
@@ -131,6 +130,7 @@ module Paratrooper
131
130
  # Public: Restarts application on Heroku.
132
131
  #
133
132
  def app_restart
133
+ return unless restart_required?
134
134
  callback(:app_restart) do
135
135
  notify(:app_restart)
136
136
  heroku.app_restart
@@ -139,6 +139,9 @@ module Paratrooper
139
139
 
140
140
  # Public: cURL for application URL to start your Heroku dyno.
141
141
  #
142
+ # wait_time - Integer length of time (seconds) to wait before making call
143
+ # to app
144
+ #
142
145
  def warm_instance(wait_time = 3)
143
146
  callback(:warm_instance) do
144
147
  notify(:warm_instance)
@@ -172,15 +175,17 @@ module Paratrooper
172
175
  end
173
176
  alias_method :deploy, :default_deploy
174
177
 
175
- def maintenance_mode?
176
- !!@maintenance_mode
177
- end
178
-
179
178
  private
180
179
  def app_url
181
180
  heroku.app_url
182
181
  end
183
182
 
183
+ def callback(name, &block)
184
+ build_callback(name, screen_notifier, &block)
185
+ end
186
+
187
+ # Internal: Payload data to be sent with notifications
188
+ #
184
189
  def default_payload
185
190
  {
186
191
  app_name: app_name,
@@ -199,19 +204,29 @@ module Paratrooper
199
204
  git_remote(deployment_host, app_name)
200
205
  end
201
206
 
207
+ # Internal: Notifies other objects that an event has occurred
208
+ #
209
+ # step - String event name
210
+ # options - Hash of options to be sent as data payload
211
+ #
212
+ def notify(step, options = {})
213
+ notifiers.each do |notifier|
214
+ notifier.notify(step, default_payload.merge(options))
215
+ end
216
+ end
217
+
202
218
  def pending_migrations?
203
219
  migration_check.migrations_waiting?
204
220
  end
205
221
 
206
- def migration_check=(obj)
207
- @migration_check = obj || PendingMigrationCheck.new(match_tag_name, heroku, system_caller)
208
- @migration_check.last_deployed_commit
209
- @migration_check
222
+ def restart_required?
223
+ pending_migrations?
210
224
  end
211
225
 
212
226
  # Internal: Calls commands meant to go to system
213
227
  #
214
228
  # call - String version of system command
229
+ #
215
230
  def system_call(call)
216
231
  system_caller.execute(call)
217
232
  end
@@ -2,6 +2,8 @@ require 'netrc'
2
2
 
3
3
  module Paratrooper
4
4
  class LocalApiKeyExtractor
5
+ class NetrcFileDoesNotExist < StandardError; end
6
+
5
7
  attr_reader :file_path, :netrc_klass
6
8
 
7
9
  def self.get_credentials
@@ -19,15 +21,22 @@ module Paratrooper
19
21
 
20
22
  private
21
23
  def netrc
22
- @netrc ||= begin
23
- File.exists?(file_path) && Netrc.read(file_path)
24
- rescue => error
25
- raise error
24
+ unless netrc_present?
25
+ raise NetrcFileDoesNotExist, netrc_file_missing_message
26
26
  end
27
+ @netrc ||= Netrc.read(file_path)
27
28
  end
28
29
 
29
30
  def read_credentials_for(domain)
30
31
  netrc[domain][1]
31
32
  end
33
+
34
+ def netrc_file_missing_message
35
+ "Unable to find netrc file. Expected location: #{netrc_klass.default_path}."
36
+ end
37
+
38
+ def netrc_present?
39
+ File.exists?(file_path)
40
+ end
32
41
  end
33
42
  end
@@ -23,20 +23,20 @@ module Paratrooper
23
23
  #
24
24
  # display("Excellent Message")
25
25
  # # =>
26
- # # => ==========================================================================
26
+ # # => =============================================================
27
27
  # # => >> Excellent Message
28
- # # => ==========================================================================
28
+ # # => =============================================================
29
29
  # # =>
30
30
  def display(message)
31
31
  output.puts
32
- output.puts "=" * 80
32
+ output.puts "=" * 60
33
33
  output.puts ">> #{message}"
34
- output.puts "=" * 80
34
+ output.puts "=" * 60
35
35
  output.puts
36
36
  end
37
37
 
38
38
  def activate_maintenance_mode(options = {})
39
- display("Activating Maintenance Mode")
39
+ display("Activating Maintenance Mode - Enabled due to pending migrations")
40
40
  end
41
41
 
42
42
  def deactivate_maintenance_mode(options = {})
@@ -1,3 +1,3 @@
1
1
  module Paratrooper
2
- VERSION = "2.0.0.beta1"
2
+ VERSION = "2.0.0.beta2".freeze
3
3
  end
@@ -4,23 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'paratrooper/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "paratrooper"
8
- gem.version = Paratrooper::VERSION
9
- gem.authors = ['Matt Polito', 'Brandon Farmer']
10
- gem.email = ['matt.polito@gmail.com', 'bthesorceror@gmail.com']
11
- gem.description = %q{Library to create task for deployment to Heroku}
12
- gem.summary = %q{Library to create task for deployment to Heroku}
13
- gem.homepage = "http://github.com/mattpolito/paratrooper"
7
+ gem.name = 'paratrooper'
8
+ gem.version = Paratrooper::VERSION
9
+ gem.authors = ['Matt Polito', 'Brandon Farmer']
10
+ gem.email = ['matt.polito@gmail.com', 'bthesorceror@gmail.com']
11
+ gem.description = %q{Library to create task for deployment to Heroku}
12
+ gem.summary = %q{Library to create task for deployment to Heroku}
13
+ gem.homepage = 'http://github.com/mattpolito/paratrooper'
14
+ gem.license = 'MIT'
14
15
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ['lib']
20
+ gem.required_ruby_version = '>= 1.9.2'
19
21
 
20
22
  gem.add_development_dependency 'rake'
21
23
  gem.add_development_dependency 'rspec', '~> 2.12'
22
24
  gem.add_development_dependency 'pry'
23
25
  gem.add_dependency 'heroku-api', '~> 0.3'
24
- gem.add_dependency 'rendezvous', "~> 0.0.1"
26
+ gem.add_dependency 'rendezvous', '~> 0.0.1'
25
27
  gem.add_dependency 'netrc', '~> 0.7'
26
28
  end
@@ -12,7 +12,7 @@ describe Paratrooper::Deploy do
12
12
  notifiers: [],
13
13
  system_caller: system_caller,
14
14
  migration_check: migration_check,
15
- maintenance_mode: true
15
+ screen_notifier: screen_notifier
16
16
  }
17
17
  end
18
18
  let(:options) { Hash.new }
@@ -26,6 +26,7 @@ describe Paratrooper::Deploy do
26
26
  )
27
27
  end
28
28
  let(:system_caller) { double(:system_caller) }
29
+ let(:screen_notifier) { double(:screen_notifier) }
29
30
  let(:migration_check) do
30
31
  double(:migration_check, last_deployed_commit: 'DEPLOYED_SHA')
31
32
  end
@@ -53,14 +54,12 @@ describe Paratrooper::Deploy do
53
54
  p.match_tag = "staging"
54
55
  p.tag = "production"
55
56
  p.debug = true
56
- p.maintenance_mode = true
57
57
  p.deployment_host = "HOST"
58
58
  p.protocol = "MOM"
59
59
  end
60
60
  expect(deployer.match_tag_name).to eq("staging")
61
61
  expect(deployer.tag_name).to eq("production")
62
62
  expect(deployer.debug).to be_true
63
- expect(deployer.maintenance_mode).to be_true
64
63
  expect(deployer.deployment_host).to eq("HOST")
65
64
  expect(deployer.protocol).to eq("MOM")
66
65
  end
@@ -93,15 +92,6 @@ describe Paratrooper::Deploy do
93
92
  end
94
93
  end
95
94
 
96
- context "accepts :maintenance_mode" do
97
- let(:options) { { maintenance_mode: false } }
98
- let(:notifiers) { double(:notifier) }
99
-
100
- it "and responds to #notifiers" do
101
- expect(deployer.maintenance_mode?).to eq(false)
102
- end
103
- end
104
-
105
95
  describe "protocol" do
106
96
  context "accepts :protocol" do
107
97
  let(:options) { { protocol: 'https' } }
@@ -131,28 +121,36 @@ describe Paratrooper::Deploy do
131
121
  context "when maintenance_mode option is 'true'" do
132
122
  let(:options) { { maintenance_mode: true } }
133
123
 
134
- it 'sends notification' do
135
- deployer.should_receive(:notify).with(:activate_maintenance_mode).once
136
- deployer.activate_maintenance_mode
137
- end
124
+ context "with pending migrations" do
125
+ before do
126
+ migration_check.stub(:migrations_waiting?).and_return(true)
127
+ end
128
+
129
+ it 'sends notification' do
130
+ deployer.should_receive(:notify).with(:activate_maintenance_mode).once
131
+ deployer.activate_maintenance_mode
132
+ end
138
133
 
139
- it "makes call to heroku to turn on maintenance mode" do
140
- heroku.should_receive(:app_maintenance_on)
141
- deployer.activate_maintenance_mode
134
+ it "makes call to heroku to turn on maintenance mode" do
135
+ heroku.should_receive(:app_maintenance_on)
136
+ deployer.activate_maintenance_mode
137
+ end
142
138
  end
143
- end
144
139
 
145
- context "when maintenance_mode option is 'false'" do
146
- let(:options) { { maintenance_mode: false } }
140
+ context "without pending migrations" do
141
+ before do
142
+ migration_check.stub(:migrations_waiting?).and_return(false)
143
+ end
147
144
 
148
- it 'does not send notification' do
149
- deployer.should_not_receive(:notify).with(:activate_maintenance_mode)
150
- deployer.activate_maintenance_mode
151
- end
145
+ it 'does not send notification' do
146
+ deployer.should_not_receive(:notify).with(:activate_maintenance_mode)
147
+ deployer.activate_maintenance_mode
148
+ end
152
149
 
153
- it "does not make a call to heroku to turn on maintenance mode" do
154
- heroku.should_not_receive(:app_maintenance_on)
155
- deployer.activate_maintenance_mode
150
+ it "does not make a call to heroku to turn on maintenance mode" do
151
+ heroku.should_not_receive(:app_maintenance_on)
152
+ deployer.activate_maintenance_mode
153
+ end
156
154
  end
157
155
  end
158
156
  end
@@ -161,28 +159,36 @@ describe Paratrooper::Deploy do
161
159
  context "when maintenance_mode option is 'true'" do
162
160
  let(:options) { { maintenance_mode: true } }
163
161
 
164
- it 'sends notification' do
165
- deployer.should_receive(:notify).with(:deactivate_maintenance_mode).once
166
- deployer.deactivate_maintenance_mode
167
- end
162
+ context "with pending migrations" do
163
+ before do
164
+ migration_check.stub(:migrations_waiting?).and_return(true)
165
+ end
166
+
167
+ it 'sends notification' do
168
+ deployer.should_receive(:notify).with(:deactivate_maintenance_mode).once
169
+ deployer.deactivate_maintenance_mode
170
+ end
168
171
 
169
- it "makes call to heroku to turn on maintenance mode" do
170
- heroku.should_receive(:app_maintenance_off)
171
- deployer.deactivate_maintenance_mode
172
+ it "makes call to heroku to turn on maintenance mode" do
173
+ heroku.should_receive(:app_maintenance_off)
174
+ deployer.deactivate_maintenance_mode
175
+ end
172
176
  end
173
- end
174
177
 
175
- context "when maintenance_mode option is 'false'" do
176
- let(:options) { { maintenance_mode: false } }
178
+ context "without pending migrations" do
179
+ before do
180
+ migration_check.stub(:migrations_waiting?).and_return(false)
181
+ end
177
182
 
178
- it 'does not send notification' do
179
- deployer.should_not_receive(:notify).with(:deactivate_maintenance_mode)
180
- deployer.deactivate_maintenance_mode
181
- end
183
+ it 'does not send notification' do
184
+ deployer.should_not_receive(:notify).with(:deactivate_maintenance_mode)
185
+ deployer.deactivate_maintenance_mode
186
+ end
182
187
 
183
- it "does not make a call to heroku to turn on maintenance mode" do
184
- heroku.should_not_receive(:app_maintenance_off)
185
- deployer.deactivate_maintenance_mode
188
+ it "does not make a call to heroku to turn on maintenance mode" do
189
+ heroku.should_not_receive(:app_maintenance_off)
190
+ deployer.deactivate_maintenance_mode
191
+ end
186
192
  end
187
193
  end
188
194
  end
@@ -287,14 +293,36 @@ describe Paratrooper::Deploy do
287
293
  end
288
294
 
289
295
  describe "#app_restart" do
290
- it 'sends notification' do
291
- deployer.should_receive(:notify).with(:app_restart).once
292
- deployer.app_restart
296
+ context 'when a restart is required due to pending migrations' do
297
+ before do
298
+ migration_check.stub(:migrations_waiting?).and_return(true)
299
+ end
300
+
301
+ it 'sends notification' do
302
+ expect(deployer).to receive(:notify).with(:app_restart).once
303
+ deployer.app_restart
304
+ end
305
+
306
+ it 'restarts your heroku instance' do
307
+ expect(heroku).to receive(:app_restart)
308
+ deployer.app_restart
309
+ end
293
310
  end
294
311
 
295
- it 'restarts your heroku instance' do
296
- heroku.should_receive(:app_restart)
297
- deployer.app_restart
312
+ context 'when a restart is not required' do
313
+ before do
314
+ migration_check.stub(:migrations_waiting?).and_return(false)
315
+ end
316
+
317
+ it 'does not send notification' do
318
+ expect(deployer).to_not receive(:notify).with(:app_restart)
319
+ deployer.app_restart
320
+ end
321
+
322
+ it 'does not restart your heroku instance' do
323
+ expect(heroku).to_not receive(:app_restart)
324
+ deployer.app_restart
325
+ end
298
326
  end
299
327
  end
300
328
 
@@ -324,23 +352,35 @@ describe Paratrooper::Deploy do
324
352
  end
325
353
  end
326
354
 
327
- describe "adding notification" do
328
- after do
329
- FileUtils.rm("spec/fixtures/test.txt")
330
- end
331
-
332
- it "adds notifier to #notifiers collection" do
333
- callback = proc do
355
+ describe "#add_callback" do
356
+ it "adds callback" do
357
+ callback = proc do |output|
334
358
  system("touch spec/fixtures/test.txt")
335
359
  end
336
360
 
337
361
  deployer = described_class.new(app_name, default_options) do |p|
338
362
  p.add_callback(:before_setup, &callback)
339
363
  end
340
- deployer.setup
341
364
 
342
365
  expect(deployer.callbacks[:before_setup]).to eq([callback])
343
366
  end
367
+
368
+ context "when messaging is added to callback" do
369
+ it "is called" do
370
+ callback = proc do |output|
371
+ output.display("Whoo Hoo!")
372
+ end
373
+
374
+ screen_notifier.stub(:display).with("Whoo Hoo!")
375
+
376
+ deployer = described_class.new(app_name, default_options) do |p|
377
+ p.add_callback(:before_setup, &callback)
378
+ end
379
+ deployer.setup
380
+
381
+ expect(screen_notifier).to have_received(:display).with("Whoo Hoo!")
382
+ end
383
+ end
344
384
  end
345
385
  end
346
386
  end
@@ -6,11 +6,11 @@ describe Paratrooper::LocalApiKeyExtractor do
6
6
  let(:netrc_klass) { double(:netrc_klass, default_path: fixture_file_path) }
7
7
  let(:fixture_file_path) { fixture_path('netrc') }
8
8
 
9
- before do
10
- File.chmod(0600, fixture_file_path)
11
- end
12
-
13
9
  describe 'file association' do
10
+ before do
11
+ File.chmod(0600, fixture_file_path)
12
+ end
13
+
14
14
  context 'when file path is provided' do
15
15
  let(:extractor) { described_class.new(file_path: fixture_file_path) }
16
16
 
@@ -29,7 +29,7 @@ describe Paratrooper::LocalApiKeyExtractor do
29
29
  end
30
30
 
31
31
  describe '#read_credentials' do
32
- let(:extractor) { described_class.new(netrc_klass: netrc_klass) }
32
+ let(:extractor) { described_class.new(netrc_klass: netrc_klass) }
33
33
 
34
34
  context 'when environment variable is set' do
35
35
  before do
@@ -43,11 +43,21 @@ describe Paratrooper::LocalApiKeyExtractor do
43
43
 
44
44
  context 'when environment variable is not set' do
45
45
  before do
46
+ ENV.stub(:[])
46
47
  ENV.stub(:[]).with('HEROKU_API_KEY').and_return(nil)
47
48
  end
49
+
48
50
  it 'returns credentials from local file' do
49
51
  expect(extractor.read_credentials).to eq('LOCAL_API_KEY')
50
52
  end
53
+
54
+ context 'and no local file is available' do
55
+ let(:fixture_file_path) { fixture_path('no_netrc') }
56
+
57
+ it 'throws error' do
58
+ expect{ extractor.read_credentials }.to raise_error(described_class::NetrcFileDoesNotExist, /#{fixture_file_path}/)
59
+ end
60
+ end
51
61
  end
52
62
  end
53
63
  end
@@ -10,9 +10,9 @@ describe Paratrooper::Notifiers::ScreenNotifier do
10
10
  it "outputs _message_ to screen" do
11
11
  expected_output = <<-EXPECTED_OUTPUT.gsub(/^ {8}/, '')
12
12
 
13
- #{'=' * 80}
13
+ #{'=' * 60}
14
14
  >> MESSAGE
15
- #{'=' * 80}
15
+ #{'=' * 60}
16
16
 
17
17
  EXPECTED_OUTPUT
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paratrooper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Polito
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-24 00:00:00.000000000 Z
12
+ date: 2014-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -132,7 +132,8 @@ files:
132
132
  - spec/paratrooper/pending_migration_check_spec.rb
133
133
  - spec/spec_helper.rb
134
134
  homepage: http://github.com/mattpolito/paratrooper
135
- licenses: []
135
+ licenses:
136
+ - MIT
136
137
  metadata: {}
137
138
  post_install_message:
138
139
  rdoc_options: []
@@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
143
  requirements:
143
144
  - - '>='
144
145
  - !ruby/object:Gem::Version
145
- version: '0'
146
+ version: 1.9.2
146
147
  required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  requirements:
148
149
  - - '>'
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  version: 1.3.1
151
152
  requirements: []
152
153
  rubyforge_project:
153
- rubygems_version: 2.0.3
154
+ rubygems_version: 2.1.11
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: Library to create task for deployment to Heroku