Skip to content

Commit

Permalink
Do not treat test_ methods with arguments as test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Jan 17, 2023
1 parent 3f13db2 commit e7cea32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rubocop/cop/mixin/minitest_exploration_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7cea32

Please sign in to comment.