From 3ba91bb3a62fc42a41a774ba8cd34c40b9a11321 Mon Sep 17 00:00:00 2001 From: "anastasia.gorokhova-alekseeva" Date: Tue, 16 Jan 2024 15:21:01 +0300 Subject: [PATCH] Print report green if no failures --- lib/fitting/log.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fitting/log.rb b/lib/fitting/log.rb index 6c84c4d..e17b8bd 100644 --- a/lib/fitting/log.rb +++ b/lib/fitting/log.rb @@ -96,10 +96,14 @@ def self.report(logs) Fitting::Log.failure(logs).each_with_index do |log, index| puts "\e[31m #{index + 1}) #{log.error.class} #{log.error.message}\n\n\e[0m" end - print "\e[31m#{logs.size} examples, #{Fitting::Log.failure(logs).size} failure, #{Fitting::Log.pending(logs).size} pending\e[0m\n" + + failure_count = Fitting::Log.failure(logs).size + color_code = failure_count > 0 ? 31 : 32 + print "\e[#{color_code}m#{logs.size} examples, #{failure_count} failure, #{Fitting::Log.pending(logs).size} pending\e[0m\n" + unless Fitting::Log.failure(logs).size <= 0 exit 1 end end end -end \ No newline at end of file +end