Fast Tests on JRuby (RSpec + Nailgun + autotest)
15 May 2012
JRuby is awesome. The JVM’s startup time is not:
This makes doing TDD in JRuby more painful than it ought to be.
Luckily, JRuby has built in support for Nailgun, which can prevent the need for starting up a new JVM each time we want to run Ruby, making things a brazilian times faster.
Using Nailgun is simple. First, start up the Nailgun server:
And then pass
--ng to ruby whenever you use it:
Unfortunately, a teensy bit of monkey patching is required to get Nailgun playing nicely with autotest.
Dump this anywhere in your .autotest file:
And then run autotest with Nailgun:
Boom. Now you have a subsecond test cycle in JRuby.