Class: Tapout::Reporters::Outline

Inherits:
Abstract
  • Object
show all
Defined in:
lib/tapout/reporters/outline_reporter.rb

Overview

Outline reporter.

TODO: Not sure there is really any good point to this reporter.

Constant Summary

Constants inherited from Abstract

Abstract::INTERNALS

Instance Method Summary collapse

Methods inherited from Abstract

#<<, #backtrace, #backtrace_snippets, #backtrace_snippets_chain, #captured_output, #captured_output?, #captured_stderr, #captured_stderr?, #captured_stdout, #captured_stdout?, #clean_backtrace, #code_snippet, #complete_cases, #config, #count_tally, #duration, #exit_code, #finalize, #finish_case, #finish_test, #format_snippet_array, #handle, inherited, #initialize, #note, #omit, #parse_backtrace, #parse_source_location, #source, #tally, #tally_message, #time_tally, #todo

Constructor Details

This class inherits a constructor from Tapout::Reporters::Abstract

Instance Method Details

#case_count(entry) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/tapout/reporters/outline_reporter.rb', line 33

def case_count(entry)
  level = entry['level'].to_i
  @_case_count = @_case_count[0,level+1]
  @_case_count[level] ||= 0
  @_case_count[level] += 1
  @_case_count.join('.') #+ '.'
  @_case_count[level].to_s
end

#error(entry) ⇒ Object



65
66
67
68
69
# File 'lib/tapout/reporters/outline_reporter.rb', line 65

def error(entry)
  super(entry)

  printout(entry, 'ERROR', config.error)
end

#fail(entry) ⇒ Object



59
60
61
62
63
# File 'lib/tapout/reporters/outline_reporter.rb', line 59

def fail(entry)
  super(entry)

  printout(entry, 'FAIL', config.fail)
end

#finish_suite(entry) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/tapout/reporters/outline_reporter.rb', line 72

def finish_suite(entry)
  time, rate, avg = time_tally(entry)
  delta = duration(time)

  puts
  print tally_message(entry)
  #puts " [%0.4fs %.4ft/s %.4fs/t] " % [time, rate, avg]
  puts " [%s %.2ft/s %.4fs/t] " % [delta, rate, avg]
end

#level_tabObject



28
29
30
# File 'lib/tapout/reporters/outline_reporter.rb', line 28

def level_tab
  2 * (@_level + 1)
end

#pass(entry) ⇒ Object



53
54
55
56
57
# File 'lib/tapout/reporters/outline_reporter.rb', line 53

def pass(entry)
  super(entry)
  print(' ' * level_tab)
  puts "#{test_count}. " + entry['label'].ansi(:green) + "   #{entry['source']}"
end

#printout(entry, type, ansi) ⇒ Object (private)



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/tapout/reporters/outline_reporter.rb', line 85

def printout(entry, type, ansi)
  counter = "#{test_count}. "

  label   = entry['label'].ansi(*ansi)
  message = entry['exception']['message']
  exclass = entry['exception']['class']

  parts = [message, exclass].compact.reject{ |x| x.strip.empty? }

  print(' ' * level_tab)
  puts counter + label + "   #{entry['source']}"
  puts
  puts parts.join("\n\n").tabto(level_tab+counter.size)
  puts
  puts backtrace_snippets(entry).tabto(level_tab++counter.size+4)
  print captured_output(entry).tabto(level_tab+counter.size)
  puts
end

#start_case(entry) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/tapout/reporters/outline_reporter.rb', line 18

def start_case(entry)
  @_test_count = 0
  @_level = entry['level'].to_i

  print(' ' * (level_tab - 2))
  puts(case_count(entry) + '. ' + entry['label'].ansi(*config.highlight))
  #puts
end

#start_suite(entry) ⇒ Object



12
13
14
15
# File 'lib/tapout/reporters/outline_reporter.rb', line 12

def start_suite(entry)
  @_case_count = [0]
  @start_time = Time.now
end

#start_test(test) ⇒ Object



43
44
45
# File 'lib/tapout/reporters/outline_reporter.rb', line 43

def start_test(test)
  @_test_count += 1
end

#test_countObject



48
49
50
# File 'lib/tapout/reporters/outline_reporter.rb', line 48

def test_count
  @_test_count
end