@@ -50,17 +50,13 @@ class MultipleExpectations < Cop
5050
5151 MSG = 'Example has too many expectations [%<total>d/%<max>d].'
5252
53- def_node_matcher :aggregate_failures? , <<-PATTERN
54- (block {
55- (send _ _ <(sym :aggregate_failures) ...>)
56- (send _ _ ... (hash <(pair (sym :aggregate_failures) true) ...>))
57- } ...)
58- PATTERN
53+ ANYTHING = -> ( _node ) { true }
54+ TRUE = -> ( node ) { node . true_type? }
5955
60- def_node_matcher :aggregate_failures_present ? , <<-PATTERN
56+ def_node_matcher :aggregate_failures ? , <<-PATTERN
6157 (block {
6258 (send _ _ <(sym :aggregate_failures) ...>)
63- (send _ _ ... (hash <(pair (sym :aggregate_failures) _ ) ...>))
59+ (send _ _ ... (hash <(pair (sym :aggregate_failures) %1 ) ...>))
6460 } ...)
6561 PATTERN
6662
@@ -89,12 +85,12 @@ def example_with_aggregate_failures?(example_node)
8985 node_with_aggregate_failures = find_aggregate_failures ( example_node )
9086 return false unless node_with_aggregate_failures
9187
92- aggregate_failures? ( node_with_aggregate_failures )
88+ aggregate_failures? ( node_with_aggregate_failures , TRUE )
9389 end
9490
9591 def find_aggregate_failures ( example_node )
9692 example_node . send_node . each_ancestor ( :block )
97- . find { |block_node | aggregate_failures_present ?( block_node ) }
93+ . find { |block_node | aggregate_failures ?( block_node , ANYTHING ) }
9894 end
9995
10096 def find_expectation ( node , &block )
0 commit comments