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

Inherits:
Webspicy::Tester::Reporter show all
Defined in:
lib/webspicy/tester/reporter/summary.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 inherited from Webspicy::Tester::Reporter

#init

Methods included from Support::Colorize

colorize, colorize_error, colorize_highlight, colorize_success

Constructor Details

#initialize(*args, &bl) ⇒ Summary

Returns a new instance of Summary.



6
7
8
9
10
11
12
13
14
# File 'lib/webspicy/tester/reporter/summary.rb', line 6

def initialize(*args, &bl)
  super
  @spec_files_count = 0
  @examples_count = 0
  @counterexamples_count = 0
  @assertions_count = 0
  @errors_count = 0
  @failures_count = 0
end

Instance Attribute Details

#assertions_countObject (readonly)

Returns the value of attribute assertions_count.



16
17
18
# File 'lib/webspicy/tester/reporter/summary.rb', line 16

def assertions_count
  @assertions_count
end

#counterexamples_countObject (readonly)

Returns the value of attribute counterexamples_count.



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

def counterexamples_count
  @counterexamples_count
end

#errors_countObject (readonly)

Returns the value of attribute errors_count.



16
17
18
# File 'lib/webspicy/tester/reporter/summary.rb', line 16

def errors_count
  @errors_count
end

#examples_countObject (readonly)

Returns the value of attribute examples_count.



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

def examples_count
  @examples_count
end

#failures_countObject (readonly)

Returns the value of attribute failures_count.



16
17
18
# File 'lib/webspicy/tester/reporter/summary.rb', line 16

def failures_count
  @failures_count
end

#spec_files_countObject (readonly)

Returns the value of attribute spec_files_count.



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

def spec_files_count
  @spec_files_count
end

Instance Method Details

#after_each_doneObject



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

def after_each_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

#before_spec_fileObject



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

def before_spec_file
  @spec_files_count += 1
end

#reportObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/webspicy/tester/reporter/summary.rb', line 37

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)
  else
    msg = colorize_error(msg)
  end
  io.puts(msg)
  io.puts
  io.flush
end

#spec_file_error(e) ⇒ Object



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

def spec_file_error(e)
  @errors_count += 1
end