@@ -12,17 +12,15 @@ module ActionDispatch # :nodoc:
12
12
# back to the web browser) or a TestResponse (i.e. one that is generated
13
13
# from integration tests).
14
14
#
15
- # \Response is mostly a Ruby on \Rails framework implementation detail, and
16
- # should never be used directly in controllers. Controllers should use the
17
- # methods defined in ActionController::Base instead. For example, if you want
18
- # to set the HTTP response's content MIME type, then use
19
- # ActionControllerBase#headers instead of Response#headers.
15
+ # The \Response object for the current request is exposed on controllers as
16
+ # ActionController::Metal#response. ActionController::Metal also provides a
17
+ # few additional methods that delegate to attributes of the \Response such as
18
+ # ActionController::Metal#headers.
20
19
#
21
- # Nevertheless, integration tests may want to inspect controller responses in
22
- # more detail, and that's when \Response can be useful for application
23
- # developers. Integration test methods such as
24
- # Integration::RequestHelpers#get and Integration::RequestHelpers#post return
25
- # objects of type TestResponse (which are of course also of type \Response).
20
+ # Integration tests will likely also want to inspect responses in
21
+ # more detail. Methods such as Integration::RequestHelpers#get
22
+ # and Integration::RequestHelpers#post return instances of
23
+ # TestResponse (which inherits from \Response) for this purpose.
26
24
#
27
25
# For example, the following demo integration test prints the body of the
28
26
# controller response to the console:
@@ -63,7 +61,18 @@ def to_hash
63
61
# The HTTP status code.
64
62
attr_reader :status
65
63
66
- # Get headers for this response.
64
+ # The headers for the response.
65
+ #
66
+ # header["Content-Type"] # => "text/plain"
67
+ # header["Content-Type"] = "application/json"
68
+ # header["Content-Type"] # => "application/json"
69
+ #
70
+ # Also aliased as +headers+.
71
+ #
72
+ # headers["Content-Type"] # => "text/plain"
73
+ # headers["Content-Type"] = "application/json"
74
+ # headers["Content-Type"] # => "application/json"
75
+ #
67
76
attr_reader :header
68
77
69
78
alias_method :headers , :header
0 commit comments