To easily explain, imaging you are developing google analytics or kissmetrics and you need to do integration testing of the javascript file. That's the file which people include on their website. Assume client also needs to push some events like signups to the web analytics tool (like kissmetrics) and javascript syntax would be _ga.push(['register', event, extra_data])
The challenge is that in you tests you can't run it from your application as it will share user session and it wouldn't test same origin policy.
Tools stack: Capybara, Webkit, Rspec, Sinatra
So the solution is to have a separate application which will act as a dummy client. I've chose sinatra as it fits perfectly for that role. One of the cool features that rack has is its ability to mount other rack applications inside it. So in run_dummy_client
helper we mount sinatra application to /dummy_client
path.
But that's not all. In order for this to work we need to run dummy client from different domain. That could be easily done through