diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-10-24 15:52:37 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-10-24 15:53:53 +0200 |
commit | 148961adcd0704d964fce920330a6301b9704c25 (patch) | |
tree | 1f1f0cb7326775788683c77f0e2cceb495d3cc95 /spec/ruby/fixtures | |
parent | 342fbae83c2e80d1b49656bc7c689cc7fe8980ce (diff) | |
download | ruby-148961adcd0704d964fce920330a6301b9704c25.tar.gz |
Update to ruby/spec@4f59d86
Diffstat (limited to 'spec/ruby/fixtures')
-rw-r--r-- | spec/ruby/fixtures/code_loading.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/fixtures/code_loading.rb b/spec/ruby/fixtures/code_loading.rb index d6cf0edb47..decd56a358 100644 --- a/spec/ruby/fixtures/code_loading.rb +++ b/spec/ruby/fixtures/code_loading.rb @@ -12,7 +12,22 @@ module CodeLoadingSpecs end end + def self.preload_rubygems + # Require RubyGems eagerly, to ensure #require is already the RubyGems + # version and RubyGems is only loaded once, before starting #require/#autoload specs + # which snapshot $LOADED_FEATURES and could cause RubyGems to load twice. + # #require specs also snapshot #require, and could end up redefining #require as the original core Kernel#require. + @rubygems ||= begin + require "rubygems" + true + rescue LoadError + true + end + end + def self.spec_setup + preload_rubygems + @saved_loaded_features = $LOADED_FEATURES.clone @saved_load_path = $LOAD_PATH.clone ScratchPad.record [] |