Method: Tapout::Reporters::Abstract#tally_message

Defined in:
lib/tapout/reporters/abstract.rb

#tally_message(entry) ⇒ String

Generate a tally message given a tally or final entry.

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/tapout/reporters/abstract.rb', line 219

def tally_message(entry)
  sums = count_tally(entry)

  total, pass, fail, error, todo, omit = *sums

  # TODO: Assertion counts isn't TAP-Y/J spec, is it a good idea to add ?
  if entry['counts'] && entry['counts']['assertions']
    assertions = entry['counts']['assertions']['pass']
    failures   = entry['counts']['assertions']['fail']
  else
    assertions = nil
    failures   = nil
  end

  text = []
  text << "%s pass".ansi(*config.pass)
  text << "%s fail".ansi(*config.fail)
  text << "%s errs".ansi(*config.error)
  text << "%s todo".ansi(*config.todo)
  text << "%s omit".ansi(*config.omit)
  text = "%s tests: " + text.join(", ")

  if assertions
    text << " (%s/%s assertions)"
    text = text % (sums + [assertions - failures, assertions])
  else
    text = text % sums
  end

  text
end