Skip to Content Skip to Search
Methods
A
R

Instance Public methods

app()

# 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)

# File actionpack/lib/action_dispatch/testing/integration.rb, line 762
def app=(app)
  @@app = app
end

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. 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 Hash and returns an encoded value

  • :response_parser - A callable that accepts the body String and returns a parsed value

  • :content_type - The String MIME type of the request 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, **options)
  RequestEncoder.register_encoder(*args, **options)
end