Finally I've got tired of pressing 'spec spec/model/*' , so I decided to try autotest.

The idea of autotest is just running and informing you about test results without manual runs. It looks simple, you run 'autotest' from console and see results. It automatically triggers test when you edit the test file. You also can configure and add some visualization by editing .autotest file, which should be located in your rails root directory.

There are plenty of documentation on installation but I still got some issues.
Here are some usefull links on this topic:

  • http://ph7spot.com/articles/getting_started_with_autotest
The nube documentation.

  • http://pragmatig.wordpress.com/2008/04/15/autotest-rspec-notifications-for-ubuntu/
And the script for Ubuntu to see linux like flashing messages about test completion.

  • http://blog.nicksieger.com/articles/2006/11/15/rspec-autotest-now-a-rails-plugin
Autotest plugin for rails


.autotest example for ubuntu

require 'autotest/redgreen'

module Autotest::Notify
def self.notify title, msg, img, pri='low', time=3000
`notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'`
end

Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
folder = "~/Pictures/rails/"
if output =~ /[1-9]\d*\sfailures?/
notify "FAIL:", "#{output}", folder+"rails_fail.png", 'critical', 10000
elsif output =~ /[1-9]\d*\spending?/
notify "PENDING:", "#{output}", folder+"rails_pending.png", 'normal', 10000
else
notify "PASS:", "#{output}", folder+"rails_ok.png"
end
end
end