Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug when an exception occurs in a before all block #90

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/rspec/abq/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ def run_with_abq(reporter)
# be sent to us from ABQ, we now loop over all the examples, and mark
# every one that we must run in this group as a failure.
for_filtered_examples(reporter) do |example|
next unless Abq.target_test_case.is_example?(example)

example.fail_with_exception(abq_reporter, ex)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were two issues here:

  • abq_reporter was undefined
  • we were looping over all of the examples but only marking the one currently assigned to the worker as failed. This causes a problem if the worker pulls another spec in the example group, but we've already moved past that in iterating over the tests

if Abq.target_test_case.is_example?(example)
example.fail_with_exception(reporter, ex)
Abq.fetch_next_example
end
end

false
Expand Down
16 changes: 16 additions & 0 deletions spec/fixture_specs/raising_specs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@
it 'has a raising test' do
raise 'the roof'
end

context "it can handle an exception in a before all hook" do
before(:all) do
raise "raising from before(:all)"
end

it "should fail" do
# should fail without running because of the exception in the before(:all)
exit 9999
end

it "should also fail" do
# should fail without running because of the exception in the before(:all)
exit 9999
end
end
end