Sha256: 87371aa0e412b07f53929a9404c02e5ab84d08c5244ece0992d7f2421f178290

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

module Typhoeus
  module Requests

    # This module handles stubbing on the request side.
    # It plays well with the block_connection configuration,
    # which raises when you make a request which is not stubbed.
    module Stubbable

      # Override run in order to check for matching expecations.
      # When an expecation is found, super is not called. Instead a
      # canned response is assigned to the request.
      #
      # @example Run the request.
      #   request.run
      #
      # @return [ Response ] The response.
      def run
        if expectation = Expectation.find_by(self)
          @response = expectation.response
          @response.mock = true
          execute_callbacks
          @response
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typhoeus-0.5.0.alpha lib/typhoeus/requests/stubbable.rb