- stuff
git-svn-id: https://svn.thoughtbot.com/plugins/tb_test_helpers/trunk@68 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
This commit is contained in:
parent
cfb496b13f
commit
b9d0a4dcc7
96
lib/color.rb
96
lib/color.rb
|
@ -11,51 +11,59 @@ module Color
|
|||
end
|
||||
end
|
||||
|
||||
class Test::Unit::UI::Console::RedGreenTestRunner < Test::Unit::UI::Console::TestRunner
|
||||
def output_single(something, level=NORMAL)
|
||||
return unless (output?(level))
|
||||
something = case something
|
||||
when '.' then Color.green('.')
|
||||
when 'F' then Color.red("F")
|
||||
when 'E' then Color.yellow("E")
|
||||
else something
|
||||
end
|
||||
@io.write(something)
|
||||
@io.flush
|
||||
end
|
||||
end
|
||||
module Test
|
||||
module Unit
|
||||
class TestResult
|
||||
alias :old_to_s :to_s
|
||||
def to_s
|
||||
if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
|
||||
Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Test::Unit::AutoRunner
|
||||
alias :old_initialize :initialize
|
||||
def initialize(standalone)
|
||||
old_initialize(standalone)
|
||||
@runner = proc do |r|
|
||||
Test::Unit::UI::Console::RedGreenTestRunner
|
||||
class AutoRunner
|
||||
alias :old_initialize :initialize
|
||||
def initialize(standalone)
|
||||
old_initialize(standalone)
|
||||
@runner = proc do |r|
|
||||
Test::Unit::UI::Console::RedGreenTestRunner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Failure
|
||||
alias :old_long_display :long_display
|
||||
def long_display
|
||||
# old_long_display.sub('Failure', Color.red('Failure'))
|
||||
Color.red(old_long_display)
|
||||
end
|
||||
end
|
||||
|
||||
class Error
|
||||
alias :old_long_display :long_display
|
||||
def long_display
|
||||
# old_long_display.sub('Error', Color.yellow('Error'))
|
||||
Color.yellow(old_long_display)
|
||||
end
|
||||
end
|
||||
|
||||
module UI
|
||||
module Console
|
||||
class RedGreenTestRunner < Test::Unit::UI::Console::TestRunner
|
||||
def output_single(something, level=NORMAL)
|
||||
return unless (output?(level))
|
||||
something = case something
|
||||
when '.' then Color.green('.')
|
||||
when 'F' then Color.red("F")
|
||||
when 'E' then Color.yellow("E")
|
||||
else something
|
||||
end
|
||||
@io.write(something)
|
||||
@io.flush
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Test::Unit::TestResult
|
||||
alias :old_to_s :to_s
|
||||
def to_s
|
||||
if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
|
||||
Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Test::Unit::Failure
|
||||
alias :old_long_display :long_display
|
||||
def long_display
|
||||
# old_long_display.sub('Failure', Color.red('Failure'))
|
||||
Color.red(old_long_display)
|
||||
end
|
||||
end
|
||||
|
||||
class Test::Unit::Error
|
||||
alias :old_long_display :long_display
|
||||
def long_display
|
||||
# old_long_display.sub('Error', Color.yellow('Error'))
|
||||
Color.yellow(old_long_display)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue