|
508 | 508 | end |
509 | 509 | end |
510 | 510 |
|
| 511 | + context 'with boolean assertions' do |
| 512 | + it 'registers an offense when using `assert_true`' do |
| 513 | + expect_offense(<<~RUBY) |
| 514 | + assert_true(a) |
| 515 | + ^^^^^^^^^^^^^^ Use `expect(a).to be(true)`. |
| 516 | + RUBY |
| 517 | + |
| 518 | + expect_correction(<<~RUBY) |
| 519 | + expect(a).to be(true) |
| 520 | + RUBY |
| 521 | + end |
| 522 | + |
| 523 | + it 'registers an offense when using `assert_true` with no parentheses' do |
| 524 | + expect_offense(<<~RUBY) |
| 525 | + assert_true a |
| 526 | + ^^^^^^^^^^^^^ Use `expect(a).to be(true)`. |
| 527 | + RUBY |
| 528 | + |
| 529 | + expect_correction(<<~RUBY) |
| 530 | + expect(a).to be(true) |
| 531 | + RUBY |
| 532 | + end |
| 533 | + |
| 534 | + it 'registers an offense when using `assert_true` with failure message' do |
| 535 | + expect_offense(<<~RUBY) |
| 536 | + assert_true a, "must be true" |
| 537 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(a).to(be(true), "must be true")`. |
| 538 | + RUBY |
| 539 | + |
| 540 | + expect_correction(<<~RUBY) |
| 541 | + expect(a).to(be(true), "must be true") |
| 542 | + RUBY |
| 543 | + end |
| 544 | + |
| 545 | + it 'registers an offense when using `assert_true` with ' \ |
| 546 | + 'multi-line arguments' do |
| 547 | + expect_offense(<<~RUBY) |
| 548 | + assert_true(a, |
| 549 | + ^^^^^^^^^^^^^^ Use `expect(a).to(be(true), "must be true")`. |
| 550 | + "must be true") |
| 551 | + RUBY |
| 552 | + |
| 553 | + expect_correction(<<~RUBY) |
| 554 | + expect(a).to(be(true), "must be true") |
| 555 | + RUBY |
| 556 | + end |
| 557 | + |
| 558 | + it 'registers an offense when using `assert_false`' do |
| 559 | + expect_offense(<<~RUBY) |
| 560 | + assert_false(a) |
| 561 | + ^^^^^^^^^^^^^^^ Use `expect(a).to be(false)`. |
| 562 | + RUBY |
| 563 | + |
| 564 | + expect_correction(<<~RUBY) |
| 565 | + expect(a).to be(false) |
| 566 | + RUBY |
| 567 | + end |
| 568 | + |
| 569 | + it 'registers an offense when using `assert_false` with no parentheses' do |
| 570 | + expect_offense(<<~RUBY) |
| 571 | + assert_false a |
| 572 | + ^^^^^^^^^^^^^^ Use `expect(a).to be(false)`. |
| 573 | + RUBY |
| 574 | + |
| 575 | + expect_correction(<<~RUBY) |
| 576 | + expect(a).to be(false) |
| 577 | + RUBY |
| 578 | + end |
| 579 | + |
| 580 | + it 'registers an offense when using `assert_false` with failure message' do |
| 581 | + expect_offense(<<~RUBY) |
| 582 | + assert_false a, "must be false" |
| 583 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(a).to(be(false), "must be false")`. |
| 584 | + RUBY |
| 585 | + |
| 586 | + expect_correction(<<~RUBY) |
| 587 | + expect(a).to(be(false), "must be false") |
| 588 | + RUBY |
| 589 | + end |
| 590 | + |
| 591 | + it 'registers an offense when using `assert_false` with ' \ |
| 592 | + 'multi-line arguments' do |
| 593 | + expect_offense(<<~RUBY) |
| 594 | + assert_false(a, |
| 595 | + ^^^^^^^^^^^^^^^ Use `expect(a).to(be(false), "must be false")`. |
| 596 | + "must be false") |
| 597 | + RUBY |
| 598 | + |
| 599 | + expect_correction(<<~RUBY) |
| 600 | + expect(a).to(be(false), "must be false") |
| 601 | + RUBY |
| 602 | + end |
| 603 | + end |
| 604 | + |
511 | 605 | context 'with predicate assertions' do |
512 | 606 | it 'registers an offense when using `assert_predicate` with ' \ |
513 | 607 | 'an actual predicate' do |
|
0 commit comments