- Improves feedback by running tests continuously.
- Continually runs tests based on files you've changed.
- Get feedback as soon as you save. Keeps you in your editor allowing you to get stuff done faster.
- Focuses on running previous failures until you've fixed them.
to run cd into your app dir and type:>>gem install ZenTest
Simple, isn't it?>>autotest -rails
Well... not really.
When I did this I got a whole bunch of error messages:
Turns out that it's looking for an environment variable called HOME. From my tests and from what I read you can put any valid path there. I just used the local path.
.../InstantRails/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.6.1/lib/autotest.rb:435:in `expand_path': couldn't find HOME environment -- expanding `~/.autotest' (ArgumentError)
from .../InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from .../InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from .../InstantRails/ruby/bin/autotest:19:in `load'
Actually, I just set the variable before running autotest.
However, a fresh new list of errors are now generated, the gist of them is this:>>set HOME=.
Basically, it's complaining that it cannot find diff.exe. Of course, most (all?) Unix systems have this installed but my Windows machine with InstantRails does not, so therein lies the problem. This post explains it simply. Go here to get diff.exe for Windows.
.../InstantRails/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.6.1/lib/unit_diff.rb:187:in ''': No such file or directory - diff.exe -u D:/temp/expect.1480.0 D:/temp/butwas.1480.0n (Errno::ENOENT)
1. from .../InstantRails/ruby/lib/ruby/gems/1.8/gems/ZenTest-3.6.1/lib/unit_diff.rb:187:in 'unit_diff'
Once installed (or unzipped), just set your path to wherever you put it, and run autotest. e.g.:
Right? Wrong.>>set HOME=.
>>set path=%path%;"C:\Program Files\GnuWin32\bin\"
diff.exe is still not found. For some reason it's not enough to set the environment like this.
You will need to set it in the Windows settings (Start-> Settings-> Control Panel-> System-> Advanced-> Environment Variables...) and change the PATH variable to include the diff.exe path.
Now you can begin enjoying the joys of autotest.
If you found this post helpful, please leave a message in the comments. If you want to hear more about my adventures on the Rails, subscribe to the blog feed and you won't miss a thing.