Class: RightDevelop::Testing::Client::Rest::Request::Record

Inherits:
Base
  • Object
show all
Defined in:
lib/right_develop/testing/clients/rest/requests/record.rb

Overview

Provides a middle-ware layer that intercepts response by overriding the logging mechanism built into rest-client Request. Request supports ‘before’ hooks (for request) but not ‘after’ hooks (for response) so logging is all we have.

Defined Under Namespace

Classes: TimeoutNetHttpResponse

Constant Summary

Constants inherited from Base

Base::METADATA_CLASS, Base::MUTEX

Instance Attribute Summary

Attributes inherited from Base

#fixtures_dir, #logger, #request_metadata, #request_timestamp, #response_metadata, #response_timestamp, #route_data, #route_path, #state_file_path

Instance Method Summary collapse

Methods inherited from Base

#forget_outstanding_request, #initialize

Constructor Details

This class inherits a constructor from RightDevelop::Testing::Client::Rest::Request::Base

Instance Method Details

#handle_timeoutObject

See Also:

  • Base.handle_timeout


88
89
90
91
92
93
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 88

def handle_timeout
  super
  response = TimeoutNetHttpResponse.new
  with_state_lock { |state| record_response(state, response) }
  response
end

#log_requestObject

Overrides log_request for basic logging.

Parameters:

  • to (RestClient::Response)

    capture

Returns:

  • (Object)

    undefined



71
72
73
74
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 71

def log_request
  logger.debug("proxied_url = #{@url.inspect}")
  super
end

#log_response(response) ⇒ Object

Overrides log_response to capture both request and response.

Parameters:

  • to (RestClient::Response)

    capture

Returns:

  • (Object)

    undefined



81
82
83
84
85
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 81

def log_response(response)
  result = super
  with_state_lock { |state| record_response(state, response) }
  result
end