Skip to content

Instantly share code, notes, and snippets.

@alainravet
Created August 4, 2009 18:43
Show Gist options
  • Save alainravet/161432 to your computer and use it in GitHub Desktop.
Save alainravet/161432 to your computer and use it in GitHub Desktop.
~/autotest config file
#autotest configuration
#
require 'redgreen/autotest'
require 'autotest/timestamp'
# ####################
# GROWL CONFIG
# ####################
#http://github.com/svoop/autotest-growl/tree/master
require 'autotest/growl'
#Autotest::Growl::hide_label = true
#Autotest::Growl::show_modified_files = true
#Autotest::Growl::clear_terminal = false
#Autotest::Growl::one_notification_per_run = true
#Autotest::Growl::remote_notification = true
# ####################
# MAC-FRIENDLY
# ####################
# see: http://www.bitcetera.com/en/techblog/2009/05/27/mac-friendly-autotest/
require 'autotest/fsevent'
# ####################
# SCOPE LIMITING
# ####################
Autotest.add_hook :initialize do |at|
# # Limit the scope of autotest (see: http://blog.davidchelimsky.net/articles/2008/03/05/limiting-scope-of-autotest)
# # Usage:
# # autotest app/models app/lib test/unit/notices
# # -> watch app/models, app/lib and test/unit/notices
unless ARGV.empty?
at.find_directories = ARGV.dup
end
end
# ####################
# EXCLUDE SOME FILES
# ####################
Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store *.log ._* vendor}.each {|exception| autotest.add_exception(exception) }
false
end
# ####################
# SPEAK (whisper)
# ####################
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\n")
# output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
# aravet: the above line seems to be for rspec only. the one below works with TestUnit
if output = results.slice(/(\d+) assertions, (\d+) failures, (\d+) errors/)
failed = $~[2].to_i > 0 || $~[3].to_i > 0
system "say -v Whisper \"#{failed ? "No" : "Yes"}\"" #aravet
else
system "say -v Whisper \"AUTOTEST ERROR (see ~/.autotest)\""
puts "\n\nAutotest error -erroOOr : results = \n#{results}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment