Module: RSpec::Httpd::Client::ResponseParser

Defined in:
lib/rspec/httpd/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#__response__Object

Returns the value of attribute __response__.



128
129
130
# File 'lib/rspec/httpd/client.rb', line 128

def __response__
  @__response__
end

Class Method Details

.parse(response) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/rspec/httpd/client.rb', line 112

def self.parse(response)
  return nil if response.body.nil?

  content_type = response["content-type"]

  result = if content_type&.include?("application/json")
             JSON.parse(response.body)
           else
             response.body.force_encoding("utf-8").encode
           end

  result.extend(self)
  result.__response__ = response
  result
end

Instance Method Details

#statusObject



130
131
132
# File 'lib/rspec/httpd/client.rb', line 130

def status
  Integer(__response__.code)
end