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
220 221 222 |
# File 'lib/syntropy/test.rb', line 220 def response_body adapter.response_body end |
#response_content_type ⇒ String?
Returns the response content MIME type.
235 236 237 238 239 240 241 242 243 |
# File 'lib/syntropy/test.rb', line 235 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.
249 250 251 252 253 254 255 256 257 |
# File 'lib/syntropy/test.rb', line 249 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.
206 207 208 |
# File 'lib/syntropy/test.rb', line 206 def response_headers adapter.response_headers end |
#response_json ⇒ any
Parses the response body from JSON.
227 228 229 230 |
# File 'lib/syntropy/test.rb', line 227 def response_json raise if response_content_type != 'application/json' JSON.parse(response_body) end |
#response_status ⇒ Integer
Returns the response status
213 214 215 |
# File 'lib/syntropy/test.rb', line 213 def response_status adapter.status end |