Class: Teaspoon::Formatters::Base
- Inherits:
-
Object
- Object
- Teaspoon::Formatters::Base
- Defined in:
- lib/teaspoon/formatters/base.rb
Direct Known Subclasses
DocumentationFormatter, DotFormatter, JsonFormatter, JunitFormatter, SwayzeOrOprahFormatter, TapFormatter, TapYFormatter, TeamcityFormatter
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#passes ⇒ Object
Returns the value of attribute passes.
-
#pendings ⇒ Object
Returns the value of attribute pendings.
-
#run_count ⇒ Object
Returns the value of attribute run_count.
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Instance Method Summary collapse
- #complete(failure_count, log = true) ⇒ Object
-
#console(message, log = true) ⇒ Object
console message come from console.log/debug/error.
-
#coverage(message, log = true) ⇒ Object
called with the text versions of coverage if configured to do so.
-
#error(result, log = true) ⇒ Object
errors are reported from the onError handler in phantomjs, so they’re not linked to a result.
-
#exception(result = {}, log = true) ⇒ Object
exception came from startup errors in the server (will exit after logging).
-
#initialize(suite_name = :default, output_file = nil) ⇒ Base
constructor
A new instance of Base.
-
#result(result, log = true) ⇒ Object
final report.
-
#runner(result, log = true) ⇒ Object
beginning of the run.
-
#spec(result, log = true) ⇒ Object
each spec, after the spec has reported to the client runner.
-
#suite(result, log = true) ⇒ Object
each suite, before any specs.
-
#threshold_failure(message, log = true) ⇒ Object
called with an array of strings which explain which coverage thresholds failed.
Constructor Details
#initialize(suite_name = :default, output_file = nil) ⇒ Base
Returns a new instance of Base.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/teaspoon/formatters/base.rb', line 28 def initialize(suite_name = :default, output_file = nil) @suite_name = suite_name.to_s @output_file = output_file @stdout = "" @suite = nil @last_suite = nil @total_count = 0 @run_count = 0 @passes = [] @pendings = [] @failures = [] @errors = [] File.open(@output_file, "w") { |f| f.write("") } if @output_file end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def failures @failures end |
#passes ⇒ Object
Returns the value of attribute passes.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def passes @passes end |
#pendings ⇒ Object
Returns the value of attribute pendings.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def pendings @pendings end |
#run_count ⇒ Object
Returns the value of attribute run_count.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def run_count @run_count end |
#total_count ⇒ Object
Returns the value of attribute total_count.
26 27 28 |
# File 'lib/teaspoon/formatters/base.rb', line 26 def total_count @total_count end |
Instance Method Details
#complete(failure_count, log = true) ⇒ Object
103 104 105 |
# File 'lib/teaspoon/formatters/base.rb', line 103 def complete(failure_count, log = true) log_complete(failure_count) if log end |
#console(message, log = true) ⇒ Object
console message come from console.log/debug/error
83 84 85 86 |
# File 'lib/teaspoon/formatters/base.rb', line 83 def console(, log = true) @stdout << log_console() if log end |
#coverage(message, log = true) ⇒ Object
called with the text versions of coverage if configured to do so
94 95 96 |
# File 'lib/teaspoon/formatters/base.rb', line 94 def coverage(, log = true) log_coverage() if log end |
#error(result, log = true) ⇒ Object
errors are reported from the onError handler in phantomjs, so they’re not linked to a result
72 73 74 75 |
# File 'lib/teaspoon/formatters/base.rb', line 72 def error(result, log = true) @errors << result log_error(result) if log end |
#exception(result = {}, log = true) ⇒ Object
exception came from startup errors in the server (will exit after logging)
78 79 80 |
# File 'lib/teaspoon/formatters/base.rb', line 78 def exception(result = {}, log = true) log_exception(result) if log end |
#result(result, log = true) ⇒ Object
final report
89 90 91 |
# File 'lib/teaspoon/formatters/base.rb', line 89 def result(result, log = true) log_result(result) if log end |
#runner(result, log = true) ⇒ Object
beginning of the run
45 46 47 48 |
# File 'lib/teaspoon/formatters/base.rb', line 45 def runner(result, log = true) @total_count = result.total log_runner(result) if log end |
#spec(result, log = true) ⇒ Object
each spec, after the spec has reported to the client runner
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/teaspoon/formatters/base.rb', line 58 def spec(result, log = true) @run_count += 1 if result.passing? @passes << result elsif result.pending? @pendings << result else @failures << result end log_spec(result) if log @stdout = "" end |
#suite(result, log = true) ⇒ Object
each suite, before any specs
51 52 53 54 55 |
# File 'lib/teaspoon/formatters/base.rb', line 51 def suite(result, log = true) @suite = result log_suite(result) if log @last_suite = result end |
#threshold_failure(message, log = true) ⇒ Object
called with an array of strings which explain which coverage thresholds failed
99 100 101 |
# File 'lib/teaspoon/formatters/base.rb', line 99 def threshold_failure(, log = true) log_threshold_failure() if log end |