Move characters to a named tuple

This commit is contained in:
Michael Miller 2019-02-17 21:35:17 -07:00
parent bd500b0799
commit 9c16a5a53e

View file

@ -9,6 +9,14 @@ module Spectator::Formatters
class DotsFormatter < Formatter class DotsFormatter < Formatter
include SuiteSummary include SuiteSummary
# Characters for each of the result types.
private CHARACTERS = {
success: '.',
failure: 'F',
error: 'E',
pending: '*',
}
# Creates the formatter. # Creates the formatter.
# By default, output is sent to `STDOUT`. # By default, output is sent to `STDOUT`.
def initialize(@io : IO = STDOUT) def initialize(@io : IO = STDOUT)
@ -30,22 +38,22 @@ module Spectator::Formatters
# Character output for a successful example. # Character output for a successful example.
def success(result) def success(result)
Color.success('.') Color.success(CHARACTERS[:success])
end end
# Character output for a failed example. # Character output for a failed example.
def failure(result) def failure(result)
Color.failure('F') Color.failure(CHARACTERS[:failure])
end end
# Character output for an errored example. # Character output for an errored example.
def error(result) def error(result)
Color.error('E') Color.error(CHARACTERS[:error])
end end
# Character output for a pending or skipped example. # Character output for a pending or skipped example.
def pending(result) def pending(result)
Color.pending('*') Color.pending(CHARACTERS[:pending])
end end
end end
end end