|
12 | 12 | subject(:run) { task.run }
|
13 | 13 |
|
14 | 14 | it do
|
| 15 | + expect(task).to receive(:check_warnings!).ordered |
15 | 16 | expect(task).to receive(:activate_main_extensions).ordered
|
16 | 17 | expect(task).to receive(:autostart_profiler).ordered
|
17 | 18 | run
|
|
346 | 347 | end
|
347 | 348 | end
|
348 | 349 | end
|
| 350 | + |
| 351 | + describe '#check_warnings!' do |
| 352 | + subject(:check_warnings!) { task.check_warnings! } |
| 353 | + |
| 354 | + it do |
| 355 | + expect(task).to receive(:warn_if_incompatible_rollbar_gem_detected) |
| 356 | + |
| 357 | + check_warnings! |
| 358 | + end |
| 359 | + end |
| 360 | + |
| 361 | + describe '#warn_if_incompatible_rollbar_gem_detected' do |
| 362 | + subject(:warn_if_incompatible_rollbar_gem_detected) { task.warn_if_incompatible_rollbar_gem_detected } |
| 363 | + |
| 364 | + let(:last_version_of_rollbar_affected) { '3.1.1' } |
| 365 | + |
| 366 | + before do |
| 367 | + # Simulate the result of the gem apis, so that we can check different combinations of having or not having the |
| 368 | + # rollbar gem and affected versions |
| 369 | + expect(Gem::Specification) |
| 370 | + .to receive(:find_all_by_name) |
| 371 | + .with('rollbar', Gem::Requirement.new("<= #{last_version_of_rollbar_affected}")) |
| 372 | + .and_return(rollbar_versions_found) |
| 373 | + end |
| 374 | + |
| 375 | + context 'when rollbar gem is not installed' do |
| 376 | + let(:rollbar_versions_found) { [] } |
| 377 | + |
| 378 | + it 'does not display a warning to STDOUT' do |
| 379 | + expect(STDOUT).to_not receive(:puts) |
| 380 | + |
| 381 | + warn_if_incompatible_rollbar_gem_detected |
| 382 | + end |
| 383 | + end |
| 384 | + |
| 385 | + context 'when compatible version of rollbar gem is installed' do |
| 386 | + # same as "no gem installed" because we use a version requirement when |
| 387 | + # calling find_all_by_name, so only incompatible versions get returned |
| 388 | + let(:rollbar_versions_found) { [] } |
| 389 | + |
| 390 | + it 'does not display a warning to STDOUT' do |
| 391 | + expect(STDOUT).to_not receive(:puts) |
| 392 | + |
| 393 | + warn_if_incompatible_rollbar_gem_detected |
| 394 | + end |
| 395 | + end |
| 396 | + |
| 397 | + context 'when incompatible version of rollbar gem is installed' do |
| 398 | + let(:rollbar_versions_found) { [instance_double(Gem::Specification), instance_double(Gem::Specification)] } |
| 399 | + |
| 400 | + it 'displays a warning to STDOUT' do |
| 401 | + expect(STDOUT).to receive(:puts) do |message| |
| 402 | + expect(message).to include('Incompatible version of the rollbar') |
| 403 | + end |
| 404 | + |
| 405 | + warn_if_incompatible_rollbar_gem_detected |
| 406 | + end |
| 407 | + end |
| 408 | + end |
349 | 409 | end
|
0 commit comments