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.
173 174 175 176 177 |
# File 'lib/restclient/components.rb', line 173 def initialize(body, status, header) @body = body @status = status @header = header end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
170 171 172 |
# File 'lib/restclient/components.rb', line 170 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
170 171 172 |
# File 'lib/restclient/components.rb', line 170 def header @header end |
#status ⇒ Object (readonly) Also known as: code
Returns the value of attribute status.
170 171 172 |
# File 'lib/restclient/components.rb', line 170 def status @status end |
Instance Method Details
#to_hash ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/restclient/components.rb', line 179 def to_hash @header.inject({}) {|out, (key, value)| # In Net::HTTP, header values are arrays out[key] = [value] out } end |