Class: Skink::RackTestResponse

Inherits:
Client::Response show all
Defined in:
lib/skink/rack_test_client/rack_test_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client::Response

#find_header, #has_header?, #has_jsonpath?, #has_link_header?, #has_xpath?, #json_doc, #jsonpath, #links, #method_missing, #xml_doc, #xpath

Methods included from Client::Utils

#normalize_header_name

Constructor Details

#initialize(native_response) ⇒ RackTestResponse

Returns a new instance of RackTestResponse.



8
9
10
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 8

def initialize(native_response)
  @native_response = native_response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Skink::Client::Response

Instance Attribute Details

#native_responseObject (readonly)

Returns the value of attribute native_response.



6
7
8
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 6

def native_response
  @native_response
end

Instance Method Details

#bodyObject



32
33
34
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 32

def body
  native_response.body
end

#has_status_code?(code) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 16

def has_status_code? code
  native_response.status == code
end

#headersObject



20
21
22
23
24
25
26
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 20

def headers
  if native_response.is_a? Rack::Response
    native_response.header
  else
    native_response.headers
  end
end


28
29
30
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 28

def link_header
  headers["Link"]
end

#status_codeObject



12
13
14
# File 'lib/skink/rack_test_client/rack_test_response.rb', line 12

def status_code
  native_response.status
end