class StubRequests::RequestStub

Class Stub tracks the WebMock::RequestStub life cycle

@author Mikael Henriksson <mikael@zoolutions.se> @since 0.1.2

Public Class Methods

new(endpoint_id, webmock_stub) click to toggle source

Initialize a new Record

@param [Endpoint] endpoint_id the id of a stubbed endpoint @param [WebMock::RequestStub] webmock_stub the stubbed webmock request

# File lib/stub_requests/request_stub.rb, line 63
def initialize(endpoint_id, webmock_stub)
  request_pattern     = webmock_stub.request_pattern
  self.endpoint_id    = endpoint_id
  self.verb           = request_pattern.method_pattern.to_s.to_sym
  self.request_uri    = request_pattern.uri_pattern.to_s
  self.webmock_stub   = webmock_stub
  self.recorded_at    = Time.now
  self.recorded_from  = RSpec.current_example.metadata[:location]
  @responded_at = nil # ByPass the validation for the initializer
end

Public Instance Methods

endpoint() click to toggle source

Retrieve the endpoint for this request stub

@return [Endpoint] <description>

# File lib/stub_requests/request_stub.rb, line 80
def endpoint
  EndpointRegistry.instance[endpoint_id]
end
mark_as_responded() click to toggle source

Marks this record as having responded

@return [Time] the time it was marked responded

# File lib/stub_requests/request_stub.rb, line 90
def mark_as_responded
  self.responded_at = Time.now
end