adds output=colorized option

This commit is contained in:
Colin T.A. Gray
2013-06-13 10:24:04 -06:00
committed by Watson
parent fcf437c351
commit cb3d1438dc

View File

@@ -155,6 +155,41 @@ module Bacon
end
end
module ColorizedOutput
GREEN = "\033[0;32m"
RED = "\033[0;31m"
RESET = "\033[00m"
def handle_specification_begin(name); end
def handle_specification_end ; end
def handle_requirement_begin(description) end
def handle_requirement_end(error)
if error.empty?
print "#{GREEN}.#{RESET}"
else
print "#{RED}#{error[0..0]}#{RESET}"
end
end
def handle_summary
puts ""
puts "", ErrorLog if Backtraces && ! ErrorLog.empty?
duration = "%0.2f" % (Time.now - @timer)
puts "", "Finished in #{duration} seconds."
color = GREEN
if Counter[:errors] > 0 || Counter[:failed] > 0
color = RED
end
puts "#{color}%d tests, %d assertions, %d failures, %d errors#{RESET}" %
Counter.values_at(:specifications, :requirements, :failed, :errors)
puts ""
end
end
module FastOutput
def handle_specification_begin(name); end
def handle_specification_end; end
@@ -238,6 +273,7 @@ module Bacon
'tap' => TapOutput,
'knock' => KnockOutput,
'rubymine' => RubyMineOutput
'colorized' => ColorizedOutput
}
extend(Outputs[ENV['output']] || SpecDoxOutput)