Here is some problem that I encountered while ruby on rails development. You might know about TDD (Test Driven Development). Now since autotest can be used to speed up and automate the testing process somewhat and spork can be used to reduce the amount of time require d to run the tests. This becomes crucial that your tests are running smoothly.

The problem I encountered was that autotest continuously kept on testing all the cases.  Autotest is supposed to run only when there is any change made to the files that are referred in the test cases. So my autotest wasnt stopping even when I wasnt making any change. Autotest is a CPU intensive task, so it was necessary for me to find a workaround so it stops testing again and again till I actually make some changes..

The workaround to stop autotest from running if you dont make any change is  to add these lines to your .autotest file

autotest.add_exception %r{^\./db}
autotest.add_exception %r{^\./log}

My .autotest file looks like

require ‘autotest/growl’ # enable pop-up windows
require ‘autotest/restart’ # optional: forces autotest to pick the changes to this file
require ‘autotest/timestamp’ # optional: shows timestamps for test runs

# filter out VCS files and other garbage to reduce HDD usage

Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store ._* vendor tmp log doc}.each do |exception|
autotest.add_exception(exception)
autotest.add_exception %r{^\./db}
autotest.add_exception %r{^\./log}
end
end

# do not clear console before running tests
Autotest::Growl::clear_terminal = false

Advertisements