[前][次][番号順一覧][スレッド一覧]

ruby-changes:57544

From: David <ko1@a...>
Date: Thu, 5 Sep 2019 19:02:54 +0900 (JST)
Subject: [ruby-changes:57544] f9f6a3d793 (master): [rubygems/rubygems] Little refactor to avoid rubocop's false positive

https://git.ruby-lang.org/ruby.git/commit/?id=f9f6a3d793

From f9f6a3d793186bd4b8897f775dcdcc9719361c11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 22 Aug 2019 17:32:47 +0200
Subject: [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.

https://github.com/rubygems/rubygems/commit/ae3fb47f5f

diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index b4f51cd..f666c6d 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -27,25 +27,21 @@ class TestGemCommandsPushCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L27
 
     @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 https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L400
     assert_equal '111111', @fetcher.last_request['OTP']
   end
 
+  private
+
+  def singleton_gem_class
+    class << Gem; self; end
+  end
+
 end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]