Class: RuboCop::Cop::RSpec::SingleArgumentMessageChain
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/single_argument_message_chain.rb
Overview
Checks that chains of messages contain more than one element.
Constant Summary collapse
- MSG =
'Use `%<recommended>s` instead of calling ' \ '`%<called>s` with a single argument.'
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
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/rspec/single_argument_message_chain.rb', line 31 def on_send(node) (node) do |arg| return if valid_usage?(arg) method = node.method_name msg = format(MSG, recommended: replacement(method), called: method) add_offense(node.loc.selector, message: msg) do |corrector| autocorrect(corrector, node, method, arg) end end end |