lib/rubocop/cop/rspec/receive_counts.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/receive_counts.rb in rubocop-rspec-1.33.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module RuboCop
module Cop
module RSpec
# Check for `once` and `twice` receive counts matchers usage.
#
@@ -20,14 +22,12 @@
# expect(foo).to receive(:bar).at_least(:twice)
# expect(foo).to receive(:bar).at_most(:once)
# expect(foo).to receive(:bar).at_most(:twice).times
#
class ReceiveCounts < Cop
- include RangeHelp
+ MSG = 'Use `%<alternative>s` instead of `%<original>s`.'
- MSG = 'Use `%<alternative>s` instead of `%<original>s`.'.freeze
-
def_node_matcher :receive_counts, <<-PATTERN
(send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
PATTERN
def_node_search :stub?, '(send nil? :receive ...)'
@@ -76,12 +76,11 @@
".#{method}(:#{matcher})"
end
end
def range(node, offending_node)
- range_between(
- offending_node.loc.dot.begin_pos,
- node.loc.expression.end_pos
+ offending_node.loc.dot.with(
+ end_pos: node.loc.expression.end_pos
)
end
end
end
end