_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
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 modifying
etc/hosts file or having a proxy which will redirect custom local domain to specific host (that can be done with POW.cx). And at the end don't forget to move that configuration setup into a rake task so you do don't need to remember it next time.
_ga.push with exactly the same arguments. With such setup we can easily expand our integration tests with a more sophisticated use cases.