Skip to content

Commit

Permalink
Merge pull request #57 from koic/fix_an_error_for_assert_includes
Browse files Browse the repository at this point in the history
[Fix #55] Fix an error for `Minitest/AssertIncludes`
  • Loading branch information
koic authored Feb 19, 2020
2 parents c1ba951 + 00a6d1c commit adcf02e
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 adcf02e

Please sign in to comment.