lib/rubocop/cop/rspec/multiple_expectations.rb in rubocop-rspec-1.15.1 vs lib/rubocop/cop/rspec/multiple_expectations.rb in rubocop-rspec-1.16.0
- old
+ new
@@ -46,18 +46,18 @@
# end
#
class MultipleExpectations < Cop
include ConfigurableMax
- MSG = 'Example has too many expectations [%{total}/%{max}].'.freeze
+ MSG = 'Example has too many expectations [%<total>d/%<max>d].'.freeze
def_node_search :with_aggregated_failures?, '(sym :aggregate_failures)'
def_node_search :disabled_aggregated_failures?, <<-PATTERN
(pair (sym :aggregate_failures) (false))
PATTERN
- def_node_matcher :expect?, '(send _ :expect ...)'
+ def_node_matcher :expect?, Expectations::ALL.send_pattern
def_node_matcher :aggregate_failures?, <<-PATTERN
(block (send _ :aggregate_failures ...) ...)
PATTERN
def on_block(node)
@@ -82,17 +82,15 @@
with_aggregated_failures?(example) &&
!disabled_aggregated_failures?(example)
end
def find_expectation(node, &block)
- return unless node.is_a?(Parser::AST::Node)
-
yield if expect?(node) || aggregate_failures?(node)
# do not search inside of aggregate_failures block
return if aggregate_failures?(node)
- node.children.each do |child|
+ node.each_child_node do |child|
find_expectation(child, &block)
end
end
def flag_example(node, expectation_count:)