123456789_123456789_123456789_123456789_123456789_

Module: ActionDispatch::IntegrationTest::Behavior::ClassMethods

Relationships & Source Files
Defined in: actionpack/lib/action_dispatch/testing/integration.rb

Instance Attribute Summary

Instance Method Summary

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 ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 762

def app=(app)
  @@app = app
end

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 ::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 response body

Example

ActionDispatch::IntegrationTest.register_encoder :csv,
  param_encoder: -> params { params.map(&:to_csv).join("\n") },
  response_parser: -> body { CSV.parse(body) }
[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/testing/integration.rb', line 789

def register_encoder(*args, **options)
  RequestEncoder.register_encoder(*args, **options)
end