Module: Minitest::Display

Defined in:
lib/minitest/display.rb

Defined Under Namespace

Classes: Reporter

Constant Summary collapse

VERSION =
'0.3.1'
DONT_PRINT_CLASSES =
%w{
ActionDispatch::IntegrationTest
ActionController::IntegrationTest
ActionController::TestCase
ActionMailer::TestCase
ActionView::TestCase
ActiveRecord::TestCase
ActiveSupport::TestCase
Test::Unit::TestCase
MiniTest::Unit::TestCase
MiniTest::Spec}

Class Method Summary collapse

Class Method Details

.add_recorder(new_recorder) ⇒ Object

Add a recorder which for each test that has a ‘record`. Optionally can also have an:

‘record_tests_started`, `record_suite_started(suite)`, `record(suite, method, assertions, time, error)` `record_suite_finished(suite, assertions, time)`, `record_tests_finished(test_count, assertion_count, failure_count, error_count, time)

(Executed in that order)



128
129
130
131
132
# File 'lib/minitest/display.rb', line 128

def add_recorder(new_recorder)
  new_recorder_instance = new_recorder.new(self)
  @recorders ||= []
  @recorders << new_recorder_instance
end

.color(string, color) ⇒ Object



83
84
85
86
# File 'lib/minitest/display.rb', line 83

def color(string, color)
  return string unless STDOUT.tty? && options[:color]
  tint(color) + string + tint(:clear)
end

.optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/minitest/display.rb', line 26

def options
  @options ||= {
    :suite_names => true,
    :suite_divider => " | ",
    :suite_time => true,
    :color => true,
    :wrap_at => 80,
    :output_slow => 5,
    :output_slow_suites => 5,
    :print => {
      :success => '.',
      :failure => 'F',
      :error => 'E'
    },
    :colors => {
      :clear => 0,
      :bold => 1,
      :italics => 3,
      :underline => 4,
      :inverse => 9,
      :strikethrough => 22,
      :bold_off => 23,
      :italics_off => 24,
      :underline_off => 27,
      :inverse_off => 29,
      :strikethrough_off => 30,
      :black => 30,
      :red => 31,
      :green => 32,
      :yellow => 33,
      :blue => 34,
      :magenta => 35,
      :cyan => 36,
      :white => 37,
      :default => 39,
      :bg_black => 40,
      :bg_red => 41,
      :bg_green => 42,
      :bg_yellow => 43,
      :bg_blue => 44,
      :bg_magenta => 45,
      :bg_cyan => 46,
      :bg_white => 47,
      :bg_default => 49,

      :suite => :clear,
      :success => :green,
      :failure => :red,
      :error => :yellow
    }
  }
end

.options=(new_options) ⇒ Object



79
80
81
# File 'lib/minitest/display.rb', line 79

def options=(new_options)
  self.options.deep_merge!(new_options)
end

.printable_suite?(suite) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/minitest/display.rb', line 113

def printable_suite?(suite)
  !DONT_PRINT_CLASSES.include?(suite.to_s)
end

.recordersObject

An array of all the registered MiniTest::Display recorders



135
136
137
# File 'lib/minitest/display.rb', line 135

def recorders
  @recorders || []
end

.tint(color) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/minitest/display.rb', line 88

def tint(color)
  case color
  when Array
    color.collect {|c| tint(c) }.join('')
  when Symbol
    if c = options[:colors][color]
      tint(c)
    end
  else
    "\e[#{color}m"
  end
end