|
505 | 505 |
|
506 | 506 | context 'with compilation directory specified and matching' do |
507 | 507 | it 'should strip compilation directory' do |
| 508 | + allow(@test_obj).to receive(:compilation_dir) |
| 509 | + .and_return('/var/folders/dw/foo/environments/production') |
| 510 | + obj = { |
| 511 | + source: { |
| 512 | + 'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp', |
| 513 | + 'line' => 23, |
| 514 | + 'type' => 'Baz', |
| 515 | + 'title' => 'buzz' |
| 516 | + }, |
| 517 | + target_type: 'Foo', |
| 518 | + target_value: 'bar' |
| 519 | + } |
| 520 | + result = @test_obj.send(:format_missing_references, [obj]) |
| 521 | + expect(result).to eq('baz[buzz](/modules/foo/manifests/bar.pp:23) -> foo[bar]') |
508 | 522 | end |
509 | 523 | end |
510 | 524 |
|
511 | 525 | context 'with compilation directory specified and not matching' do |
512 | 526 | it 'should not strip compilation directory' do |
| 527 | + allow(@test_obj).to receive(:compilation_dir) |
| 528 | + .and_return('/var/folders/dw/bar/environments/production') |
| 529 | + obj = { |
| 530 | + source: { |
| 531 | + 'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp', |
| 532 | + 'line' => 23, |
| 533 | + 'type' => 'Baz', |
| 534 | + 'title' => 'buzz' |
| 535 | + }, |
| 536 | + target_type: 'Foo', |
| 537 | + target_value: 'bar' |
| 538 | + } |
| 539 | + result = @test_obj.send(:format_missing_references, [obj]) |
| 540 | + expect(result).to eq('baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]') |
513 | 541 | end |
514 | 542 | end |
515 | 543 |
|
516 | 544 | context 'with compilation directory not specified' do |
517 | 545 | it 'should not strip compilation directory' do |
| 546 | + allow(@test_obj).to receive(:compilation_dir).and_return(nil) |
| 547 | + obj = { |
| 548 | + source: { |
| 549 | + 'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp', |
| 550 | + 'line' => 23, |
| 551 | + 'type' => 'Baz', |
| 552 | + 'title' => 'buzz' |
| 553 | + }, |
| 554 | + target_type: 'Foo', |
| 555 | + target_value: 'bar' |
| 556 | + } |
| 557 | + result = @test_obj.send(:format_missing_references, [obj]) |
| 558 | + expect(result).to eq('baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]') |
| 559 | + end |
| 560 | + end |
| 561 | + |
| 562 | + context 'with multiple targets for the same resource' do |
| 563 | + it 'should display each target separately' do |
| 564 | + allow(@test_obj).to receive(:compilation_dir).and_return(nil) |
| 565 | + src = { |
| 566 | + 'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp', |
| 567 | + 'line' => 23, |
| 568 | + 'type' => 'Baz', |
| 569 | + 'title' => 'buzz' |
| 570 | + } |
| 571 | + obj = [ |
| 572 | + { |
| 573 | + source: src, |
| 574 | + target_type: 'Foo', |
| 575 | + target_value: 'bar' |
| 576 | + }, |
| 577 | + { |
| 578 | + source: src, |
| 579 | + target_type: 'Fizz', |
| 580 | + target_value: 'buzz' |
| 581 | + } |
| 582 | + ] |
| 583 | + answer = [ |
| 584 | + 'baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]', |
| 585 | + 'baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> fizz[buzz]' |
| 586 | + ].join('; ') |
| 587 | + result = @test_obj.send(:format_missing_references, obj) |
| 588 | + expect(result).to eq(answer) |
518 | 589 | end |
519 | 590 | end |
520 | 591 | end |
|
0 commit comments