[rubygems/rubygems] Little refactor to avoid rubocop's false positive

Otherwise it detects duplicate methods here, because it doesn't see that
we are reopening the class in two different places.

ae3fb47f5f
This commit is contained in:
David Rodríguez 2019-08-22 17:32:47 +02:00 committed by Hiroshi SHIBATA
parent d84b9b6d0a
commit f9f6a3d793

View file

@ -27,25 +27,21 @@ class TestGemCommandsPushCommand < Gem::TestCase
@cmd = Gem::Commands::PushCommand.new
class << Gem
singleton_gem_class.class_eval do
alias_method :orig_latest_rubygems_version, :latest_rubygems_version
def latest_rubygems_version
Gem.rubygems_version
end
end
end
def teardown
super
class << Gem
singleton_gem_class.class_eval do
remove_method :latest_rubygems_version
alias_method :latest_rubygems_version, :orig_latest_rubygems_version
end
end
@ -404,4 +400,10 @@ class TestGemCommandsPushCommand < Gem::TestCase
assert_equal '111111', @fetcher.last_request['OTP']
end
private
def singleton_gem_class
class << Gem; self; end
end
end