Sha256: 553492f259d210c340b0c9d9b4c1a7d38656a32b4fd1bdeff0067c14964b8f7e

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

module Typhoeus
  module Hydras

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

      # Override queue 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 Queue the request.
      #   hydra.queue(request)
      def queue(request)
        if expectation = Expectation.find_by(request)
          request.response = expectation.response
          request.response.mock = true
          request.execute_callbacks
          request.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/hydras/stubbable.rb