Module: Syntropy::TestRequestExtensions
- Included in:
- Request
- Defined in:
- lib/syntropy/test.rb
Overview
Extensions to Syntropy::Request for testing.
Instance Method Summary collapse
-
#response_body ⇒ String?
Returns the response body.
-
#response_content_type ⇒ String?
Returns the response content MIME type.
-
#response_cookie(name) ⇒ String?
Returns the cookie value for the given cookie name from the response.
-
#response_headers ⇒ Hash
Returns the response headers.
-
#response_json ⇒ any
Parses the response body from JSON.
-
#response_status ⇒ Integer
Returns the response status.
Instance Method Details
#response_body ⇒ String?
Returns the response body
202 203 204 |
# File 'lib/syntropy/test.rb', line 202 def response_body adapter.response_body end |
#response_content_type ⇒ String?
Returns the response content MIME type.
217 218 219 220 221 222 223 224 225 |
# File 'lib/syntropy/test.rb', line 217 def response_content_type ct = response_headers['Content-Type'] return nil if !ct m = ct.match(/^([^;]+)/) return nil if !m m[1] end |
#response_cookie(name) ⇒ String?
Returns the cookie value for the given cookie name from the response.
231 232 233 234 235 236 237 238 239 |
# File 'lib/syntropy/test.rb', line 231 def (name) sc = response_headers['Set-Cookie'] return nil if !sc m = sc.match(/#{name}=([^\s]+)$/) return nil if !m m[1] end |
#response_headers ⇒ Hash
Returns the response headers.
188 189 190 |
# File 'lib/syntropy/test.rb', line 188 def response_headers adapter.response_headers end |
#response_json ⇒ any
Parses the response body from JSON.
209 210 211 212 |
# File 'lib/syntropy/test.rb', line 209 def response_json raise if response_content_type != 'application/json' JSON.parse(response_body) end |
#response_status ⇒ Integer
Returns the response status
195 196 197 |
# File 'lib/syntropy/test.rb', line 195 def response_status adapter.status end |