Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Minitest/AssertPredicate and Minitest/RefutePredicate cops #161

Commits on Mar 2, 2022

  1. Add new Minitest/AssertPredicate and Minitest/RefutePredicate cops

    This PR adds new `Minitest/AssertPredicate` and `Minitest/RefutePredicate` cops.
    
    ## `Minitest/AssertPredicate` cop
    
    This cop enforces the test to use `assert_predicate`
    instead of using `assert(obj.a_predicate_method?)`.
    
    ```ruby
    # bad
    assert(obj.one?)
    assert(obj.one?, 'message')
    
    # good
    assert_predicate(obj, :one?)
    assert_predicate(obj, :one?, 'message')
    ```
    
    ## `Minitest/RefutePredicate` cop
    
    This cop enforces the test to use `refute_predicate`
    instead of using `refute(obj.a_predicate_method?)`.
    
    ```ruby
    # bad
    refute(obj.one?)
    refute(obj.one?, 'message')
    
    # good
    refute_predicate(obj, :one?)
    refute_predicate(obj, :one?, 'message')
    ```
    koic committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    4c38d48 View commit details
    Browse the repository at this point in the history