Class: RestClient::MockNetHTTPResponse
- Inherits:
-
Object
- Object
- RestClient::MockNetHTTPResponse
- Defined in:
- lib/restclient/components.rb
Overview
A class that mocks the behaviour of a Net::HTTPResponse class. It is required since RestClient::Response must be initialized with a class that responds to :code and :to_hash.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#status ⇒ Object
(also: #code)
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(body, status, header) ⇒ MockNetHTTPResponse
constructor
A new instance of MockNetHTTPResponse.
- #to_hash ⇒ Object
Constructor Details
#initialize(body, status, header) ⇒ MockNetHTTPResponse
Returns a new instance of MockNetHTTPResponse.
170 171 172 173 174 |
# File 'lib/restclient/components.rb', line 170 def initialize(body, status, header) @body = body @status = status @header = header end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
167 168 169 |
# File 'lib/restclient/components.rb', line 167 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
167 168 169 |
# File 'lib/restclient/components.rb', line 167 def header @header end |
#status ⇒ Object (readonly) Also known as: code
Returns the value of attribute status.
167 168 169 |
# File 'lib/restclient/components.rb', line 167 def status @status end |
Instance Method Details
#to_hash ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/restclient/components.rb', line 176 def to_hash @header.inject({}) {|out, (key, value)| # In Net::HTTP, header values are arrays out[key] = [value] out } end |