Module: ActionDispatch::IntegrationTest::Behavior::ClassMethods
| Relationships & Source Files | |
| Defined in: | actionpack/lib/action_dispatch/testing/integration.rb |
Instance Attribute Summary
- #app rw
- #app=(app) rw
Instance Method Summary
-
#register_encoder(mime_name, param_encoder: nil, response_parser: nil, content_type: nil)
Registers an encoder used to parse the response body returned by TestResponse#parsed_body.
Instance Attribute Details
#app (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 754
def app if defined?(@@app) && @@app @@app else ActionDispatch.test_app end end
#app=(app) (rw)
[ GitHub ]Instance Method Details
#register_encoder(mime_name, param_encoder: nil, response_parser: nil, content_type: nil)
Registers an encoder used to parse the response body returned by
TestResponse#parsed_body. ::ActionDispatch::IntegrationTest encodes and parses :html
and :json requests by default.
Arguments
mime_name- The MIME-compatible name
Options
:param_encoder- A callable that accepts a::Hashand returns an encoded value:response_parser- A callable that accepts the body::Stringand returns a parsed value:content_type- The String MIME type of the response body
Example
ActionDispatch::IntegrationTest.register_encoder :csv,
param_encoder: -> params { params.map(&:to_csv).join("\n") },
response_parser: -> body { CSV.parse(body) }
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 789
def register_encoder(*args, **) RequestEncoder.register_encoder(*args, **) end