Here's one strategy I've been using that offers several benefits that were previously hard to combine:
- write both code and tests in any combination of pre-processable languages, relying on Sprockets and the asset pipeline to automatically find and compile everything.
- tests can execute in the browser with a nice graphical UI.
- the exact same tests can execute from the shell with no browser. I'm using therubyracer.
To run in the browser, you just need
&debug_assets=1to get useful filenames and line numbers in your stack traces.
Of course there are still a few more details to take care of to trigger the tests, produce nice console output, and set Rake's exit status. Here is a full example config.