Skip to content

Commit f92bd1f

Browse files
luislavenaAry Borenszweig
authored and
Ary Borenszweig
committed
Fully honor no color option when running specs
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
1 parent ee30684 commit f92bd1f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/spec/context.cr

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module Spec
9595

9696
if ex.is_a?(AssertionFailed)
9797
puts
98-
puts " # #{Spec.relative_file(ex.file)}:#{ex.line}".colorize.cyan
98+
puts Spec.color(" # #{Spec.relative_file(ex.file)}:#{ex.line}", :comment)
9999
end
100100
end
101101
end
@@ -137,8 +137,8 @@ module Spec
137137
puts "Failed examples:"
138138
puts
139139
failures_and_errors.each do |fail|
140-
print "crystal spec #{Spec.relative_file(fail.file)}:#{fail.line}".colorize.red
141-
puts " # #{fail.description}".colorize.cyan
140+
print Spec.color("crystal spec #{Spec.relative_file(fail.file)}:#{fail.line}", :error)
141+
puts Spec.color(" # #{fail.description}", :comment)
142142
end
143143
end
144144
end

src/spec/dsl.cr

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Spec
88
fail: :red,
99
error: :red,
1010
pending: :yellow,
11+
comment: :cyan,
1112
}
1213

1314
private LETTERS = {

0 commit comments

Comments
 (0)