Class: ActionDispatch::TestResponse
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Response
|
|
Instance Chain:
|
|
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
DATE, DEFAULT_CACHE_CONTROL, LAST_MODIFIED, MUST_REVALIDATE, NO_CACHE, PRIVATE, PUBLIC, SPECIAL_KEYS
Response
- Inherited
CONTENT_TYPE, LOCATION, NO_CONTENT_CODES, NullContentTypeHeader, SET_COOKIE
Class Attribute Summary
Response
- Inherited
Class Method Summary
Instance Attribute Summary
-
#error? ⇒ Boolean
readonly
Was there a server-side error?
-
#missing? ⇒ Boolean
readonly
Was the URL not found?
-
#success? ⇒ Boolean
readonly
Was the response successful?
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. |
#charset= | Sets the HTTP character set. |
#committed?, | |
#content_type | Sets the HTTP response’s content MIME type. |
#content_type= | Sets the HTTP content type. |
#default_charset, #default_headers, | |
#header | Get headers for this response. |
#headers | Alias for Response#header. |
#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
#cache_control, #date, #date=, #date?, | |
#etag= | This method sets a weak ETag validator on the response so browsers and proxies may cache the response, keyed on the ETag. |
#etag?, #last_modified, #last_modified=, #last_modified?, #strong_etag=, | |
#strong_etag? | True if an ETag is set and it isn’t a weak validator (not preceded with W/). |
#weak_etag=, | |
#weak_etag? | True if an ETag is set and it’s a weak validator (preceded with W/). |
Instance Method Summary
Response
- Inherited
#[], #[]=, | |
#_cache_control | Aliasing these off because |
#_cache_control=, #abort, #await_commit, #await_sent, #body_parts, #close, | |
#code | Returns a string to ensure compatibility with |
#commit!, | |
#cookies | Returns the response cookies, converted to a |
#delete_header, #each, #get_header, #handle_no_content!, #has_header?, | |
#message | Returns the corresponding message for the current HTTP status code: |
#prepare! | Alias for Response#to_a. |
#rack_response, | |
#redirect_url | The location header we’ll be responding with. |
#reset_body!, | |
#response_code | The response code of the request. |
#send_file | Send the file stored at |
#sending!, #sent!, #set_header, | |
#status_message | Alias for Response#message. |
#to_a | Turns the |
#write |
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 13
def self.from_response(response) new response.status, response.headers, response.body end
Instance Attribute Details
#error? ⇒ Boolean
(readonly)
Was there a server-side error?
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 41
def error? ActiveSupport::Deprecation.warn(<<-MSG.squish) The error? predicate is deprecated and will be removed in Rails 6.0. Please use server_error? as provided by Rack::Response::Helpers. MSG server_error? end
#missing? ⇒ Boolean
(readonly)
Was the URL not found?
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 32
def missing? ActiveSupport::Deprecation.warn(<<-MSG.squish) The missing? predicate is deprecated and will be removed in Rails 6.0. Please use not_found? as provided by Rack::Response::Helpers. MSG not_found? end
#success? ⇒ Boolean
(readonly)
Was the response successful?
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 23
def success? ActiveSupport::Deprecation.warn(<<-MSG.squish) The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. MSG successful? end
Instance Method Details
#parsed_body
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 49
def parsed_body @parsed_body ||= @response_parser.call(body) end