Class: Smartest::Reporter
- Inherits:
-
Object
- Object
- Smartest::Reporter
- Defined in:
- lib/smartest/reporter.rb
Constant Summary collapse
- PASS_MARK =
"\u2713"- FAIL_MARK =
"\u2717"- SKIP_MARK =
"-"- PENDING_MARK =
"*"
Instance Method Summary collapse
- #finish(results, suite_cleanup_errors: [], suite_errors: []) ⇒ Object
-
#initialize(io = $stdout) ⇒ Reporter
constructor
A new instance of Reporter.
- #record(result) ⇒ Object
- #start(count) ⇒ Object
Constructor Details
#initialize(io = $stdout) ⇒ Reporter
Returns a new instance of Reporter.
10 11 12 |
# File 'lib/smartest/reporter.rb', line 10 def initialize(io = $stdout) @io = io end |
Instance Method Details
#finish(results, suite_cleanup_errors: [], suite_errors: []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/smartest/reporter.rb', line 23 def finish(results, suite_cleanup_errors: [], suite_errors: []) failures = results.select(&:failed?) skipped = results.select(&:skipped?) pending = results.select(&:pending?) report_failures(failures) if failures.any? report_suite_errors(suite_errors) if suite_errors.any? report_suite_cleanup_errors(suite_cleanup_errors) if suite_cleanup_errors.any? @io.puts summary = "#{results.count} #{results.count == 1 ? 'test' : 'tests'}, #{results.count(&:passed?)} passed, #{failures.count} failed" summary = "#{summary}, #{skipped.count} skipped" if skipped.any? summary = "#{summary}, #{pending.count} pending" if pending.any? if suite_errors.any? suite_label = suite_errors.count == 1 ? "suite failure" : "suite failures" summary = "#{summary}, #{suite_errors.count} #{suite_label}" end if suite_cleanup_errors.any? cleanup_label = suite_cleanup_errors.count == 1 ? "suite cleanup" : "suite cleanups" summary = "#{summary}, #{suite_cleanup_errors.count} #{cleanup_label} failed" end @io.puts summary end |
#record(result) ⇒ Object
19 20 21 |
# File 'lib/smartest/reporter.rb', line 19 def record(result) @io.puts record_line(result) end |
#start(count) ⇒ Object
14 15 16 17 |
# File 'lib/smartest/reporter.rb', line 14 def start(count) @io.puts "Running #{count} #{count == 1 ? 'test' : 'tests'}" @io.puts end |