Skip to content

Instantly share code, notes, and snippets.

@andrew
Created July 10, 2009 10:24
Show Gist options
  • Select an option

  • Save andrew/144393 to your computer and use it in GitHub Desktop.

Select an option

Save andrew/144393 to your computer and use it in GitHub Desktop.
require 'autotest/fsevent'
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg}' #{title} #{stick}"
end
Autotest.add_hook :red do |at|
errors = at.files_to_test.map { |k, v| "#{k}:\n #{v.join("\n ")}"}.join("\n\n")
#failed_tests = at.files_to_test.inject(0){ |s,a| k,v = a; s + v.size}
growl "Tests failed:", "#{errors}", '~/library/Autotest/failed.png', 2
end
Autotest.add_hook :green do |at|
res = at.results.scan(/Finished.*failures/m).to_s.gsub(/\e\[32m/,'')
growl "Test Results", "#{res}", '~/library/Autotest/passed.png'
end
end
Autotest.add_hook :initialize do |at|
at.clear_mappings
at.add_mapping(%r{^test/.*_test\.rb$}) {|f, _| [f] }
at.add_mapping(%r{^lib/factory_girl/(.*)\.rb$}) {|_, m| ["test/#{m[1]}_test.rb",
"test/integration_test.rb"] }
at.add_mapping(%r{^test/(test_helper|models)\.rb$}) { at.files_matching %r{^test/.*_test\.rb$} }
at.add_mapping(%r{^lib/.*\.rb$}) { at.files_matching %r{^test/.*_test\.rb$} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment