1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Make @@project_dir constants per files

https://github.com/rubygems/rubygems/commit/955174658f
This commit is contained in:
Nobuyoshi Nakada 2019-07-24 13:57:59 +09:00 committed by Hiroshi SHIBATA
parent 99680f81e8
commit 99fb637c41
2 changed files with 14 additions and 14 deletions

View file

@ -17,7 +17,7 @@ class TestGem < Gem::TestCase
PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
@@project_dir = File.expand_path('../../..', __FILE__).untaint
PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint
def setup
super
@ -632,7 +632,7 @@ class TestGem < Gem::TestCase
end
def test_self_find_files
cwd = File.expand_path("test/rubygems", @@project_dir)
cwd = File.expand_path("test/rubygems", PROJECT_DIR)
$LOAD_PATH.unshift cwd
discover_path = File.join 'lib', 'sff', 'discover.rb'
@ -652,7 +652,7 @@ class TestGem < Gem::TestCase
Gem.refresh
expected = [
File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
File.join(foo2.full_gem_path, discover_path),
File.join(foo1.full_gem_path, discover_path),
]
@ -664,7 +664,7 @@ class TestGem < Gem::TestCase
end
def test_self_find_files_with_gemfile
cwd = File.expand_path("test/rubygems", @@project_dir)
cwd = File.expand_path("test/rubygems", PROJECT_DIR)
actual_load_path = $LOAD_PATH.unshift(cwd).dup
discover_path = File.join 'lib', 'sff', 'discover.rb'
@ -689,7 +689,7 @@ class TestGem < Gem::TestCase
Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile')
expected = [
File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
File.join(foo1.full_gem_path, discover_path)
].sort
@ -700,7 +700,7 @@ class TestGem < Gem::TestCase
end
def test_self_find_latest_files
cwd = File.expand_path("test/rubygems", @@project_dir)
cwd = File.expand_path("test/rubygems", PROJECT_DIR)
$LOAD_PATH.unshift cwd
discover_path = File.join 'lib', 'sff', 'discover.rb'
@ -720,7 +720,7 @@ class TestGem < Gem::TestCase
Gem.refresh
expected = [
File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
File.join(foo2.full_gem_path, discover_path),
]
@ -872,12 +872,12 @@ class TestGem < Gem::TestCase
end
def test_self_prefix
assert_equal @@project_dir, Gem.prefix
assert_equal PROJECT_DIR, Gem.prefix
end
def test_self_prefix_libdir
orig_libdir = RbConfig::CONFIG['libdir']
RbConfig::CONFIG['libdir'] = @@project_dir
RbConfig::CONFIG['libdir'] = PROJECT_DIR
assert_nil Gem.prefix
ensure
@ -886,7 +886,7 @@ class TestGem < Gem::TestCase
def test_self_prefix_sitelibdir
orig_sitelibdir = RbConfig::CONFIG['sitelibdir']
RbConfig::CONFIG['sitelibdir'] = @@project_dir
RbConfig::CONFIG['sitelibdir'] = PROJECT_DIR
assert_nil Gem.prefix
ensure
@ -1867,7 +1867,7 @@ You may need to `gem install -g` to install missing gems
def with_plugin(path)
test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
@@project_dir)
PROJECT_DIR)
# A single test plugin should get loaded once only, in order to preserve
# sane test semantics.

View file

@ -4,7 +4,7 @@ require 'rubygems/command_manager'
class TestGemCommandManager < Gem::TestCase
@@project_dir = File.expand_path('../../..', __FILE__).untaint
PROJECT_DIR = File.expand_path('../../..', __FILE__).untaint
def setup
super
@ -60,7 +60,7 @@ class TestGemCommandManager < Gem::TestCase
def test_run_interrupt
old_load_path = $:.dup
$: << File.expand_path("test/rubygems", @@project_dir)
$: << File.expand_path("test/rubygems", PROJECT_DIR)
Gem.load_env_plugins
@command_manager.register_command :interrupt
@ -79,7 +79,7 @@ class TestGemCommandManager < Gem::TestCase
def test_run_crash_command
old_load_path = $:.dup
$: << File.expand_path("test/rubygems", @@project_dir)
$: << File.expand_path("test/rubygems", PROJECT_DIR)
@command_manager.register_command :crash
use_ui @ui do