Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/spec/context.cr
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ module Spec
Fail
Error
Pending

def color : Colorize::Color
case self
in Success then Colorize::ColorANSI::Green
in Fail then Colorize::ColorANSI::Red
in Error then Colorize::ColorANSI::Red
in Pending then Colorize::ColorANSI::Yellow
end
end

def letter : Char
case self
in Success then '.'
in Fail then 'F'
in Error then 'E'
in Pending then '*'
end
end
end

# :nodoc:
Expand Down
28 changes: 6 additions & 22 deletions src/spec/dsl.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,20 @@ module Spec
Comment
Focus
Order
end

private STATUS_COLORS = {
Status::Success => :green,
Status::Fail => :red,
Status::Error => :red,
Status::Pending => :yellow,
}

private INFO_COLORS = {
InfoKind::Comment => :cyan,
InfoKind::Focus => :cyan,
InfoKind::Order => :cyan,
}

private LETTERS = {
Status::Success => '.',
Status::Fail => 'F',
Status::Error => 'E',
Status::Pending => '*',
}
def color : Colorize::Color
Colorize::ColorANSI::Cyan
end
end

# :nodoc:
def self.color(str, status : Status)
str.colorize(STATUS_COLORS[status])
str.colorize(status.color)
end

# :nodoc:
def self.color(str, kind : InfoKind)
str.colorize(INFO_COLORS[kind])
str.colorize(kind.color)
end

# :nodoc:
Expand Down
2 changes: 1 addition & 1 deletion src/spec/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Spec
end

def report(result)
@io << Spec.color(LETTERS[result.kind], result.kind)
@io << Spec.color(result.kind.letter, result.kind)
split_lines
@io.flush
end
Expand Down