class ActionDispatch::TestResponse
See Response for more information on controller response objects.
controller actions.
TestResponse, which represent the HTTP response results of the requested
and Integration::RequestHelpers#post return objects of class
Integration test methods such as Integration::RequestHelpers#get
def self.from_response(response)
def self.from_response(response) new response.status, response.headers, response.body end
def parsed_body
response.parsed_body.class # => Hash
response.content_type # => "application/json; charset=utf-8"
get "/posts/42.json"
response.parsed_body # => [{"id"=>42, "title"=>"Title"},...
response.parsed_body.class # => Array
response.content_type # => "application/json; charset=utf-8"
get "/posts.json"
response.parsed_body # => "\n\n..."
response.parsed_body.class # => String
response.content_type # => "text/html; charset=utf-8"
get "/posts"
==== Examples
corresponding to the MIME type is not found, it returns the raw body.
Returns a parsed body depending on the response MIME type. When a parser
def parsed_body @parsed_body ||= response_parser.call(body) end
def response_parser
def response_parser @response_parser ||= RequestEncoder.parser(media_type) end