summaryrefslogtreecommitdiff
path: root/test/rubygems
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-08-04 14:16:42 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-05 18:45:18 +0900
commit2ea2108a9fb1460342226f54cbf54ddd79ea1cc2 (patch)
treea2514b5a1a62e42a6ada062ea43167bbfee1e242 /test/rubygems
parentf9dac1bd54af384e99fecf949cad9df9ceb09f0d (diff)
[rubygems/rubygems] Fix error handling of #with_engine_version
* If settings constants fail, show that exception instead of getting another one due to variables being unset and hiding the real cause. https://github.com/rubygems/rubygems/commit/f38cd67874
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index 24cfb67c4d..959c28580f 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -34,21 +34,22 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
- yield
+ begin
+ yield
+ ensure
+ Object.send :remove_const, :RUBY_ENGINE if name
+ Object.send :remove_const, new_engine_version_const if version
- ensure
- Object.send :remove_const, :RUBY_ENGINE if name
- Object.send :remove_const, new_engine_version_const if version
+ Object.send :remove_const, engine_version_const if name == 'ruby' and
+ Object.const_defined? engine_version_const
- Object.send :remove_const, engine_version_const if name == 'ruby' and
- Object.const_defined? engine_version_const
+ Object.const_set :RUBY_ENGINE, engine if engine
+ Object.const_set engine_version_const, engine_version unless
+ Object.const_defined? engine_version_const
- Object.const_set :RUBY_ENGINE, engine if engine
- Object.const_set engine_version_const, engine_version unless
- Object.const_defined? engine_version_const
-
- Gem.send :remove_instance_variable, :@ruby_version if
- Gem.instance_variables.include? :@ruby_version
+ Gem.send :remove_instance_variable, :@ruby_version if
+ Gem.instance_variables.include? :@ruby_version
+ end
end
def test_gempspec_with_multiple_runtime_deps