Sep 19
Rails Testing Toys
You've got all these test written to drive the development of your
rails app, but you're still using rake test huh? Let's be honest,
Test:Unit is a wonderful library that's made the Ruby testing world
dance, but its output isn't what I'd call pretty.
There are plenty of testing toys out there you should be playing with,
and one of the most important is ZenTest. If not for the cool new
assertions, you should definitely be using the autotest utility.
Autotest
Start the autotest utility, and keep it running. It will detect file
changes in your project and run the appropriate tests. Failed tests
continue running until they pass, and after they pass, the full test
suite is run. Super cool!
Autotest and Mac OS X
Get that autotest running in the background and receive eye candy GUI
notifications when tests fail, thanks to Growl. And, it's easy to
setup thanks to autotest plugins. Just create a .autotest file in
your home directory, or the directory you run autotest from, and
you're off and running. Here is mine:
require 'autotest/growl' require 'autotest/redgreen'
These two lines enable Growl test notifications, and change the terminal output to include colored output.
Autotest and Other Platforms
There's plenty of love to go around. autotest ships with plugins to
do test notification and reporting on most platforms. Just take a
look at the example_dot_autotest.rb file that is included with
ZenTest:
# require 'autotest/growl' # require 'autotest/html_report' # require 'autotest/kdenotify' # require 'autotest/menu' # require 'autotest/pretty' # require 'autotest/redgreen' # require 'autotest/snarl' # require 'autotest/timestamp'
For more info about @autotest@, including a screencast, take a look at this NOR post.
Other Toys
Of course, you can use RedGreen to color the output from @Test::Unit@, there's even a wrapper script for RedGreen available. And Google reveals many pages relating to colored output of @Test::Unit@.
Cheat Sheet
Before you go, be sure to stop by TopFunky and get the Ruby on Rails Testing Cheat Sheet. It lists all the assertions from @Test::Unit@, Rails, and ZenTest's @Test::Rails@.



Just wanted to let you know that you should take a look at dead links in the article.
For example:
“Ruby on Rails Testing Cheat Sheet” doesn’t exist any more (probably too old now).
Could it be time for a renewal of the whole article, ’couse its still useful just a bit outdated?
Or am I wrong?
Post a comment.