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
229 230 231 |
# File 'lib/syntropy/test.rb', line 229 def response_body adapter.response_body end |
#response_content_type ⇒ String?
Returns the response content MIME type.
244 245 246 247 248 249 250 251 252 |
# File 'lib/syntropy/test.rb', line 244 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.
258 259 260 261 262 263 264 265 266 |
# File 'lib/syntropy/test.rb', line 258 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.
215 216 217 |
# File 'lib/syntropy/test.rb', line 215 def response_headers adapter.response_headers end |
#response_json ⇒ any
Parses the response body from JSON.
236 237 238 239 |
# File 'lib/syntropy/test.rb', line 236 def response_json raise if response_content_type != 'application/json' JSON.parse(response_body) end |
#response_status ⇒ Integer
Returns the response status
222 223 224 |
# File 'lib/syntropy/test.rb', line 222 def response_status adapter.status end |