diff --git a/lib/rubocop/cop/minitest/multiple_assertions.rb b/lib/rubocop/cop/minitest/multiple_assertions.rb index c0224abd..c75f2b6b 100644 --- a/lib/rubocop/cop/minitest/multiple_assertions.rb +++ b/lib/rubocop/cop/minitest/multiple_assertions.rb @@ -49,12 +49,6 @@ def on_class(class_node) private - def assertions_count(node) - node.each_descendant(:send).count do |send_node| - assertion_method?(send_node) - end - end - def max_assertions Integer(cop_config.fetch('Max', 3)) end diff --git a/lib/rubocop/cop/minitest/no_assertions.rb b/lib/rubocop/cop/minitest/no_assertions.rb index b63d719b..b0eea3f7 100644 --- a/lib/rubocop/cop/minitest/no_assertions.rb +++ b/lib/rubocop/cop/minitest/no_assertions.rb @@ -35,13 +35,6 @@ def on_class(class_node) add_offense(node.block_type? ? node.loc.expression : node.loc.name) end end - - private - - def assertions_count(node) - base = assertion_method?(node) ? 1 : 0 - base + node.each_child_node.sum { |c| assertions_count(c) } - end end end end diff --git a/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb b/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb index 0ec865ad..d0a640b0 100644 --- a/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb +++ b/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb @@ -86,6 +86,12 @@ def assertions(def_node) send_nodes.select { |send_node| assertion_method?(send_node) } end + def assertions_count(node) + node.each_descendant(:send).count do |send_node| + assertion_method?(send_node) + end + end + def assertion_method?(node) return false if !node.send_type? && !node.block_type?