Note that there are some explanatory texts on larger screens.

plurals
  1. PORails, Cucumber, Capybara, Selenium, Pow, domains, subdomains and javascript
    primarykey
    data
    text
    <p>TL:DR - How can I make Cucumber request a page through the app but pretend that the request came from "http://mysubdomain.mydomain.dev", and run the javascript properly?</p> <p>Ok, this may take a while to explain, but please bear with me...</p> <p>I'm a 'relatively' experienced Rails dev, but only recently took the plunge into full BDD/TDD.</p> <p>The page I'm testing in cucumber has some javascript in it for creating a new nested object (very similar to this <a href="http://railscasts.com/episodes/196-nested-model-form-revised" rel="nofollow">RailsCast</a>).</p> <p>Now the problem lies in the fact that not only do I have variable sub-domains, I have variable <em>Domains</em> too (Just trust me on that one...)</p> <p>So the app needs to query the <code>request.host</code> to find the <code>current_domain</code> and the <code>current_subdomain</code> before everything ties up in the background and it can carry on serving the right bits of the app.</p> <p>I've managed to get all of the tests passing fine using the <code>host! domain</code> and <code>Capybara.default_host = domain</code> techniques in the background steps.</p> <p>However, when I use the @javascript tag on the feature that tests a page with .js on it, I get Firefox grabbing focus, then trying to load the full url.</p> <p>Now it also happens that I'm running Pow, and have those urls hooked up to the dev server. Unsurprisingly, they don't work as when the user tries to log in, it's looking in the dev DB. I tried running the suite after turning the pow server off, and it just timed out.</p> <p>Surely the javascript webdriver shouldn't be actually accessing the url, but simply running the app itself and pretending that the host is what I tell it to be???</p> <p>I'm obviously missing something here - How can I make Cucumber build the page internally, but pretend that the request came from "http://mysubdomain.mydomain.dev"?</p> <p><strong>edit:</strong> <em>Jason</em> - the variable domain trick is achieved exactly the same as subdomains... If you can query the db for an account based on <code>request.subdomains.first</code>, you can query for a domain through <code>request.domain</code>. You just have to double check a few things like capitalisation etc. to minimize the risk of a malformed url breaking stuff, and obviously you need to ensure that the domain record exists in the db first...</p> <p>Oh - and cache the domain record requests with care...</p> <p>It means that you can serve the same app, but with different styling and landing pages etc. Useful for PaaS apps with a broad customer base - you can re-brand it and sell it as a specific solution to one group's problems, even though it's the same guts underneath.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload