4

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?

Ralf
  • 14,655
  • 9
  • 48
  • 58

1 Answers1

7

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.

Ralf
  • 14,655
  • 9
  • 48
  • 58
  • 1
    For more information about manipulating the request variable, see http://stackoverflow.com/questions/2029488/change-value-of-request-remoteip-in-ruby-on-rails/ where the only difference is that the remote_ip was modified instead of host – Veger Jan 11 '10 at 12:00