Skip to content
Prev Previous commit
Next Next commit
Use CodeLoading fixture to clean up require spec
The modified spec requires a file but does not clean up afterwards.
This prevents it from being run repeatedly, since n+1 runs will
fail to actually execute the required script. The CodeLoading
fixture is used in the require specs for this sort of cleanup.
  • Loading branch information
headius committed Aug 6, 2025
commit 7760ae422e7977bd4a1a37bbc33e513a8d33fc9e
19 changes: 15 additions & 4 deletions spec/ruby/language/rescue_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require_relative '../spec_helper'
require_relative 'fixtures/rescue'
require_relative '../fixtures/code_loading'

class SpecificExampleException < StandardError
end
Expand Down Expand Up @@ -134,12 +135,22 @@ class << Object.new
ScratchPad.recorded.should == ["message"]
end

it 'captures successfully at the top-level' do
ScratchPad.record []
describe "at the top-level" do
before :each do
CodeLoadingSpecs.spec_setup
end

require_relative 'fixtures/rescue/top_level'
after :each do
CodeLoadingSpecs.spec_cleanup
end

ScratchPad.recorded.should == ["message"]
it 'captures successfully at the top-level' do
ScratchPad.record []

require_relative 'fixtures/rescue/top_level'

ScratchPad.recorded.should == ["message"]
end
end
end

Expand Down