Class: RubstApi::TestResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/rubst_api/test_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ TestResponse

Returns a new instance of TestResponse.



6
7
8
9
10
# File 'lib/rubst_api/test_client.rb', line 6

def initialize(status, headers, body)
  @status, @headers = status, Headers.new(headers)
  @body = body.respond_to?(:each) ? body.to_a.join : body.to_s
  body.close if body.respond_to?(:close)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/rubst_api/test_client.rb', line 5

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/rubst_api/test_client.rb', line 5

def headers
  @headers
end

#statusObject (readonly) Also known as: status_code

Returns the value of attribute status.



5
6
7
# File 'lib/rubst_api/test_client.rb', line 5

def status
  @status
end

Instance Method Details

#jsonObject



12
# File 'lib/rubst_api/test_client.rb', line 12

def json = JSON.parse(body)

#success?Boolean

Returns:

  • (Boolean)


14
# File 'lib/rubst_api/test_client.rb', line 14

def success? = status.between?(200, 299)

#textObject



13
# File 'lib/rubst_api/test_client.rb', line 13

def text = body