Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'autotest/redgreen'
- Autotest.send(:alias_method, :real_make_test_cmd, :make_test_cmd)
- Autotest.send(:define_method, :make_test_cmd) do |*args|
- real_make_test_cmd(*args).sub('test/unit', %[rubygems -e "require 'redgreen'"])
- end
- Autotest.add_hook :initialize do |autotest|
- autotest.add_exception(/^\.\/vendor/)
- autotest.add_exception(/\.svn/)
- autotest.add_exception(/\.git/)
- autotest.add_mapping(/stories\/all.rb/) do |f, _|
- autotest.files_matching %r%^spec/(controllers|helpers|lib|models|views)/.*\.rb$%
- end
- end
- module Autotest::Growl
- def self.growl title, msg, pri=-1, stick=""
- system "growlnotify -n autotest -p #{pri} -m #{msg.inspect} #{title} #{stick}"
- end
- def self.parse_results(autotest_results)
- keys = %w(test example failure error pending fixed)
- output = (autotest_results.last||"")
- results = {}
- keys.each do |key|
- output =~ /(\d+) #{key}/
- results[key] = $1.to_i || 0
- end
- results
- end
- Autotest.add_hook :ran_command do |autotest|
- autotest_output = (autotest.results.last||"").slice(/(\d+) (test||example)[^\e]*/)
- output = parse_results(autotest.results)
- if output['failure'] == 0 && output['error'] == 0 && output['pending'] == 0
- growl "Test Results", autotest_output, -2
- elsif output['failure'] == 0 && output['error'] == 0 && output['pending'] > 0
- growl "Test Results", autotest_output, -1
- elsif output['failure'] == 0 && output['error'] == 0
- growl "Test Results", autotest_output, 0
- elsif output['fixed'] > 0
- growl "Test Results", autotest_output, 0
- else
- growl "Test Results", autotest_output, 1#, "-s"
- end unless autotest_output.nil?
- end
- end
Add Comment
Please, Sign In to add comment