Skip to content

Commit

Permalink
Merge pull request #197 from krishanbhasin-shopify/master
Browse files Browse the repository at this point in the history
Fix a false positive for `Minitest/EmptyLineBeforeAssertionMethods`
  • Loading branch information
koic authored Nov 11, 2022
2 parents e822d6e + 8802a80 commit dca5659
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#189](https://github.com/rubocop/rubocop-minitest/issues/189): Fix a false positive for `Minitest/EmptyLineBeforeAssertionMethods` when using an assertion method as the first line within a test block([@ryanquanz][])
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def on_send(node)
def assertion_method(node)
return node if assertion_method?(node)
return unless (parent = node.parent)
return unless parent.block_type?
return if parent.method?(:test)

node.parent if parent.block_type? && parent.body && assertion_method?(parent.body)
node.parent if parent.body && assertion_method?(parent.body)
end

def accept_previous_line?(previous_line_node, node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,14 @@ def test_does_not_register_offense_when_using_only_non_assertion_method
do_something(thing)
RUBY
end

def test_does_not_register_offense_when_using_assertion_method_as_first_line_in_test_block_at_top_of_class
assert_no_offenses(<<~RUBY)
class FooTest < Minitest::Test
test "do something" do
assert_equal(expected, actual)
end
end
RUBY
end
end

0 comments on commit dca5659

Please sign in to comment.