Sha256: 4e2a259a81871ab4d0676cfee07a7607e5bd85dba044f7152acca9ac3a6673ef

Contents?: true

Size: 854 Bytes

Versions: 6802

Compression:

Stored size: 854 Bytes

Contents

module Typhoeus
  class Request

    # 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.
    #
    # @api private
    module Stubbable

      # Override run in order to check for matching expectations.
      # When an expectation 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 response = Expectation.response_for(self)
          execute_headers_callbacks(response)
          self.on_body.each{ |callback| callback.call(response.body, response) }
          finish(response)
        else
          super
        end
      end
    end
  end
end

Version data entries

6,802 entries across 6,799 versions & 27 rubygems

Version Path
typhoeus-0.7.1 lib/typhoeus/request/stubbable.rb
typhoeus-0.7.0 lib/typhoeus/request/stubbable.rb