|
14 | 14 | let(:rollbar_revision) { 'sha123' } |
15 | 15 | let(:dry_run) { false } |
16 | 16 |
|
| 17 | + class Capistrano2LoggerStub |
| 18 | + def important(message, line_prefix=nil) end |
| 19 | + def info(message, line_prefix=nil) end |
| 20 | + def debug(message, line_prefix=nil) end |
| 21 | + end |
| 22 | + |
17 | 23 | before do |
18 | 24 | allow(logger).to receive(:info) |
19 | 25 | allow(logger).to receive(:error) |
|
88 | 94 |
|
89 | 95 | subject.deploy_started(capistrano, logger, dry_run) |
90 | 96 | end |
| 97 | + |
| 98 | + context 'when using Capistrano 2.x logger' do |
| 99 | + let(:logger2) { Capistrano2LoggerStub.new } |
| 100 | + |
| 101 | + it "logs the error to the logger" do |
| 102 | + expect(::Rollbar::Deploy).to receive(:report) |
| 103 | + .and_raise('an API exception') |
| 104 | + |
| 105 | + expect(logger2).to receive(:important).with(/an API exception/) |
| 106 | + |
| 107 | + subject.deploy_started(capistrano, logger2, dry_run) |
| 108 | + end |
| 109 | + end |
91 | 110 | end |
92 | 111 |
|
93 | 112 | context 'with --dry-run provided' do |
|
174 | 193 |
|
175 | 194 | subject.deploy_succeeded(capistrano, logger, dry_run) |
176 | 195 | end |
| 196 | + |
| 197 | + context 'when using Capistrano 2.x logger' do |
| 198 | + let(:logger2) { Capistrano2LoggerStub.new } |
| 199 | + |
| 200 | + it "logs the error to the logger" do |
| 201 | + expect(::Rollbar::Deploy).to receive(:update) |
| 202 | + .and_raise('an API exception') |
| 203 | + |
| 204 | + expect(logger2).to receive(:important).with(/an API exception/) |
| 205 | + |
| 206 | + subject.deploy_succeeded(capistrano, logger2, dry_run) |
| 207 | + end |
| 208 | + end |
177 | 209 | end |
178 | 210 |
|
179 | 211 | context 'with --dry-run provided' do |
|
282 | 314 |
|
283 | 315 | subject.deploy_failed(capistrano, logger, dry_run) |
284 | 316 | end |
| 317 | + |
| 318 | + context 'when using Capistrano 2.x logger' do |
| 319 | + let(:logger2) { Capistrano2LoggerStub.new } |
| 320 | + |
| 321 | + it "logs the error to the logger" do |
| 322 | + expect(::Rollbar::Deploy).to receive(:update) |
| 323 | + .and_raise('an API exception') |
| 324 | + |
| 325 | + expect(logger2).to receive(:important).with(/an API exception/) |
| 326 | + |
| 327 | + subject.deploy_failed(capistrano, logger2, dry_run) |
| 328 | + end |
| 329 | + end |
285 | 330 | end |
286 | 331 |
|
287 | 332 | context 'with --dry-run provided' do |
|
324 | 369 |
|
325 | 370 | subject.deploy_failed(capistrano, logger, dry_run) |
326 | 371 | end |
| 372 | + |
| 373 | + context 'when using Capistrano 2.x logger' do |
| 374 | + let(:logger2) { Capistrano2LoggerStub.new } |
| 375 | + |
| 376 | + it 'displays an error message and exits' do |
| 377 | + expect(Rollbar::Deploy).to_not receive(:report) |
| 378 | + |
| 379 | + expect(logger2).to receive(:important).with(/Failed(.*)No deploy id available/) |
| 380 | + |
| 381 | + subject.deploy_failed(capistrano, logger2, dry_run) |
| 382 | + end |
| 383 | + end |
327 | 384 | end |
328 | 385 | end |
329 | 386 |
|
|
0 commit comments