mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Cleanup color code
This commit is contained in:
parent
625262b6d5
commit
caeab6c338
1 changed files with 22 additions and 8 deletions
|
@ -4,6 +4,16 @@ require "colorize"
|
||||||
module Spectator
|
module Spectator
|
||||||
module Formatters
|
module Formatters
|
||||||
class DefaultFormatter < Formatter
|
class DefaultFormatter < Formatter
|
||||||
|
SUCCESS_COLOR = :green
|
||||||
|
FAILURE_COLOR = :red
|
||||||
|
ERROR_COLOR = :magenta
|
||||||
|
PENDING_COLOR = :yellow
|
||||||
|
|
||||||
|
SUCCESS_CHAR = '.'.colorize(SUCCESS_COLOR)
|
||||||
|
FAILURE_CHAR = 'F'.colorize(FAILURE_COLOR)
|
||||||
|
ERROR_CHAR = 'E'.colorize(ERROR_COLOR)
|
||||||
|
PENDING_CHAR = 'P'.colorize(PENDING_COLOR)
|
||||||
|
|
||||||
def start_suite
|
def start_suite
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,15 +28,19 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
def end_example(result : Result)
|
def end_example(result : Result)
|
||||||
print case result
|
print result_char(result)
|
||||||
|
end
|
||||||
|
|
||||||
|
private def result_char(result : Result)
|
||||||
|
case result
|
||||||
when SuccessfulResult
|
when SuccessfulResult
|
||||||
".".colorize.green
|
SUCCESS_CHAR
|
||||||
when PendingResult
|
when PendingResult
|
||||||
"P".colorize.yellow
|
PENDING_CHAR
|
||||||
when ErroredResult
|
when ErroredResult
|
||||||
"E".colorize.magenta
|
ERROR_CHAR
|
||||||
when FailedResult
|
when FailedResult
|
||||||
"F".colorize.red
|
FAILURE_CHAR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,11 +55,11 @@ module Spectator
|
||||||
pending = results.pending_examples
|
pending = results.pending_examples
|
||||||
string = "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending"
|
string = "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending"
|
||||||
if failures > 0 || errors > 0
|
if failures > 0 || errors > 0
|
||||||
string.colorize.red
|
string.colorize(FAILURE_COLOR)
|
||||||
elsif pending != examples
|
elsif pending != examples
|
||||||
string.colorize.yellow
|
string.colorize(PENDING_COLOR)
|
||||||
else
|
else
|
||||||
string.colorize.green
|
string.colorize(SUCCESS_COLOR)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue