From 84f2487353bc22bbabc0163a1fcad45bc6d22984 Mon Sep 17 00:00:00 2001 From: ilyazub Date: Mon, 3 Jun 2024 21:25:07 +0200 Subject: [PATCH] Output errors outside of examples --- lib/turbo_tests/reporter.rb | 3 ++- lib/turbo_tests/runner.rb | 11 ++++++++--- spec/cli_spec.rb | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/turbo_tests/reporter.rb b/lib/turbo_tests/reporter.rb index 9f281d7..417f06a 100644 --- a/lib/turbo_tests/reporter.rb +++ b/lib/turbo_tests/reporter.rb @@ -117,8 +117,9 @@ def message(message) @messages << message end - def error_outside_of_examples + def error_outside_of_examples(error_message) @errors_outside_of_examples_count += 1 + message error_message end def finish diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index 430f79a..9db297d 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -259,12 +259,17 @@ def handle_messages break end when "message" - @reporter.message(message[:message]) + if message[:message].include?("An error occurred") || message[:message].include?("occurred outside of examples") + @reporter.error_outside_of_examples(message[:message]) + @error = true + else + @reporter.message(message[:message]) + end when "seed" when "close" when "error" - @reporter.error_outside_of_examples - @error = true + # Do nothing + nil when "exit" exited += 1 if exited == @num_processes diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 9594056..443c6bf 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -27,7 +27,7 @@ } let(:expected_end_of_output) do - "0 examples, 0 failures\n"\ + "0 examples, 0 failures, 1 error occurred outside of examples\n"\ "\n"\ "Randomized with seed #{seed}" end @@ -81,7 +81,7 @@ } let(:expected_end_of_output) do - "0 examples, 0 failures" + "0 examples, 0 failures, 1 error occurred outside of examples" end let(:fixture) { "./fixtures/rspec/errors_outside_of_examples_spec.rb" }