Class: Wajub::MockTransport
- Inherits:
-
Object
- Object
- Wajub::MockTransport
- Defined in:
- lib/wajub/http/base_client.rb
Instance Attribute Summary collapse
-
#last_request ⇒ Object
readonly
Returns the value of attribute last_request.
Instance Method Summary collapse
- #call(method:, path:, headers:, body:, query:) ⇒ Object
-
#initialize(responses) ⇒ MockTransport
constructor
A new instance of MockTransport.
Constructor Details
#initialize(responses) ⇒ MockTransport
Returns a new instance of MockTransport.
160 161 162 163 164 |
# File 'lib/wajub/http/base_client.rb', line 160 def initialize(responses) @responses = responses @index = 0 @last_request = nil end |
Instance Attribute Details
#last_request ⇒ Object (readonly)
Returns the value of attribute last_request.
158 159 160 |
# File 'lib/wajub/http/base_client.rb', line 158 def last_request @last_request end |
Instance Method Details
#call(method:, path:, headers:, body:, query:) ⇒ Object
166 167 168 169 170 171 |
# File 'lib/wajub/http/base_client.rb', line 166 def call(method:, path:, headers:, body:, query:) @last_request = { method: method, path: path, headers: headers, body: body, query: query } response = @responses[@index] || { status: 200, body: {} } @index += 1 response.merge(request: @last_request) end |