I can't take credit for any of these instructions. Dave South from the Logan Ruby group sent these out in an email. I am posting them so that I can find them later on.
Install ZenTest:
sudo gem install ZenTest
Then install RedGreen
sudo gem install redgreen
Go to your rails project directory and create a file called: .autotest
mate .autotest
Add this to the file:
require 'redgreen/autotest'
Save and exit
In your terminal, change to your rails application. Instead of typing
'rake' to run the tests, type 'autotest'. It will load the tests and
run them all the first time it loads. RedGreen will highlight the
result in green if everything passes and red if anything fails.
Autotest will continue to run, waiting for changes in the application.
Leave that terminal open and edit your rails application. Whenever
you save the app, autotest will detect the save, identify the file(s)
that changed, and run appropriate tests.
If you change a model file, for example, autotest will run the unit
tests for that model. It won't run the whole test suite.
If you hit control-c once, it WILL hit the whole test suite. Except
the version I'm running right now actually crashes with one control-
c. Hopefully it will be fixed, soon.
To quit autotest, hit control-c twice.
We like to set TextMate to "Save files when focus is lost". It's
under the advanced tab of TextMate's preferences. The nice thing
about that command is it saves every changed file in the project. So
if you do a global search and replace, all you have to do is switch
to another application and all the project files will save.
It also kicks the autotest every time you switch away from TextMate.
For those on windows here is a good resource:
http://blog.sourcecraft.net/2007/03/11/colored-autotest-with-notifications-on-windows/
Looks like the windows link is dead. If anyone has any suggestions please let me know.
Tags: red green · Ruby On Rails · testing · zentest5 Comments











5 responses so far ↓
When you say redgreen, I think of this.
http://www.redgreen.com/
Thanks for the tutorial, Justin. I think the .autotest file should require autotest/redgreen and not redgreen/autotest, right?
I think you are right. I haven’t set this up in a while, but I do tend to mess up the code I post every now and then.
If you want to use the redgreen gem, you should use ‘redgreen/autotest’. If you want to use the version of redgreen that comes with ZenTest, then you use ‘autotest/redgreen’
Hope that clears it up
Also, I plan to post some fresh info for windows users soon.
Thanks for the clarification. That actually helps a lot.