Class: Webspicy::Tester::Reporter::Exceptions

Inherits:
Webspicy::Tester::Reporter show all
Includes:
Documentation::Helpers
Defined in:
lib/webspicy/tester/reporter/exceptions.rb

Constant Summary

Constants inherited from Webspicy::Tester::Reporter

HOOKS

Instance Attribute Summary collapse

Attributes inherited from Webspicy::Tester::Reporter

#io, #tester

Instance Method Summary collapse

Methods included from Documentation::Helpers

#check_error_line, #check_failure_line, #check_success_line, #service_line, #spec_file_error_line

Methods inherited from Webspicy::Tester::Reporter

#init

Methods included from Support::Colorize

colorize, colorize_error, colorize_highlight, colorize_success

Constructor Details

#initialize(*args, &bl) ⇒ Exceptions

Returns a new instance of Exceptions.



7
8
9
10
11
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 7

def initialize(*args, &bl)
  super
  @spec_file_errors = []
  @failed_results = []
end

Instance Attribute Details

#failed_resultsObject (readonly)

Returns the value of attribute failed_results.



12
13
14
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 12

def failed_results
  @failed_results
end

#spec_file_errorsObject (readonly)

Returns the value of attribute spec_file_errors.



12
13
14
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 12

def spec_file_errors
  @spec_file_errors
end

Instance Method Details

#after_each_doneObject



18
19
20
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 18

def after_each_done
  @failed_results << result unless result.success?
end

#reportObject



22
23
24
25
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 22

def report
  report_spec_file_errors
  report_failed_results
end

#report_failed_resultsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 39

def report_failed_results
  return if failed_results.empty?
  io.puts
  io.puts "Exceptions:"
  io.puts
  failed_results.each_with_index do |result,i|
    io.puts service_line(result.service, result.test_case)
    result.failures.each do |(c,e)|
      io.puts check_failure_line(c,e)
    end
    result.errors.each do |(c,e)|
      io.puts check_error_line(c,e)
      io.puts e.backtrace.join("\n").gsub(/^/, "  ") if e.backtrace
    end
    io.puts
  end
  io.puts
  io.flush
end

#report_spec_file_errorsObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 27

def report_spec_file_errors
  return if spec_file_errors.empty?
  io.puts
  io.puts "Invalid specs:"
  io.puts
  spec_file_errors.each do |e|
    io.puts e
  end
  io.puts
  io.flush
end

#spec_file_error(e) ⇒ Object



14
15
16
# File 'lib/webspicy/tester/reporter/exceptions.rb', line 14

def spec_file_error(e)
  @spec_file_errors << spec_file_error_line(spec_file, e)
end