Class: FancyTapReporter
- Inherits:
-
Tapout::Reporters::Abstract
- Object
- Tapout::Reporters::Abstract
- FancyTapReporter
- Defined in:
- lib/tapout/custom_reporters/fancy_tap_reporter.rb
Instance Method Summary collapse
- #error(entry) ⇒ Object
- #fail(entry) ⇒ Object
-
#finish_suite(entry) ⇒ Object
to print out formatted time and rates.
- #highlight(anything) ⇒ Object
- #pass(entry) ⇒ Object
- #start_case(entry) ⇒ Object
- #start_suite(entry) ⇒ Object
- #todo(entry) ⇒ Object
Instance Method Details
#error(entry) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 49 def error(entry) super(entry) @i += 1 x = entry['exception'] #desc = ok.concern.label + " #{ok.arguments.inspect}" body = [] body << "ERROR #{x['file']}:#{x['line']}" #clean_backtrace(exception.backtrace)[0..2].join(" \n") body << "#{x['class']}: #{x['message']}" body << "" body << x['backtrace'] body << entry['stdout'] body = body.join("\n").gsub(/^/, ' # ') puts "not ok".ansi(*config.error) + highlight(" #{@i} - #{entry['label']}") puts body end |
#fail(entry) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 28 def fail(entry) super(entry) @i += 1 x = entry['exception'] #desc = #ok.concern.label + " #{ok.arguments.inspect}" body = [] body << "FAIL #{x['file']}:#{x['line']}" #clean_backtrace(exception.backtrace)[0] body << "#{x['message']}" body << x['snippet'] body << x['backtrace'] body << entry['stdout'] body = body.join("\n").gsub(/^/, ' # ') puts "not ok".ansi(*config.fail) + highlight(" #{@i} - #{entry['label']}") puts body end |
#finish_suite(entry) ⇒ Object
to print out formatted time and rates
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 81 def finish_suite(entry) time, rate, avg = time_tally(entry) delta = duration(time) ending = [] ending << "" ending << (entry) ending << "[%s %.2ft/s %.4fs/t] " % [delta, rate, avg] + "Finished at: #{Time.now}" ending = ending.join("\n").gsub(/^/, ' # ') puts ending end |
#highlight(anything) ⇒ Object
76 77 78 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 76 def highlight(anything) anything.ansi(*config.highlight) end |
#pass(entry) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 18 def pass(entry) super(entry) @i += 1 #desc = entry['message'] #+ " #{ok.arguments.inspect}" puts "ok".ansi(*config.pass) + highlight(" #{@i} - #{entry['label']}") end |
#start_case(entry) ⇒ Object
13 14 15 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 13 def start_case(entry) #$stdout.puts concern.label.ansi(:bold) end |
#start_suite(entry) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 4 def start_suite(entry) @start = Time.now @i = 0 #n = 0 #suite.concerns.each{ |f| f.concerns.each { |s| n += s.ok.size } } puts "1..#{entry['count']}" end |
#todo(entry) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/tapout/custom_reporters/fancy_tap_reporter.rb', line 69 def todo(entry) super(entry) @i += 1 puts 'ok'.ansi(*config.pass) + highlight(" #{@i} - #{entry['label']} # skip #{entry['exception']['message']}") puts " # #{entry['exception']['message']}" end |