lib/rubocop/cop/minitest/test_method_name.rb in rubocop-minitest-0.26.1 vs lib/rubocop/cop/minitest/test_method_name.rb in rubocop-minitest-0.27.0
- old
+ new
@@ -35,11 +35,11 @@
MSG = 'Test method name should start with `test_` prefix.'
def on_class(class_node)
return unless test_class?(class_node)
- class_elements(class_node).each do |node|
+ class_def_nodes(class_node).each do |node|
next unless offense?(node)
test_method_name = node.loc.name
add_offense(test_method_name) do |corrector|
@@ -47,20 +47,9 @@
end
end
end
private
-
- def class_elements(class_node)
- class_def = class_node.body
- return [] unless class_def
-
- if class_def.def_type?
- [class_def]
- else
- class_def.each_child_node(:def).to_a
- end
- end
def offense?(node)
return false if assertions(node).none?
public?(node) && node.arguments.empty? && !test_method_name?(node) && !lifecycle_hook_method?(node)