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 "Assert Nil" rule #2

Merged
merged 1 commit into from Aug 8, 2019
Merged

Add "Assert Nil" rule #2

merged 1 commit into from Aug 8, 2019

Commits on Aug 8, 2019

  1. Add "Assert Nil" rule

    Use `assert_nil` if expecting `nil`.
    
    ```ruby
    # bad
    assert_equal(nil, actual)
    
    # good
    assert_nil(actual)
    ```
    
    This rule prevents the following MT6's deprecated warning:
    
    ```ruby
    class ExampleTest < Minitest::Test
      def test_expecting_nil
        foo = nil
    
        assert_equal(nil, foo)
      end
    end
    ```
    
    ```console
    % bundle exec rake test
    Run options: --seed 16727
    
    # Running:
    
    DEPRECATED: Use assert_nil if expecting nil from
    /Users/koic/src/github.com/rubocop-hq/rubocop-minitest/test/rubocop/minitest_test.rb:13. This
    will fail in Minitest 6.
    ```
    
    https://github.com/seattlerb/minitest/blob/ab39d35fb4e84eb866ed9c4ecb707cbf3889de42/lib/minitest/assertions.rb#L203
    koic committed Aug 8, 2019
    Copy the full SHA
    a0afd37 View commit details
    Browse the repository at this point in the history