Skip to content

Commit

Permalink
Add Spec::Formatter#should_print_summary? (#14397)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Mar 26, 2024
1 parent c52b041 commit 723f829
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/spec/context.cr
Expand Up @@ -178,10 +178,12 @@ module Spec

def finish(elapsed_time, aborted = false)
Spec.cli.formatters.each(&.finish(elapsed_time, aborted))
Spec.cli.formatters.each(&.print_results(elapsed_time, aborted))
if Spec.cli.formatters.any?(&.should_print_summary?)
print_summary(elapsed_time, aborted)
end
end

def print_results(elapsed_time, aborted = false)
def print_summary(elapsed_time, aborted = false)
pendings = results_for(:pending)
unless pendings.empty?
puts
Expand Down
11 changes: 6 additions & 5 deletions src/spec/formatter.cr
Expand Up @@ -19,7 +19,8 @@ module Spec
def finish(elapsed_time, aborted)
end

def print_results(elapsed_time : Time::Span, aborted : Bool)
def should_print_summary?
false
end
end

Expand Down Expand Up @@ -54,8 +55,8 @@ module Spec
@io.puts
end

def print_results(elapsed_time : Time::Span, aborted : Bool)
Spec.cli.root_context.print_results(elapsed_time, aborted)
def should_print_summary?
true
end
end

Expand Down Expand Up @@ -110,8 +111,8 @@ module Spec
@io.puts Spec.color(@last_description, result.kind)
end

def print_results(elapsed_time : Time::Span, aborted : Bool)
Spec.cli.root_context.print_results(elapsed_time, aborted)
def should_print_summary?
true
end
end

Expand Down

0 comments on commit 723f829

Please sign in to comment.