Created
July 10, 2009 10:24
-
-
Save andrew/144393 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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