I was merging the functions of a couple of Rails controllers the other day, and started by combining the tests. For a couple of reasons, I found myself wishing for a way to sort Ruby Test::Unit test methods. First, I wanted to know if there were any test methods with duplicate names. Second, more importantly, I wanted to be able to work methodically through the failing tests—and those are run in alphabetical order.
I knocked together a quick and dirty filter that pulls apart a
test file and puts it back together with the
methods in alphabetical order. It’s a quick hack, not a robust
parser, but it works for me.