From e7cea3270b4c7f4298f78c07f65b427515d095cb Mon Sep 17 00:00:00 2001 From: fatkodima Date: Tue, 17 Jan 2023 16:56:25 +0200 Subject: [PATCH] Do not treat `test_` methods with arguments as test methods --- lib/rubocop/cop/mixin/minitest_exploration_helpers.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb b/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb index 323524ac..dc76e22a 100644 --- a/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +++ b/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb @@ -27,14 +27,16 @@ 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) && !node.arguments? class_ancestor = node.each_ancestor(:class).first test_class?(class_ancestor) end def test_cases(class_node) - test_cases = class_def_nodes(class_node).select { |def_node| test_case_name?(def_node.method_name) } + test_cases = class_def_nodes(class_node).select do |def_node| + test_case_name?(def_node.method_name) && !def_node.arguments? + end # Support Active Support's `test 'example' { ... }` method. # https://api.rubyonrails.org/classes/ActiveSupport/Testing/Declarative.html