Class: SterlingApi::RemoteActions::MockResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/sterling_api/remote_actions.rb

Overview

for use in tests

options:

:ret_val    the Net::HTTP return value
            pass true for Net::HTTPSuccess, Net::HTTPRedirection
            pass false for all others

:body       the body 'returned' by the supposed Net::HTTP request

Instance Attribute Summary

Attributes inherited from Response

#body, #raw_response, #status

Instance Method Summary collapse

Methods inherited from Response

#errors, #failure?, #success?

Constructor Details

#initialize(options = {}) ⇒ MockResponse

Returns a new instance of MockResponse.



47
48
49
50
51
# File 'lib/sterling_api/remote_actions.rb', line 47

def initialize(options={})
  Struct.new('MockHttpResponse', :body) unless defined?(Struct::MockHttpResponse)
  mock_http_response = Struct::MockHttpResponse.new(options[:body])
  super(options[:ret_val], mock_http_response)
end