Class: Philiprehberger::HttpMock::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/http_mock/response.rb

Overview

Represents a stubbed HTTP response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status: 200, body: '', headers: {}) ⇒ Response

Returns a new instance of Response.

Parameters:

  • status (Integer) (defaults to: 200)

    the HTTP status code

  • body (String) (defaults to: '')

    the response body

  • headers (Hash) (defaults to: {})

    the response headers



19
20
21
22
23
# File 'lib/philiprehberger/http_mock/response.rb', line 19

def initialize(status: 200, body: '', headers: {})
  @status = status
  @body = body
  @headers = headers
end

Instance Attribute Details

#bodyString (readonly)

Returns the response body.

Returns:

  • (String)

    the response body



11
12
13
# File 'lib/philiprehberger/http_mock/response.rb', line 11

def body
  @body
end

#headersHash (readonly)

Returns the response headers.

Returns:

  • (Hash)

    the response headers



14
15
16
# File 'lib/philiprehberger/http_mock/response.rb', line 14

def headers
  @headers
end

#statusInteger (readonly)

Returns the HTTP status code.

Returns:

  • (Integer)

    the HTTP status code



8
9
10
# File 'lib/philiprehberger/http_mock/response.rb', line 8

def status
  @status
end