Rails' Readable Test Names: Run Individual Tests From the Console

As you probably know, since rails 2.1 you can write test methods in the following format:

test "hotel should return its permalink" do
#your test code here

Which is great, as the test name becomes much more clear. But you can’t simply run this test easily from the command line. You’d have to run something like:

$ ruby your_test_file.rb -n test_hotel_should_return_its_permalink

It annoys me. And it’s not practical either to make the test fail just so you can get the test’s real name.
I wanted to be able to just copy and paste the readable name in the console and have Test::Unit do the conversion and run it for me, like this:

$ ruby your_test_file.rb -n "hotel should return its permalink"

So I created readable_test_names_runner. It’s a tiny rails plugin that adds this feature for you.