Capybara (and Cucumber) and Domains
While hacking on a new application, it took a good few weeks to find out how to, using cucumber and Capybara, interact with domains that weren’t localhost. Consider this a note to my future self :)
Let’s imagine your Rails application has a parimary domain and allows users to have subdomains (as if, granted by the power of subdomain-fu). By default, everything is hitting localhost, for example:
To get around this, you can tell Capybara to use a different domain:
I found it useful to make a step to navigate to a particular domain:
Armed with this, we can write our features: