diff --git a/lib/guard/forku.rb b/lib/guard/forku.rb index 39ccd20..6a43e56 100644 --- a/lib/guard/forku.rb +++ b/lib/guard/forku.rb @@ -5,10 +5,9 @@ module Guard class Forku < Guard def start - UI.info "Loading test_helper" require 'test_helper' ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base) - UI.info "Ready" + notify 'Ready to test. Code away.' end # Called on Ctrl-/ signal @@ -18,7 +17,6 @@ def start def run_all %w[unit functional integration performance].each do |test| load_in_fork("test/#{test}/**/*_test.rb") - Process.wait end end @@ -37,14 +35,27 @@ def load_in_fork(*paths) ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base) $0 = paths.join(' ') # test/unit uses this if paths.empty? - UI.info "No tests found. Skipping." + notify "No tests found", image: :pending exit! # skip test/unit autorun else paths.each {|p| load p } end end + if Process.wait > 0 + notify "PASS" + else + notify "FAIL", image: :failed + end end private :load_in_fork + + def notify(message, opts={}) + if options[:notify] + Notifier.notify(message, opts) + else + UI.info("*** " << message) + end + end end end