lib/rubocop/cop/rspec/multiple_expectations.rb in rubocop-rspec-1.9.1 vs lib/rubocop/cop/rspec/multiple_expectations.rb in rubocop-rspec-1.10.0
- old
+ new
@@ -46,14 +46,12 @@
# end
#
class MultipleExpectations < Cop
include ConfigurableMax
- MSG = 'Too many expectations.'.freeze
+ MSG = 'Example has too many expectations [%{total}/%{max}]'.freeze
- def_node_matcher :example?, Examples::ALL.block_pattern
-
def_node_search :expect, '(send _ :expect ...)'
def on_block(node)
return unless example?(node) && (expectations = expect(node))
@@ -70,10 +68,10 @@
method, = *node
add_offense(
method,
:expression,
- MSG % { total: expectation_count, max: max_expectations }
+ format(MSG, total: expectation_count, max: max_expectations)
)
end
def max_expectations
Integer(cop_config.fetch('Max', 1))