Class: RuboCop::Cop::RSpec::ReceiveNever
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/receive_never.rb
Overview
Prefer `not_to receive(…)` over `receive(…).never`.
Constant Summary collapse
- MSG =
'Use `not_to receive` instead of `never`.'
- RESTRICT_ON_SEND =
%i[never].freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#method_on_stub?(node) ⇒ Object
22 |
# File 'lib/rubocop/cop/rspec/receive_never.rb', line 22 def_node_search :method_on_stub?, '(send nil? :receive ...)' |
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rubocop/cop/rspec/receive_never.rb', line 24 def on_send(node) return unless node.method?(:never) && method_on_stub?(node) add_offense(node.loc.selector) do |corrector| autocorrect(corrector, node) end end |