Display summary from default formatter

This commit is contained in:
Michael Miller 2018-09-15 13:51:07 -06:00
parent b329afffb6
commit 8e1a2e114b
2 changed files with 33 additions and 2 deletions

View file

@ -9,6 +9,9 @@ module Spectator
def end_suite(results : TestResults)
puts
puts
puts finish_time_string(results)
puts result_string(results)
end
def start_example(example : Example)
@ -26,6 +29,22 @@ module Spectator
"F".colorize.red
end
end
private def finish_time_string(results)
"Finished in #{human_time(results.runtime)}"
end
private def result_string(results)
examples = results.examples
failures = results.failed_examples
errors = results.errored_examples
pending = results.pending_examples
"#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending"
end
private def human_time(span : Time::Span)
span.to_s
end
end
end
end

View file

@ -8,12 +8,24 @@ module Spectator
@results = results.to_a
end
def examples
@results.size
end
def successful_examples
@results.select { |result| result.successful? }
@results.count(&.successful?)
end
def failed_examples
@results.select { |result| result.failed? }
@results.count(&.failed?)
end
def errored_examples
@results.count(&.errored?)
end
def pending_examples
@results.count(&.pending?)
end
def example_runtime