lib/rubocop/cop/rspec/receive_never.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/receive_never.rb in rubocop-rspec-1.33.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module RuboCop
module Cop
module RSpec
# Prefer `not_to receive(...)` over `receive(...).never`.
#
@@ -10,14 +12,12 @@
#
# # good
# expect(foo).not_to receive(:bar)
#
class ReceiveNever < Cop
- include RangeHelp
+ MSG = 'Use `not_to receive` instead of `never`.'
- MSG = 'Use `not_to receive` instead of `never`.'.freeze
-
def_node_search :method_on_stub?, '(send nil? :receive ...)'
def on_send(node)
return unless node.method_name == :never && method_on_stub?(node)
@@ -28,13 +28,10 @@
end
def autocorrect(node)
lambda do |corrector|
corrector.replace(node.parent.loc.selector, 'not_to')
- range = range_between(
- node.loc.dot.begin_pos,
- node.loc.selector.end_pos
- )
+ range = node.loc.dot.with(end_pos: node.loc.selector.end_pos)
corrector.remove(range)
end
end
end
end