diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-12-20 11:50:32 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-12-20 11:50:32 +0900 |
commit | e672494cd737b8fea3a186aeb5c2c17d1a18cb96 (patch) | |
tree | 7c10a5af0630284fc69342e9598a3c0176e0b27c /lib/rubygems/test_case.rb | |
parent | fac60be324260cd834478fedf934e59b97935dbf (diff) |
Merge RubyGems 3.1.2
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r-- | lib/rubygems/test_case.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 5ecf2ab1d8..206497c651 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -164,6 +164,50 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni end end + ## + # Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the + # original value when the block ends + # + def bindir(value) + bindir = RbConfig::CONFIG['bindir'] + + 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' + end + end + + ## + # Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the + # original value when the block ends + # + def exeext(value) + exeext = RbConfig::CONFIG['EXEEXT'] + + if value + RbConfig::CONFIG['EXEEXT'] = value + else + RbConfig::CONFIG.delete 'EXEEXT' + end + + yield + ensure + if exeext + RbConfig::CONFIG['EXEEXT'] = exeext + else + RbConfig::CONFIG.delete 'EXEEXT' + end + end + # TODO: move to minitest def refute_path_exists(path, msg = nil) msg = message(msg) { "Expected path '#{path}' to not exist" } |