@@ -50,17 +50,13 @@ class MultipleExpectations < Cop
50
50
51
51
MSG = 'Example has too many expectations [%<total>d/%<max>d].'
52
52
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? }
59
55
60
- def_node_matcher :aggregate_failures_present ? , <<-PATTERN
56
+ def_node_matcher :aggregate_failures ? , <<-PATTERN
61
57
(block {
62
58
(send _ _ <(sym :aggregate_failures) ...>)
63
- (send _ _ ... (hash <(pair (sym :aggregate_failures) _ ) ...>))
59
+ (send _ _ ... (hash <(pair (sym :aggregate_failures) %1 ) ...>))
64
60
} ...)
65
61
PATTERN
66
62
@@ -89,12 +85,12 @@ def example_with_aggregate_failures?(example_node)
89
85
node_with_aggregate_failures = find_aggregate_failures ( example_node )
90
86
return false unless node_with_aggregate_failures
91
87
92
- aggregate_failures? ( node_with_aggregate_failures )
88
+ aggregate_failures? ( node_with_aggregate_failures , TRUE )
93
89
end
94
90
95
91
def find_aggregate_failures ( example_node )
96
92
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 ) }
98
94
end
99
95
100
96
def find_expectation ( node , &block )
0 commit comments