Class: Webspicy::Tester::Reporter::Summary

Inherits:
Webspicy::Tester::Reporter show all
Defined in:
lib/webspicy/tester/reporter/summary.rb

Direct Known Subclasses

SuccessOrNot

Constant Summary

Constants inherited from Webspicy::Tester::Reporter

ErrorCount, HOOKS

Instance Attribute Summary collapse

Attributes inherited from Webspicy::Tester::Reporter

#io, #tester

Instance Method Summary collapse

Methods inherited from Webspicy::Tester::Reporter

#find, #init

Methods included from Support::Colorize

colorize, colorize_error, colorize_highlight, colorize_section, colorize_success

Constructor Details

#initialize(*args, &bl) ⇒ Summary

Returns a new instance of Summary.



6
7
8
9
# File 'lib/webspicy/tester/reporter/summary.rb', line 6

def initialize(*args, &bl)
  super
  clear
end

Instance Attribute Details

#assertions_countObject (readonly)

Returns the value of attribute assertions_count.



11
12
13
# File 'lib/webspicy/tester/reporter/summary.rb', line 11

def assertions_count
  @assertions_count
end

#counterexamples_countObject (readonly)

Returns the value of attribute counterexamples_count.



10
11
12
# File 'lib/webspicy/tester/reporter/summary.rb', line 10

def counterexamples_count
  @counterexamples_count
end

#errors_countObject (readonly)

Returns the value of attribute errors_count.



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

def errors_count
  @errors_count
end

#examples_countObject (readonly)

Returns the value of attribute examples_count.



10
11
12
# File 'lib/webspicy/tester/reporter/summary.rb', line 10

def examples_count
  @examples_count
end

#failures_countObject (readonly)

Returns the value of attribute failures_count.



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

def failures_count
  @failures_count
end

#spec_file_errors_countObject (readonly)

Returns the value of attribute spec_file_errors_count.



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

def spec_file_errors_count
  @spec_file_errors_count
end

#spec_files_countObject (readonly)

Returns the value of attribute spec_files_count.



10
11
12
# File 'lib/webspicy/tester/reporter/summary.rb', line 10

def spec_files_count
  @spec_files_count
end

Instance Method Details

#before_spec_fileObject



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

def before_spec_file
  @spec_files_count += 1
end

#clearObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/webspicy/tester/reporter/summary.rb', line 50

def clear
  @spec_files_count = 0
  @examples_count = 0
  @counterexamples_count = 0
  @assertions_count = 0
  #
  @spec_file_errors_count = 0
  @errors_count = 0
  @failures_count = 0
end

#reportObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/webspicy/tester/reporter/summary.rb', line 33

def report
  msg = "#{plural('spec file', spec_files_count)}, "\
        "#{plural('example', examples_count)}, "\
        "#{plural('counterexample', counterexamples_count)}\n"\
        "#{plural('assertion', assertions_count)}, "\
        "#{plural('error', errors_count)}, "\
        "#{plural('failure', failures_count)}"
  if success?
    msg = colorize_success(msg, config)
  else
    msg = colorize_error(msg, config)
  end
  io.puts(msg)
  io.puts
  io.flush
end

#spec_file_error(e) ⇒ Object



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

def spec_file_error(e)
  @spec_file_errors_count += 1
end

#success?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/webspicy/tester/reporter/summary.rb', line 65

def success?
  total_error_count == 0
end

#test_case_doneObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/webspicy/tester/reporter/summary.rb', line 22

def test_case_done
  if tester.test_case.counterexample?
    @counterexamples_count += 1
  else
    @examples_count += 1
  end
  @assertions_count += tester.result.assertions_count
  @errors_count += tester.result.errors_count
  @failures_count += tester.result.failures_count
end

#total_error_countObject



61
62
63
# File 'lib/webspicy/tester/reporter/summary.rb', line 61

def total_error_count
  @spec_file_errors_count + @errors_count + @failures_count
end