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
10
11
12
13
14
15
16
# 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
  #
  @spec_file_errors_count = 0
  @errors_count = 0
  @failures_count = 0
end

Instance Attribute Details

#assertions_countObject (readonly)

Returns the value of attribute assertions_count.



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

def assertions_count
  @assertions_count
end

#counterexamples_countObject (readonly)

Returns the value of attribute counterexamples_count.



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

def counterexamples_count
  @counterexamples_count
end

#errors_countObject (readonly)

Returns the value of attribute errors_count.



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

def errors_count
  @errors_count
end

#examples_countObject (readonly)

Returns the value of attribute examples_count.



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

def examples_count
  @examples_count
end

#failures_countObject (readonly)

Returns the value of attribute failures_count.



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

def failures_count
  @failures_count
end

#spec_file_errors_countObject (readonly)

Returns the value of attribute spec_file_errors_count.



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

def spec_file_errors_count
  @spec_file_errors_count
end

#spec_files_countObject (readonly)

Returns the value of attribute spec_files_count.



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

def spec_files_count
  @spec_files_count
end

Instance Method Details

#before_spec_fileObject



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

def before_spec_file
  @spec_files_count += 1
end

#reportObject



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

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



25
26
27
# File 'lib/webspicy/tester/reporter/summary.rb', line 25

def spec_file_error(e)
  @spec_file_errors_count += 1
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  total_error_count == 0
end

#test_case_doneObject



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

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



57
58
59
# File 'lib/webspicy/tester/reporter/summary.rb', line 57

def total_error_count
  @spec_file_errors_count + @errors_count + @failures_count
end