Class: Tapout::Reporters::Markdown

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

Overview

Markdown 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, #start_test, #tally, #tally_message, #time_tally, #todo

Constructor Details

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

Instance Method Details

#error(entry) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/tapout/reporters/markdown_reporter.rb', line 63

def error(entry)
  super(entry)

  $stdout.puts "#{mark}" + entry['label'] + "   #{entry['source']}"

  $stdout.puts "\n**MESSAGE**\n\n"
  $stdout.puts entry['exception']['message'].tabto(4)

  $stdout.puts "\n**TYPE**\n\n"
  $stdout.puts entry['exception']['class'].tabto(4)

  #$stdout.puts "    " + ok.caller #clean_backtrace(exception.backtrace)[0..2].join("    \n")

  $stdout.puts "\n**SNIPPET**\n\n"
  $stdout.puts code_snippet(entry['exception'])

  if captured_stdout?(entry)
    $stdout.puts "\n**STDOUT**\n\n"
    $stdout.puts captured_stdout(entry).tabto(4)
  end

  if captured_stderr?(entry)
    $stdout.puts "\n**STDERR**\n\n"
    $stdout.puts captured_stderr(entry).tabto(4)
  end

  $stdout.puts
end

#fail(entry) ⇒ Object



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
# File 'lib/tapout/reporters/markdown_reporter.rb', line 33

def fail(entry)
  super(entry)

  $stdout.puts "#{mark}" + entry['label'] + "   #{entry['source']}"

  $stdout.puts "\n**MESSAGE**\n\n"
  $stdout.puts entry['exception']['message'].tabto(4)

  $stdout.puts "\n**TYPE**\n\n"
  $stdout.puts entry['exception']['class'].tabto(4)

  #$stdout.puts "    " + ok.caller #clean_backtrace(exception.backtrace)[0]

  $stdout.puts "\n**SNIPPET**\n\n"
  $stdout.puts code_snippet(entry['exception'])

  if captured_stdout?(entry)
    $stdout.puts "\n**STDOUT**\n\n"
    $stdout.puts captured_stdout(entry).tabto(4)
  end

  if captured_stderr?(entry)
    $stdout.puts "\n**STDERR**\n\n"
    $stdout.puts captured_stderr(entry).tabto(4)
  end

  $stdout.puts
end

#finish_suite(entry) ⇒ Object



93
94
95
96
97
# File 'lib/tapout/reporters/markdown_reporter.rb', line 93

def finish_suite(entry)
  #$stderr.puts
  $stderr.print tally_message(entry)
  $stderr.puts " [%0.4fs] " % [Time.now - @start_time]
end

#markObject



15
16
17
# File 'lib/tapout/reporters/markdown_reporter.rb', line 15

def mark
  ('#' * (@_level + 1)) + ' '
end

#pass(entry) ⇒ Object



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

def pass(entry)
  super(entry)
  $stdout.puts "#{mark}" + entry['label'] + "   #{entry['source']}"
end

#start_case(entry) ⇒ Object



20
21
22
23
24
# File 'lib/tapout/reporters/markdown_reporter.rb', line 20

def start_case(entry)
  @_level = entry['level'].to_i + 1
  $stdout.print('#' * @_level + ' ')
  $stdout.puts(entry['label'])
end

#start_suite(entry) ⇒ Object



10
11
12
# File 'lib/tapout/reporters/markdown_reporter.rb', line 10

def start_suite(entry)
  @start_time = Time.now
end