Last active
December 29, 2015 03:29
-
-
Save uxp/7608567 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
# A super basic color output formatter for MiniTest in 1.9.3 | |
class ColorReporter | |
attr_reader :io | |
def initialize io, opts={} | |
@io = io | |
@opts = opts | |
end | |
def print o | |
case o | |
when '.' | |
io.print green(o) | |
when 'E', 'F' | |
io.print red(o) | |
when 'S' | |
io.print yellow(o) | |
else | |
io.print o | |
end | |
end | |
def puts(*o) | |
o.map! do |s| | |
if s.to_s.match(/(failure|error):/i) | |
red s | |
elsif s.to_s.match(/skipped:/i) | |
yellow s | |
else | |
s | |
end | |
end | |
super | |
end | |
def green(o) | |
"\033[32;1m#{o}\033[0m" | |
end | |
def red(o) | |
"\033[31;1m#{o}\033[0m" | |
end | |
def yellow(o) | |
"\033[33m#{o}\033[0m" | |
end | |
end | |
MiniTest::Unit.output = ColorReporter.new(MiniTest::Unit.output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment