diff --git a/src/spectator/formatting/components/failure_command_list.cr b/src/spectator/formatting/components/failure_command_list.cr new file mode 100644 index 0000000..c6f247b --- /dev/null +++ b/src/spectator/formatting/components/failure_command_list.cr @@ -0,0 +1,16 @@ +require "./example_command" + +module Spectator::Formatting::Components + struct FailureCommandList + def initialize(@failures : Enumerable(Example)) + end + + def to_s(io) + io.puts "Failed examples:" + io.puts + @failures.each do |failure| + io.puts ExampleCommand.new(failure).colorize(:red) + end + end + end +end diff --git a/src/spectator/formatting/components/stats.cr b/src/spectator/formatting/components/stats.cr index 4828c00..3daa837 100644 --- a/src/spectator/formatting/components/stats.cr +++ b/src/spectator/formatting/components/stats.cr @@ -1,4 +1,3 @@ -require "./example_command" require "./runtime" require "./totals" @@ -9,30 +8,17 @@ module Spectator::Formatting::Components end def to_s(io) - timing_line(io) - totals_line(io) - - unless (failures = @report.failures).empty? - io.puts - failures_block(io, failures) - end + runtime(io) + totals(io) end - private def timing_line(io) + private def runtime(io) io << "Finished in " io.puts Runtime.new(@report.runtime) end - private def totals_line(io) + private def totals(io) io.puts Totals.colorize(@report.counts) end - - private def failures_block(io, failures) - io.puts "Failed examples:" - io.puts - failures.each do |failure| - io.puts ExampleCommand.new(failure).colorize(:red) - end - end end end diff --git a/src/spectator/formatting/summary.cr b/src/spectator/formatting/summary.cr index 0364755..85d0538 100644 --- a/src/spectator/formatting/summary.cr +++ b/src/spectator/formatting/summary.cr @@ -43,7 +43,12 @@ module Spectator::Formatting # Invoked after testing completes with summarized information from the test suite. # Called after `#dump_failures` and before `#dump_profile`. def dump_summary(notification) - io.puts Components::Stats.new(notification.report) + report = notification.report + io.puts Components::Stats.new(report) + + return if (failures = report.failures).empty? + + io.puts Components::FailureCommandList.new(failures) end # Invoked after testing completes with profiling information.