Sha256: 3d528b75f7ae07086d918b7790527cd59becee8518dfd97460ee07e3f0c10df4

Contents?: true

Size: 697 Bytes

Versions: 8

Compression:

Stored size: 697 Bytes

Contents

module Typhoeus
  class Hydra

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

      # Override add 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 Add the request.
      #   hydra.add(request)
      def add(request)
        if response = Expectation.response_for(request)
          request.finish(response)
        else
          super
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typhoeus-0.7.0.pre1 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.9 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.8 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.7 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.6 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.5 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.4 lib/typhoeus/hydra/stubbable.rb
typhoeus-0.6.3 lib/typhoeus/hydra/stubbable.rb