Class: Minitest::Colorin
- Inherits:
-
Object
- Object
- Minitest::Colorin
- Defined in:
- lib/minitest/colorin.rb,
lib/minitest/colorin/version.rb
Defined Under Namespace
Classes: TestID
Constant Summary collapse
- LABELS =
{ '.' => 'PASS ', 'S' => 'SKIP ', 'F' => 'FAIL ', 'E' => 'ERROR' }
- GROUPS =
{ '.' => :passed, 'S' => :skips, 'F' => :failures, 'E' => :errors }
- COLORS =
{ tests: :blue_a700, passed: :green_500, failures: :red_500, errors: :amber_300, skips: :cyan_300, assertions: :purple_400 }
- VERSION =
'0.1.3'
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#previous_context ⇒ Object
readonly
Returns the value of attribute previous_context.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
-
#initialize(io) ⇒ Colorin
constructor
A new instance of Colorin.
- #passed? ⇒ Boolean
- #record(result) ⇒ Object
- #report ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(io) ⇒ Colorin
Returns a new instance of Colorin.
47 48 49 50 51 |
# File 'lib/minitest/colorin.rb', line 47 def initialize(io) @io = io @previous_context = nil @results = [] end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
45 46 47 |
# File 'lib/minitest/colorin.rb', line 45 def io @io end |
#previous_context ⇒ Object (readonly)
Returns the value of attribute previous_context.
45 46 47 |
# File 'lib/minitest/colorin.rb', line 45 def previous_context @previous_context end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
45 46 47 |
# File 'lib/minitest/colorin.rb', line 45 def results @results end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
45 46 47 |
# File 'lib/minitest/colorin.rb', line 45 def started_at @started_at end |
Instance Method Details
#passed? ⇒ Boolean
82 83 84 |
# File 'lib/minitest/colorin.rb', line 82 def passed? results.all? { |r| r.failures.empty? } end |
#record(result) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/minitest/colorin.rb', line 58 def record(result) @results << result test_id = TestID.new result if test_id.context != @previous_context io.puts io.puts ::Colorin.white(test_id.context).bold @previous_context = test_id.context end label = colorin(LABELS[result.result_code], GROUPS[result.result_code]) number = ::Colorin.grey_600(test_id.number) time = ::Colorin.grey_600("(#{result.time.round(3)}s)") = case result.result_code when 'S' then colorin(result.failures[0]., :skips) when 'F' then colorin(relative_path(result.failures[0].location), :failures) when 'E' then colorin((result), :errors) else nil end io.puts " #{label} #{number} #{test_id.name} #{time} #{message}" end |
#report ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/minitest/colorin.rb', line 86 def report io.puts print_detail_of :skips print_detail_of :failures print_detail_of :errors print_total_time print_summary end |
#start ⇒ Object
53 54 55 56 |
# File 'lib/minitest/colorin.rb', line 53 def start @started_at = Time.now io.puts "Started at #{started_at}" end |