lib/rubocop/cop/rspec/expect_change.rb in rubocop-rspec-2.10.0 vs lib/rubocop/cop/rspec/expect_change.rb in rubocop-rspec-2.11.0

- old
+ new

@@ -37,19 +37,19 @@ MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.' RESTRICT_ON_SEND = %i[change].freeze # @!method expect_change_with_arguments(node) def_node_matcher :expect_change_with_arguments, <<-PATTERN - (send nil? :change $_ (sym $_)) + (send nil? :change $_ ({sym str} $_)) PATTERN # @!method expect_change_with_block(node) def_node_matcher :expect_change_with_block, <<-PATTERN (block (send nil? :change) (args) - (send ({const send} nil? $_) $_) + (send $_ $_) ) PATTERN def on_send(node) return unless style == :block @@ -65,12 +65,12 @@ def on_block(node) return unless style == :method_call expect_change_with_block(node) do |receiver, message| - msg = format(MSG_BLOCK, obj: receiver, attr: message) + msg = format(MSG_BLOCK, obj: receiver.source, attr: message) add_offense(node, message: msg) do |corrector| - replacement = "change(#{receiver}, :#{message})" + replacement = "change(#{receiver.source}, :#{message})" corrector.replace(node, replacement) end end end end