Class: Smartest::Reporter
- Inherits:
-
Object
- Object
- Smartest::Reporter
- Defined in:
- lib/smartest/reporter.rb
Constant Summary collapse
- PASS_MARK =
"\u2713"- FAIL_MARK =
"\u2717"
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.
8 9 10 |
# File 'lib/smartest/reporter.rb', line 8 def initialize(io = $stdout) @io = io end |
Instance Method Details
#finish(results, suite_cleanup_errors: [], suite_errors: []) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/smartest/reporter.rb', line 22 def finish(results, suite_cleanup_errors: [], suite_errors: []) failures = results.select(&:failed?) 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" 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
17 18 19 20 |
# File 'lib/smartest/reporter.rb', line 17 def record(result) mark = result.passed? ? PASS_MARK : FAIL_MARK @io.puts "#{mark} #{result.test_case.name}" end |
#start(count) ⇒ Object
12 13 14 15 |
# File 'lib/smartest/reporter.rb', line 12 def start(count) @io.puts "Running #{count} #{count == 1 ? 'test' : 'tests'}" @io.puts end |