lib/rubocop/cop/mocha_to_rspec/stubs_with_no_args.rb
# TODO: Use seperate messages for allow/expect.
Use seperate messages for allow/expect.
Use seperate messages for allow / expect .
def autocorrect(node)
          lambda do |corrector|
            receiver, _with, *args = *node 
            args_list = args.map(&:source).join(", ")
            subject, variant, method_name = *receiver 
            allow_or_expect = case variant
                              when :stubs
                                "allow"
                              when :expects
                                "expect"
                              else
                                raise
                              end
            begin
              replacement = "#{allow_or_expect}(#{subject.source}).to receive(#{method_name.source}).and_return(#{args_list})"
            rescue => e
              require 'pry'; binding.pry
            end
            corrector.replace(node.source_range, replacement)
          end
        end
def autocorrect ( node ) lambda do | corrector | receiver , _with , * args = * node args_list = args . map ( & :source ) . join ( ", " ) subject , variant , method_name = * receiver allow_or_expect = case variant when :stubs "allow" when :expects "expect" else raise end begin replacement = "#{allow_or_expect}(#{subject.source}).to receive(#{method_name.source}).and_return(#{args_list})" rescue => e require 'pry' ; binding . pry end corrector . replace ( node . source_range , replacement ) end end
TODO: Use seperate messages for allow/expect.
TODO : Use seperate messages for allow / expect .
# ..., :with, :bar # Object, :stubs, :foo
node
<not_specific>