[Screencast] Faster Rails test runs...with Unix!
Published on June 19, 2013 by Jesse Storimer
Anybody who works on a moderate size Rails app can probably tell you: it takes forever to run a single test. I've definitely experienced this with some of the big Rails projects I've worked on, and it sucks! Goodbye productivity.
Some smart people have been advocating ways around this. But if you've got an existing app, seeing the full benefit of these techniques involves some pretty serious rearchitechting. Not an option for most of us.
Today I'm going to show you a technique to speed up those test runs that doesn't involved touching your app code. In this screencast, I took the rubygems.org codebase, a big Rails app, and cut the time to run a unit test in half. When I started, it took a little over 5 seconds to run the
UserTest. With the tool that I build in 20 mins in the screencast, the same test run took just under 2 and a half seconds. Yay for Unix!
If you want to avoid my blathering at the beginning and skip right to the code, jump to the 2:30 mark.
Random bit of trivia. If you listen right to the end, around the 20:45 mark you can hear me stumble on a word. If you turn the volume up, you'll hear the coyotes howling that I was hearing outside my window!
The code from the screencast is available in a gist.
Registration just opened for my Unix fu online workshop. Want to level up your system programming and learn more of the awesome things you saw in this video? Join me in class on July 18-19.