Module: Tet::Stats

Defined in:
lib/tet.rb

Overview

Tracks and reports statistics about the tests that have run

Constant Summary collapse

Counts =
{ passed: 0,  failed: 0,  erred: 0  }
Marks =
{ passed: ?., failed: ?!, erred: ?? }

Class Method Summary collapse

Class Method Details

.empty?Boolean

Returns true if no statistics have been logged



176
177
178
# File 'lib/tet.rb', line 176

def empty?
  Counts.values.inject(&:+).zero?
end

.erredObject

Call when an assertion has erred



171
172
173
# File 'lib/tet.rb', line 171

def erred
  log :erred
end

.failedObject

Call when an assertion has failed



166
167
168
# File 'lib/tet.rb', line 166

def failed
  log :failed
end

.passedObject

Call when an assertion has passed



161
162
163
# File 'lib/tet.rb', line 161

def passed
  log :passed
end

.reportObject

Returns a string with statistics about the tests that have been run



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/tet.rb', line 181

def report
  errors = Counts[:erred]
  fails  = Counts[:failed]
  passes = Counts[:passed]

  output = []
  output << "Errors: #{errors}" unless errors.zero?
  output << "Failed: #{fails}"
  output << "Passed: #{passes}"

  output.join(?\n)
end