Skip to content

Commit

Permalink
[Fix rubocop#55] Fix an error for Minitest/AssertIncludes
Browse files Browse the repository at this point in the history
Fixes rubocop#55

This PR fixes an error for `Minitest/AssertIncludes` when using local
variable argument.
  • Loading branch information
koic committed Feb 19, 2020
1 parent c1ba951 commit 00a6d1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#55](https://github.com/rubocop-hq/rubocop-minitest/issues/55): Fix an error for `Minitest/AssertIncludes` when using local variable argument. ([@koic][])

## 0.6.1 (2020-02-18)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/includes_cop_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def rule(target_method:, prefer_method:)
def on_send(node)
return unless node.method?(:#{target_method})
return unless (arguments = peel_redundant_parentheses_from(node.arguments))
return unless arguments.first.method?(:include?)
return unless arguments.first.respond_to?(:method?) && arguments.first.method?(:include?)
add_offense(node, message: offense_message(arguments))
end
Expand Down
11 changes: 11 additions & 0 deletions test/rubocop/cop/minitest/assert_includes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ def test_do_something
end
RUBY
end

def test_does_not_registers_offense_when_using_assert_with_local_variable
assert_no_offenses(<<~RUBY)
class FooTest < Minitest::Test
def test_do_something
collection = []
assert(collection)
end
end
RUBY
end
end

0 comments on commit 00a6d1c

Please sign in to comment.