Class: RubyLsp::ProgressReporterWithColor

Inherits:
Minitest::ProgressReporter
  • Object
show all
Defined in:
lib/ruby_lsp/test_reporters/minitest_reporter.rb

Overview

An override of the default progress reporter in Minitest to add color to the output

Instance Method Summary collapse

Instance Method Details

#record(result) ⇒ Object

: (Minitest::Result) -> void



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruby_lsp/test_reporters/minitest_reporter.rb', line 16

def record(result)
  color = if result.error?
    "\e[31m" # red
  elsif result.passed?
    "\e[32m" # green
  elsif result.skipped?
    "\e[33m" # yellow
  elsif result.failure
    "\e[31m" # red
  else
    "\e[0m" # no color
  end

  io.print("#{color}#{result.result_code}\e[0m") # Reset color after printing
end