Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 21f2e91

Browse files
committed
Fix issue causing our spec suite to run much slower.
Before this change: $ bin/rspec | egrep 'Finished|(examples.*failure)' Finished in 45.99 seconds (files took 0.89765 seconds to load) 2014 examples, 4 failures, 1 pending After this change: $ bin/rspec | egrep 'Finished|(examples.*failure)' Finished in 11.16 seconds (files took 1.16 seconds to load) 2014 examples, 4 failures, 1 pending I believe the issue was requiring 'rspec/rails/version'. Since rspec-rails is not available, rubygems would exhaustively search all my installed gems before raising `LoadError`. I have ~300 gems installed and this was quite slow. It's better to just force it to raise `LoadError` and not wait on RubyGems to do the same thing.
1 parent 910eb7f commit 21f2e91

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spec/rspec/core/invocations_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ def run_invocation
131131
end
132132

133133
describe Invocations::PrintVersion do
134+
before do
135+
allow(subject).to receive(:require).and_call_original
136+
allow(subject).to receive(:require).with("rspec/rails/version").and_raise(LoadError)
137+
end
138+
134139
it "prints the major.minor version of RSpec as a whole" do
135140
stub_const("RSpec::Core::Version::STRING", "9.18.23")
136141
run_invocation
@@ -162,8 +167,6 @@ def run_invocation
162167
end
163168

164169
it "indicates a part is not installed if it cannot be loaded" do
165-
expect { require 'rspec/rails/version' }.to raise_error(LoadError)
166-
167170
run_invocation
168171

169172
expect(out.string).not_to include("rspec-rails")

0 commit comments

Comments
 (0)