Module: Overseer::Reporter

Extended by:
Reporter
Included in:
Reporter
Defined in:
lib/overseer/reporter.rb

Instance Method Summary collapse

Instance Method Details

#filter_backtrace(backtrace) ⇒ Object



56
57
58
59
60
# File 'lib/overseer/reporter.rb', line 56

def filter_backtrace(backtrace)
  backtrace.reject do |line|
    line.rindex(OVERSEER_DIR, 0)
  end
end

#format_backtrace_output(backtrace) ⇒ Object



62
63
64
# File 'lib/overseer/reporter.rb', line 62

def format_backtrace_output(backtrace)
  backtrace.map { |line| "     # #{line}"}.join("\n")
end


11
12
13
14
# File 'lib/overseer/reporter.rb', line 11

def print_header
  puts "Overseer is running..."
  puts
end


28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/overseer/reporter.rb', line 28

def print_open_issues
  if Overseer.failures_exists? || Overseer.errors_exists?
    print "\nOpen issues:\n"
    counter = 1
    Overseer.suites.each do |suite|
      suite.tests.each do |test|
        unless test.passed?
          print_test_issues(test, counter)
          counter += 1
        end
      end
    end
  end
end


24
25
26
# File 'lib/overseer/reporter.rb', line 24

def print_single_test_result(test)
  print(test.passed? ? Color.green(".") : (test.errors? ? Color.red("E") : Color.red("F")))
end


43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/overseer/reporter.rb', line 43

def print_test_issues(test, counter)
  puts
  puts "  #{counter}) #{(test.errors?) ? Color.red("Error:") : Color.red("Failure:")}"
  puts "     Test: #{test.name} (in #{test.suite.name} Suite)"
  exception = if test.errors?
                test.errors.first
              else
                test.failures.first
              end
  puts Color.red("     #{exception.message}")
  puts Color.bright_black("#{format_backtrace_output(filter_backtrace(exception.backtrace))}")
end


16
17
18
19
20
21
22
# File 'lib/overseer/reporter.rb', line 16

def print_test_report
  puts
  print_open_issues
  puts
  puts "Finished in %.3f seconds" % Overseer.total_time
  puts Color.green("#{Overseer.total_tests} tests, #{Overseer.total_assertions} assertions, #{Overseer.total_failures} failures, #{Overseer.total_errors} errors")
end

#reportObject



5
6
7
8
9
# File 'lib/overseer/reporter.rb', line 5

def report
  print_header
  yield
  print_test_report
end