What is an ActionDispatch::TestResponse?
An ActionDispatch::TestResponse
class is a subclass of ActionDispatch::Response
with a couple of convenience methods for testing. It can return its own parsed body, using the encoder that the body was encoded with.
It can also assign itself a parser, so that calls to parsed_body
don't fail if the TestResponse was manually instantiated.
It has all of a normal Response
's behavior. It's not a "light" or "fake" version of a Response.
It used to have more behavior, back in 2009, before it was moved into the newly-introduced ActionDispatch component. ActionDispatch took over responsibility for HTTP libs and middleware, and that refactor appears to have allowed the TestResponse
to shed most of its responsibilities, except for the parsing convenience methods.