123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::TestResponse

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Response
Instance Chain:
self, Response, MonitorMixin, Http::Cache::Response, Http::FilterRedirect, Rack::Response::Helpers
Inherits: ActionDispatch::Response
Defined in: actionpack/lib/action_dispatch/testing/test_response.rb

Overview

Integration test methods such as ActionDispatch::Integration::Session#get and ActionDispatch::Integration::Session#post return objects of class TestResponse, which represent the HTTP response results of the requested controller actions.

See Response for more information on controller response objects.

Constant Summary

Http::Cache::Response - Included

CACHE_CONTROL, DATE, DEFAULT_CACHE_CONTROL, ETAG, LAST_MODIFIED, MUST_REVALIDATE, NO_CACHE, PRIVATE, PUBLIC, SPECIAL_KEYS

Response - Inherited

CONTENT_TYPE, EMPTY, LOCATION, NO_CONTENT_CODES, SET_COOKIE

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Response - Inherited

#body

Returns the content of the response as a string.

#body=

Allows you to manually set or override the response body.

#charset

The charset of the response.

#committed?,
#content_type

Sets the HTTP response's content MIME type.

#content_type=

Sets the HTTP content type.

#default_charset, #default_headers, #each,
#header

Get and set headers for this response.

#headers

Alias for Response#header.

#location

The location header we'll be responding with.

#location=

Sets the location header we'll be responding with.

#request

The request that the response is responding to.

#sending?, #sending_file=, #sent?,
#status

The HTTP status code.

#status=

Sets the HTTP status code.

#stream

The underlying body, as a streamable object.

Http::Cache::Response - Included

Instance Method Summary

Response - Inherited

#[], #[]=, #abort, #await_commit, #await_sent, #body_parts, #close,
#code

Returns a string to ensure compatibility with Net::HTTPResponse.

#commit!,
#cookies

Returns the response cookies, converted to a ::Hash of (name => value) pairs.

#delete_cookie,
#message

Returns the corresponding message for the current HTTP status code:

#prepare!

Alias for Response#to_a.

#rack_response,
#redirect_url
#response_code

The response code of the request.

#sending!, #sent!, #set_cookie,
#status_message

Alias for Response#message.

#to_a

Turns the Response into a Rack-compatible array of the status, headers, and body.

#to_ary

Be super clear that a response object is not an ::Array.

Http::Cache::Response - Included

Http::FilterRedirect - Included

Constructor Details

This class inherits a constructor from ActionDispatch::Response

Class Method Details

.from_response(response)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 9

def self.from_response(response)
  new response.status, response.headers, response.body, default_headers: nil
end

Instance Method Details

#error?

Was there a server-side error?

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 23

alias_method :error?, :server_error?

#missing?

Was the URL not found?

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 17

alias_method :missing?, :not_found?

#redirect?

Were we redirected?

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 20

alias_method :redirect?, :redirection?

#success?

Was the response successful?

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 14

alias_method :success?, :successful?