Class: Teaspoon::Formatter::Base
- Inherits:
-
Object
- Object
- Teaspoon::Formatter::Base
- Defined in:
- lib/teaspoon/formatter/base.rb
Direct Known Subclasses
Documentation, Dot, Json, Junit, RspecHtml, SwayzeOrOprah, Tap, TapY, Teamcity
Constant Summary collapse
- RESERVED_PARAMS =
["body", "instrument"]
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.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/teaspoon/formatter/base.rb', line 8 def initialize(suite_name = :default, output_file = nil) @suite_name = suite_name.to_s @output_file = parse_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.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def failures @failures end |
#passes ⇒ Object
Returns the value of attribute passes.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def passes @passes end |
#pendings ⇒ Object
Returns the value of attribute pendings.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def pendings @pendings end |
#run_count ⇒ Object
Returns the value of attribute run_count.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def run_count @run_count end |
#total_count ⇒ Object
Returns the value of attribute total_count.
6 7 8 |
# File 'lib/teaspoon/formatter/base.rb', line 6 def total_count @total_count end |
Instance Method Details
#complete(failure_count, log = true) ⇒ Object
83 84 85 |
# File 'lib/teaspoon/formatter/base.rb', line 83 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
63 64 65 66 |
# File 'lib/teaspoon/formatter/base.rb', line 63 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
74 75 76 |
# File 'lib/teaspoon/formatter/base.rb', line 74 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
52 53 54 55 |
# File 'lib/teaspoon/formatter/base.rb', line 52 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)
58 59 60 |
# File 'lib/teaspoon/formatter/base.rb', line 58 def exception(result = {}, log = true) log_exception(result) if log end |
#result(result, log = true) ⇒ Object
final report
69 70 71 |
# File 'lib/teaspoon/formatter/base.rb', line 69 def result(result, log = true) log_result(result) if log end |
#runner(result, log = true) ⇒ Object
beginning of the run
25 26 27 28 |
# File 'lib/teaspoon/formatter/base.rb', line 25 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
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/teaspoon/formatter/base.rb', line 38 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
31 32 33 34 35 |
# File 'lib/teaspoon/formatter/base.rb', line 31 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
79 80 81 |
# File 'lib/teaspoon/formatter/base.rb', line 79 def threshold_failure(, log = true) log_threshold_failure() if log end |