Class: ActionDispatch::TestResponse
- Inherits:
- Response show all
- Includes:
- DeprecatedHelpers
- 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.
Defined Under Namespace
Modules: DeprecatedHelpers
Constant Summary
Constant Summary
Constants inherited from Response
Response::CONTENT_TYPE, Response::EMPTY
Constants included from Http::Cache::Response
Http::Cache::Response::DEFAULT_CACHE_CONTROL
Instance Attribute Summary
Attributes included from DeprecatedHelpers
Attributes inherited from Response
#blank, #charset, #content_type, #header, #request, #sending_file
Attributes included from Http::Cache::Response
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Boolean) client_error?
Was there a client client?.
-
- (Boolean) error?
(also: #server_error?)
Was there a server-side error?.
-
- (Boolean) missing?
Was the URL not found?.
-
- (Boolean) redirect?
Were we redirected?.
-
- (Boolean) success?
Was the response successful?.
Methods included from DeprecatedHelpers
#assigns, #binary_content, #flash, #has_flash?, #has_flash_object?, #has_flash_with_contents?, #has_session_object?, #has_template_object?, #layout, #redirect_url_match?, #redirected_to, #rendered, #session, #template_objects
Methods inherited from Response
#body, #body=, #body_parts, #code, #cookies, #each, #location, #location=, #message, #respond_to?, #response_code, #status=, #to_a, #to_path, #write
Methods included from Http::Cache::Response
#etag, #etag=, #etag?, #initialize, #last_modified, #last_modified=, #last_modified?
Methods included from Response::Setup
Class Method Details
+ (Object) from_response(response)
9 10 11 12 13 14 15 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 9 def self.from_response(response) new.tap do |resp| resp.status = response.status resp.headers = response.headers resp.body = response.body end end |
Instance Method Details
- (Boolean) client_error?
Was there a client client?
132 133 134 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 132 def client_error? (400..499).include?(response_code) end |
- (Boolean) error? Also known as: server_error?
Was there a server-side error?
126 127 128 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 126 def error? (500..599).include?(response_code) end |
- (Boolean) missing?
Was the URL not found?
116 117 118 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 116 def missing? response_code == 404 end |
- (Boolean) redirect?
Were we redirected?
121 122 123 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 121 def redirect? (300..399).include?(response_code) end |
- (Boolean) success?
Was the response successful?
111 112 113 |
# File 'actionpack/lib/action_dispatch/testing/test_response.rb', line 111 def success? (200..299).include?(response_code) end |