Mostly implemented progress formatter

This commit is contained in:
Michael Miller 2021-05-15 19:45:01 -06:00
parent e2f4051927
commit eebcba0749
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436

View file

@ -1,8 +1,37 @@
require "colorize"
require "./formatter"
module Spectator::Formatting
# Output formatter that produces a single character for each test as it completes.
# A '.' indicates a pass, 'F' a failure, and '*' a skipped or pending test.
# A '.' indicates a pass, 'F' a failure, 'E' an error, and '*' a skipped or pending test.
class ProgressFormatter < Formatter
@pass_char : Colorize::Object(Char) = '.'.colorize(:green)
@fail_char : Colorize::Object(Char) = 'F'.colorize(:red)
@error_char : Colorize::Object(Char) = 'E'.colorize(:red)
@skip_char : Colorize::Object(Char) = '*'.colorize(:yellow)
# Creates the formatter.
def initialize(@io : IO = STDOUT)
end
# Produces a pass character.
def example_passed(_notification)
@pass_char.to_s(@io)
end
# Produces a fail character.
def example_failed(_notification)
@fail_char.to_s(@io)
end
# Produces an error character.
def example_error(_notification)
@error_char.to_s(@io)
end
# Produces a skip character.
def example_pending(_notification)
@skip_char.to_s(@io)
end
end
end