I work on a large Rails app. We have a JavaScript feature which acts as a general analytics data delivery system. It announces general analytics data based on various page interaction events (clicks, page views, etc) but is framework agnostic, in that, the data isn't specific to what, say, Google Analytics wants out of the box. It's just general data about the interaction.
The idea is that an adapter module for Google Analytics (or any other 3rd Party analytics tool) can be written to take the data produced by the general library, augment the data to fit the needs of the 3rd Party, and send it to their endpoint.
My question is about testing this feature accurately.
We use Rspec for the bulk of our testing and Teaspoon for our JavaScript unit tests. Ideally I'd like to write a feature test that navigates our app, clicks on various triggering elements, and confirms that the general analytics data is being announced correctly.
Is that even possible, or are our Teaspoon tests going to have to suffice?
Rspec integration tests can do this for you. Unfortunately it's a very slow way to test javascript, but for regression testing, where performance may not be important, rspec feature testing will do the job.
My rspec integration tests take 40 minutes to run, so I run the entire suite only when there's a work break. Of course you can run individual feature files much quicker, but they're still way slower than js tests.
You can run them headlessly using poltergeist and phantomjs, this is faster than using a browser, but you'll probably want to switch to a browser for debugging.