Class: Shoe::Util::MiniTestColors
- Inherits:
-
IO
- Object
- IO
- Shoe::Util::MiniTestColors
- Defined in:
- lib/shoe/util/minitest_colors.rb
Constant Summary collapse
- RED =
31
- GREEN =
32
- YELLOW =
33
- CYAN =
36
- STATUS =
/\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors, \d+ skips/
Instance Method Summary collapse
Instance Method Details
#print(object) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/shoe/util/minitest_colors.rb', line 12 def print(object) case object when '.' super color(GREEN, object) when 'F' super color(RED, object) when 'E' super color(YELLOW, object) when 'S' super color(CYAN, object) else super end end |
#puts(*objects) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/shoe/util/minitest_colors.rb', line 29 def puts(*objects) if objects.size == 1 string = objects.first string.gsub!(STATUS) do |match| failures, errors = $1.to_i, $2.to_i if failures + errors == 0 color(GREEN, match) else color(RED, match) end end string.gsub!(/\bFailure:/) { |s| color(RED, s) } string.gsub!(/\bError:/) { |s| color(YELLOW, s) } string.gsub!(/\bSkipped:/) { |s| color(CYAN, s) } end super end |