lib/rubocop/cop/minitest/test_method_name.rb in rubocop-minitest-0.10.2 vs lib/rubocop/cop/minitest/test_method_name.rb in rubocop-minitest-0.10.3

- old
+ new

@@ -2,10 +2,11 @@ module RuboCop module Cop module Minitest # This cop enforces that test method names start with `test_` prefix. + # It aims to prevent tests that aren't executed by forgetting to start test method name with `test_`. # # @example # # bad # class FooTest < Minitest::Test # def does_something @@ -18,10 +19,16 @@ # def test_does_something # assert_equal 42, do_something # end # end # + # # good + # class FooTest < Minitest::Test + # def helper_method(argument) + # end + # end + # class TestMethodName < Cop include MinitestExplorationHelpers include DefNode MSG = 'Test method name should start with `test_` prefix.' @@ -52,10 +59,12 @@ class_def.each_child_node(:def).to_a end end def offense?(node) - public?(node) && !test_method_name?(node) && !lifecycle_hook_method?(node) + return false if node.each_child_node(:send).none? { |send_node| assertion_method?(send_node.method_name) } + + public?(node) && node.arguments.empty? && !test_method_name?(node) && !lifecycle_hook_method?(node) end def public?(node) !non_public?(node) end