Sunday, May 18, 2008

Autotest and Snarl - Coding bliss is obtainable in Windows

Ok when I was trying to setup my autotest with Snarl on windows box I had quite a few problems and couldn't really find a blog that told me how to do it exactely. Ok so for the few people stuck on windows boxes out there this should get you up and running.
  1. Install Snarl (This setup makes you install some other program that Snarl has a dependacy on)
  2. Install autotest if you havn't got it (gem install ZenTest)
  3. Install the ruby-snarl gem (gem install ruby-snarl)
  4. Download and install the GNU DiffUtils package – I installed this into my C:\Program Files\GnuWin32 directory.
  5. Add the C:\Program Files\GnuWin32\bin to your PATH environment variable. ( if you need some help with that)
  6. Set your HOME environment variable to something like C:\Documents and Settings\{USERNAME}
  7. Ok now for some pretty pictures to show when a test passes or fails. I use the ones from here. But you can make your own or get some from somewhere else if you like. Save these pictures to the $RUBY_HOME\lib\ruby\gems\1.8\gems\ZenTest-3.6.1\lib\icons as accept.png and exclamation.png (You may have to create the icons directory) Note that $RUBY_HOME is the directory where Ruby is installed, on my computer that means C:\Ruby
  8. Now create a file called .autotest in your Rails Applications root directory and place the following line in it
    require 'autotest/snarl'
    Note: If you can't work out how to create the .autotest file in windows because renaming it in the GUI doesn't work. The easiest way I found to make the file was to open up a command window, navigate to the rails application root directory then type edit .autotest and then just save the file. (Im sure there are much easier ways to create this file but I didn't want to spend anymore time looking for them)
  9. And thats it ... now you should just be able to type autotest in the command prompt while in your rails application root and autotest should begin. And if you tests pass you should see something like this

Welcome to a new world of productivity where you can implement a new feature and go straight onto the next while your tests run in the background. And now you wont need need to switch back to the command prompt to check that your tests passed!

If I'lve missed out something important then please leave a comment and Ill update the post.

Other references that may be helpful and that were used in the making of this blog include, many thanks to the authors of these blogs


nachocab said...

Thanks a lot, Andrew. You saved my life! Hahaha, now I only have to figure out how to speed up the tests so they run as quickly as in OSX.

Take care!


Andrew Dedman said...

No worries Nacho. Regarding speed, I know that you can run the SQL Lite db in memory on OSX. But I'm not sure if thats possible on windows. I'lve never tried to on either platform because my tests never run that long anyway but may be worth a google to see if you can get your DB working in memory on windows.. If you find a way to get it to work let us know!

lunaclaire said...

I've followed the instructions here and on other sites, but I always run into a problem... when I run autotest from my app's root directory, I get a line that says:

"loading autotest/rails"

and it just hangs there.

I'm on Vista and running rails 1.2.6.

Any ideas?

gil said...

I'm running into the same issue as lunaclaire. I'm running on vista/cygwin, using rails 2.2.2.

raja said...

does autotest/snarl gives a way to customize messages like growl does ?

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Bill said...

Thanks you. I was running into some of the same info that was leading me nowhere.

Anonymous said...

I would like to say that this blog really convinced me, you give me best information! Thanks, very good post.