|
623 | 623 | end |
624 | 624 | end |
625 | 625 |
|
| 626 | + context 'with boolean assertions' do |
| 627 | + it 'registers an offense when using `assert_true`' do |
| 628 | + expect_offense(<<~RUBY) |
| 629 | + assert_true(a) |
| 630 | + ^^^^^^^^^^^^^^ Use `expect(a).to be(true)`. |
| 631 | + RUBY |
| 632 | + |
| 633 | + expect_correction(<<~RUBY) |
| 634 | + expect(a).to be(true) |
| 635 | + RUBY |
| 636 | + end |
| 637 | + |
| 638 | + it 'registers an offense when using `assert_true` with no parentheses' do |
| 639 | + expect_offense(<<~RUBY) |
| 640 | + assert_true a |
| 641 | + ^^^^^^^^^^^^^ Use `expect(a).to be(true)`. |
| 642 | + RUBY |
| 643 | + |
| 644 | + expect_correction(<<~RUBY) |
| 645 | + expect(a).to be(true) |
| 646 | + RUBY |
| 647 | + end |
| 648 | + |
| 649 | + it 'registers an offense when using `assert_true` with failure message' do |
| 650 | + expect_offense(<<~RUBY) |
| 651 | + assert_true a, "must be true" |
| 652 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(a).to(be(true), "must be true")`. |
| 653 | + RUBY |
| 654 | + |
| 655 | + expect_correction(<<~RUBY) |
| 656 | + expect(a).to(be(true), "must be true") |
| 657 | + RUBY |
| 658 | + end |
| 659 | + |
| 660 | + it 'registers an offense when using `assert_true` with ' \ |
| 661 | + 'multi-line arguments' do |
| 662 | + expect_offense(<<~RUBY) |
| 663 | + assert_true(a, |
| 664 | + ^^^^^^^^^^^^^^ Use `expect(a).to(be(true), "must be true")`. |
| 665 | + "must be true") |
| 666 | + RUBY |
| 667 | + |
| 668 | + expect_correction(<<~RUBY) |
| 669 | + expect(a).to(be(true), "must be true") |
| 670 | + RUBY |
| 671 | + end |
| 672 | + |
| 673 | + it 'registers an offense when using `assert_false`' do |
| 674 | + expect_offense(<<~RUBY) |
| 675 | + assert_false(a) |
| 676 | + ^^^^^^^^^^^^^^^ Use `expect(a).to be(false)`. |
| 677 | + RUBY |
| 678 | + |
| 679 | + expect_correction(<<~RUBY) |
| 680 | + expect(a).to be(false) |
| 681 | + RUBY |
| 682 | + end |
| 683 | + |
| 684 | + it 'registers an offense when using `assert_false` with no parentheses' do |
| 685 | + expect_offense(<<~RUBY) |
| 686 | + assert_false a |
| 687 | + ^^^^^^^^^^^^^^ Use `expect(a).to be(false)`. |
| 688 | + RUBY |
| 689 | + |
| 690 | + expect_correction(<<~RUBY) |
| 691 | + expect(a).to be(false) |
| 692 | + RUBY |
| 693 | + end |
| 694 | + |
| 695 | + it 'registers an offense when using `assert_false` with failure message' do |
| 696 | + expect_offense(<<~RUBY) |
| 697 | + assert_false a, "must be false" |
| 698 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `expect(a).to(be(false), "must be false")`. |
| 699 | + RUBY |
| 700 | + |
| 701 | + expect_correction(<<~RUBY) |
| 702 | + expect(a).to(be(false), "must be false") |
| 703 | + RUBY |
| 704 | + end |
| 705 | + |
| 706 | + it 'registers an offense when using `assert_false` with ' \ |
| 707 | + 'multi-line arguments' do |
| 708 | + expect_offense(<<~RUBY) |
| 709 | + assert_false(a, |
| 710 | + ^^^^^^^^^^^^^^^ Use `expect(a).to(be(false), "must be false")`. |
| 711 | + "must be false") |
| 712 | + RUBY |
| 713 | + |
| 714 | + expect_correction(<<~RUBY) |
| 715 | + expect(a).to(be(false), "must be false") |
| 716 | + RUBY |
| 717 | + end |
| 718 | + end |
| 719 | + |
626 | 720 | context 'with predicate assertions' do |
627 | 721 | it 'registers an offense when using `assert_predicate` with ' \ |
628 | 722 | 'an actual predicate' do |
|
0 commit comments