lib/rubocop/cop/rspec/instance_spy.rb in rubocop-rspec-1.18.0 vs lib/rubocop/cop/rspec/instance_spy.rb in rubocop-rspec-1.19.0
- old
+ new
@@ -22,33 +22,33 @@
MSG = 'Use `instance_spy` when you check your double '\
'with `have_received`.'.freeze
EXAMPLES = Examples::ALL.node_pattern_union.freeze
- def_node_matcher :example?, "(block $(send nil #{EXAMPLES}) ...)"
+ def_node_matcher :example?, "(block $(send nil? #{EXAMPLES}) ...)"
def_node_search :null_double, <<-PATTERN
(lvasgn $_
(send
- $(send nil :instance_double
+ $(send nil? :instance_double
...) :as_null_object))
PATTERN
def_node_search :have_received_usage, <<-PATTERN
(send
- (send nil :expect
+ (send nil? :expect
(lvar $_)) :to
- (send nil :have_received
+ (send nil? :have_received
...)
...)
PATTERN
def on_block(node)
return unless example?(node)
null_double(node) do |var, receiver|
have_received_usage(node) do |expected|
- add_offense(receiver, :expression) if expected == var
+ add_offense(receiver, location: :expression) if expected == var
end
end
end
def autocorrect(node)