Module: Typhoeus::Hydra::Stubbable Private

Included in:
Typhoeus::Hydra
Defined in:
lib/typhoeus/hydra/stubbable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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.

Since:

  • 0.5.0

Instance Method Summary collapse

Instance Method Details

#add(request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Examples:

Add the request.

hydra.add(request)

Since:

  • 0.5.0



17
18
19
20
21
22
23
24
25
# File 'lib/typhoeus/hydra/stubbable.rb', line 17

def add(request)
  if response = Expectation.response_for(request)
    request.execute_headers_callbacks(response)
    request.on_body.each{ |callback| callback.call(response.body, response) }
    request.finish(response)
  else
    super
  end
end