Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created June 28, 2011 18:10
Show Gist options
  • Save seanbehan/1051767 to your computer and use it in GitHub Desktop.
Save seanbehan/1051767 to your computer and use it in GitHub Desktop.
Watchr Script for Test Unit
require 'ruby-debug'
require 'rainbow'
require 'colorize'
def result(message)
msg = message.to_a.map(&:strip)
stats = msg.last.split(",")
errors = stats[-1].split(" ").first.to_i
failures = stats[-2].split(" ").first.to_i
color = (failures >= 1||errors>=1) ? :"yellow" : :"green"
summary = message.to_a.last
msg.shift
msg.shift
started = msg.shift
failure_count = msg.shift
elapsed_time = msg.shift
body = ""
msg.each do |m|
body << m
body << "\n" if m.empty?
end
puts "
==TEST_RESULTS=============================================
#{failure_count}
#{summary}
#{body}
--END_RESULTS----------------------------------------------
#{elapsed_time}
".send(color)
end
def run
begin
system "clear"
result(`rake test`)
rescue Exception => e
puts e.message
end
end
watch('test/.*_test\.rb') { run }
watch('lib/(.*)\.rb') { run }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment