Skip to content

Commit

Permalink
Fully honor no color option when running specs
Browse files Browse the repository at this point in the history
Spec runner have the option to disable colored output (ANSI codes) when
`--no-color` option is used, example:

    $ crystal spec -- --no-color

However, certain elements in the output didn't fully support that option,
resulting in a mix of non-color and color.

This change unifies that setting and ensures that `--no-color` usage
is fully honored by the output.

Ref #4292
  • Loading branch information
luislavena authored and asterite committed Apr 18, 2017
1 parent ee30684 commit f92bd1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/spec/context.cr
Expand Up @@ -95,7 +95,7 @@ module Spec

if ex.is_a?(AssertionFailed)
puts
puts " # #{Spec.relative_file(ex.file)}:#{ex.line}".colorize.cyan
puts Spec.color(" # #{Spec.relative_file(ex.file)}:#{ex.line}", :comment)
end
end
end
Expand Down Expand Up @@ -137,8 +137,8 @@ module Spec
puts "Failed examples:"
puts
failures_and_errors.each do |fail|
print "crystal spec #{Spec.relative_file(fail.file)}:#{fail.line}".colorize.red
puts " # #{fail.description}".colorize.cyan
print Spec.color("crystal spec #{Spec.relative_file(fail.file)}:#{fail.line}", :error)
puts Spec.color(" # #{fail.description}", :comment)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/spec/dsl.cr
Expand Up @@ -8,6 +8,7 @@ module Spec
fail: :red,
error: :red,
pending: :yellow,
comment: :cyan,
}

private LETTERS = {
Expand Down

0 comments on commit f92bd1f

Please sign in to comment.