quicker rails testing

So, I've finally gotten into the habit of doing serious unit testing at work. We have an agreement not to check in any new code unless the tests all pass, but running all the tests can take a while. (It doesn't help that they run on my 1 GHz personal server.)

Anyhow, what's really important in this case is that you test the changes you made. Running every test isn't necessary. You can manually do this by specifying the test file directly, but you may not remember which files you've changed. That's where rake since_checkin comes in.

Behold, Ticket 4035, my first code contribution to Rails. In true Rails style, I wrote it because I was annoyed with how things were working. This will use svn status to determine which files have changed, pick the models from that list, and run the tests associated with them. (In fact if you look at the patch, it's really only three lines of new code, and they line up perfectly with the three steps I just listed. I like to think the fact that it's done in three lines of code says more about the expressiveness of Ruby than it does about the content of my patch.)

If you want to use the task without upgrading to Edge Rails, just drop this file into RAILS_ROOT/lib/tasks.

It's good to be a (minor) contributor. Update: David accepted the patch. He's fast. Update again: name was changed to rake uncommitted.

« older | 2006-03-01T10:29:41Z | newer »