Last Updated: February 25, 2016
· jhubert

Use a rake task to describe your Test::Unit tests

I've been considering switching to RSpec / BDD for my Rails projects, but after thinking about it I realized that all I really wanted was the nice output from the Spec command that described my code. I figured that there had to be a way to do this with my existing Test::Unit tests... so I wrote this quickly:

As it so happens, despite how rough it is, it actually does a pretty good job!

Just place the rake file in your lib/tasks/ folder and call it like this:

rake test:describe

You can also call a specific class by passing it to rake as an argument:

rake test:describe[User]

The code is rough and definitely conforms to my way of writing tests, but I hope you can find it useful at least as a starting point for your projects.