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

Add spec for after hook following before(:all) #2652

Closed
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
28 changes: 28 additions & 0 deletions spec/rspec/core/hooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,34 @@ def hook_collection_for(position, scope)
end
end

describe "#before(:all)" do
it "stops running subsequent after hook when an error is encountered" do
Copy link
Member

Choose a reason for hiding this comment

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

I'd put this next to it "runs subsequent hooks of the same type when an error is encountered so all cleanup can complete" do.

sequence = []

RSpec.configure do |c|
c.output_stream = StringIO.new

c.before(:all) do
sequence << :hook_1
raise "boom"
end

c.after do
sequence << :hook_2
raise "boom"
end
end

RSpec.configuration.with_suite_hooks do
RSpec.describe do
example { sequence << :example }
end.run
end

expect(sequence).to eq [:hook_1]
end
end

describe "#around" do
context "when it does not run the example" do
context "for a hook declared in the group" do
Expand Down