Skip to content

Commit

Permalink
Output errors outside of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyazub committed Jun 3, 2024
1 parent 99a0e04 commit 03a879f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/turbo_tests/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ def message(message)
@messages << message
end

def error_outside_of_examples
def error_outside_of_examples(message = nil)
@errors_outside_of_examples_count += 1
message message if message
end

def finish
Expand Down
10 changes: 8 additions & 2 deletions lib/turbo_tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,17 @@ def handle_messages
break
end
when "message"
@reporter.message(message[:message])
if message[:message].end_with?("occurred outside of examples")
@reporter.message(message[:message])
else
@reporter.error_outside_of_examples(message[:message])
@error = true
end
when "seed"
when "close"
# Do nothing
when "error"
@reporter.error_outside_of_examples
@reporter.error_outside_of_examples(message[:message])
@error = true
when "exit"
exited += 1
Expand Down
4 changes: 2 additions & 2 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 03a879f

Please sign in to comment.