Skip to content

Commit

Permalink
[Fix rubocop#106] Fix an errof for Minitest/AssertOutput cop
Browse files Browse the repository at this point in the history
Fixes rubocop#106.

This PR fixes an error for `Minitest/AssertOutput` when using gvar at top level.
  • Loading branch information
koic committed Jul 17, 2020
1 parent ab80c8b commit 953a5b9
Show file tree
Hide file tree
Showing 3 changed files with 11 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

* [#106](https://github.com/rubocop-hq/rubocop-minitest/issues/106): Fix an error for `Minitest/AssertOutput` when using gvar at top level. ([@koic][])

## 0.10.0 (2020-07-12)

### New features
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_class?(class_node)
end

def test_case?(node)
return false unless node.def_type? && test_case_name?(node.method_name)
return false unless node&.def_type? && test_case_name?(node.method_name)

class_ancestor = node.each_ancestor(:class).first
test_class?(class_ancestor)
Expand Down
6 changes: 6 additions & 0 deletions test/rubocop/cop/minitest/assert_output_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ def test_do_something
end
RUBY
end

def test_does_not_register_offense_when_using_gvar_at_top_level
assert_no_offenses(<<~RUBY)
$foo = false
RUBY
end
end

0 comments on commit 953a5b9

Please sign in to comment.