From 58af4c0a1fdf15e1624867938d5a9ce6be8403e3 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 29 Apr 2020 06:50:02 +0900 Subject: [rubygems/rubygems] Split credential helper as credential_setup and use it https://github.com/rubygems/rubygems/commit/b0c55c76ca --- lib/rubygems/test_case.rb | 11 +++++++---- test/rubygems/test_gem_commands_owner_command.rb | 2 ++ test/rubygems/test_gem_commands_push_command.rb | 3 +++ test/rubygems/test_gem_commands_signin_command.rb | 2 ++ test/rubygems/test_gem_config_file.rb | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 2bf4fb05e4..0609519efa 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -359,10 +359,6 @@ class Gem::TestCase < Minitest::Test ENV['HOME'] = @userhome FileUtils.mkdir_p File.join(@userhome, ".gem") File.write File.join(@userhome, ".gemrc"), "--- {}" - temp_cred = File.join(@userhome, '.gem', 'credentials') - FileUtils.mkdir_p File.dirname(temp_cred) - File.write temp_cred, ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' - File.chmod 0600, temp_cred Gem.instance_variable_set :@user_home, nil Gem.instance_variable_set :@cache_home, nil @@ -479,6 +475,13 @@ class Gem::TestCase < Minitest::Test @back_ui.close end + def credential_setup + @temp_cred = File.join(@userhome, '.gem', 'credentials') + FileUtils.mkdir_p File.dirname(@temp_cred) + File.write @temp_cred, ':rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97' + File.chmod 0600, @temp_cred + end + def common_installer_setup common_installer_teardown diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb index 35424629fe..685365ed3b 100644 --- a/test/rubygems/test_gem_commands_owner_command.rb +++ b/test/rubygems/test_gem_commands_owner_command.rb @@ -7,6 +7,8 @@ class TestGemCommandsOwnerCommand < Gem::TestCase def setup super + credential_setup + ENV["RUBYGEMS_HOST"] = nil @stub_ui = Gem::MockGemUi.new @stub_fetcher = Gem::FakeFetcher.new diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index ddb287388d..877621d489 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -6,6 +6,9 @@ class TestGemCommandsPushCommand < Gem::TestCase def setup super + + credential_setup + ENV["RUBYGEMS_HOST"] = nil Gem.host = Gem::DEFAULT_HOST Gem.configuration.disable_default_gem_server = false diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index fee67fe438..8991f65302 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -8,6 +8,8 @@ class TestGemCommandsSigninCommand < Gem::TestCase def setup super + credential_setup + Gem.configuration.rubygems_api_key = nil Gem.configuration.api_keys.clear diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index d31d55eba1..36725f9390 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -7,6 +7,8 @@ class TestGemConfigFile < Gem::TestCase def setup super + credential_setup + @temp_conf = File.join @tempdir, '.gemrc' @cfg_args = %W[--config-file #{@temp_conf}] -- cgit v1.2.3