summaryrefslogtreecommitdiff
path: root/lib/rubygems/test_case.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r--lib/rubygems/test_case.rb40
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 206497c651..89403206f9 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -96,6 +96,8 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
TEST_PATH = ENV.fetch('RUBYGEMS_TEST_PATH', File.expand_path('../../../test/rubygems', __FILE__))
+ SPECIFICATIONS = File.expand_path(File.join(TEST_PATH, "specifications"), __FILE__)
+
def assert_activate(expected, *specs)
specs.each do |spec|
case spec
@@ -169,20 +171,24 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
# original value when the block ends
#
def bindir(value)
- bindir = RbConfig::CONFIG['bindir']
+ with_clean_path_to_ruby do
+ bindir = RbConfig::CONFIG['bindir']
- if value
- RbConfig::CONFIG['bindir'] = value
- else
- RbConfig::CONFIG.delete 'bindir'
- end
+ if value
+ RbConfig::CONFIG['bindir'] = value
+ else
+ RbConfig::CONFIG.delete 'bindir'
+ end
- yield
- ensure
- if bindir
- RbConfig::CONFIG['bindir'] = bindir
- else
- RbConfig::CONFIG.delete 'bindir'
+ begin
+ yield
+ ensure
+ if bindir
+ RbConfig::CONFIG['bindir'] = bindir
+ else
+ RbConfig::CONFIG.delete 'bindir'
+ end
+ end
end
end
@@ -1247,6 +1253,16 @@ Also, a list:
end
end
+ def with_clean_path_to_ruby
+ orig_ruby = Gem.ruby
+
+ Gem.instance_variable_set :@ruby, nil
+
+ yield
+ ensure
+ Gem.instance_variable_set :@ruby, orig_ruby
+ end
+
class << self
# :nodoc: