Specify host for Rails functional tests

ruby-on-rails, testing

Solution

Found my own solution:

def setup
  @request.host = 'test.example.com'
end

The @request object is reused between requests, so it only has to be set once.

Problem

Some of my controller actions use the request.host parameter in their logic. In integration tests I can use the `host!` method to set the host. How can the same be achieved in functional tests?

Original source

Related problems