Class: RuboCop::Cop::RSpec::ReceiveCounts
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/receive_counts.rb
Overview
Check for ‘once` and `twice` receive counts matchers usage.
Constant Summary collapse
- MSG =
'Use `%<alternative>s` instead of `%<original>s`.'
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Instance Method Details
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/rspec/receive_counts.rb', line 37 def on_send(node) receive_counts(node) do |offending_node| return unless stub?(offending_node.receiver) offending_range = range(node, offending_node) msg = (offending_node, offending_range.source) add_offense(offending_range, message: msg) do |corrector| autocorrect(corrector, offending_node, offending_range) end end end |