lib/rubocop/cop/mocha_to_rspec/stubs_with_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|
            obj_stubs_x_with_y, returns, ret_val = *node
            obj_stubs_x, _with, *args = *obj_stubs_x_with_y
            subject, variant, method_name = *obj_stubs_x
            args_list = args.map(&:source).join(", ")
            allow_or_expect = case variant
                              when :stubs
                                "allow"
                              when :expects
                                "expect"
                              else
                                raise "Got #{variant}"
                              end
            replacement = "#{allow_or_expect}(#{subject.source}).to receive(#{method_name.source}).with(#{args_list}).and_return(#{ret_val.source})"
            corrector.replace(node.source_range, replacement)
          end
        end
def autocorrect ( node ) lambda do | corrector | obj_stubs_x_with_y , returns , ret_val = * node obj_stubs_x , _with , * args = * obj_stubs_x_with_y subject , variant , method_name = * obj_stubs_x args_list = args . map ( & :source ) . join ( ", " ) allow_or_expect = case variant when :stubs "allow" when :expects "expect" else raise "Got #{variant}" end replacement = "#{allow_or_expect}(#{subject.source}).to receive(#{method_name.source}).with(#{args_list}).and_return(#{ret_val.source})" corrector . replace ( node . source_range , replacement ) end end
TODO: Use seperate messages for allow/expect.
TODO : Use seperate messages for allow / expect .
node
<not_specific>