Search code examples
ruby-on-railsrspec

How do I change the default "www.example.com" domain for testing in rails?


I have a rails application which acts differently depending on what domain it's accessed at (for example www.myapp.com will invoke differently to user.myapp.com). In production use this all works fine but my test code always sees a hostname of "www.example.com".

Is there a clean way of having a test specify the hostname it's pretending to access?


Solution

  • @request.host = 'user.myapp.com'