1
require 'rubygems/test_case'
5
class TestGemPathSupport < Gem::TestCase
9
ENV["GEM_HOME"] = @tempdir
10
ENV["GEM_PATH"] = [@tempdir, "something"].join(File::PATH_SEPARATOR)
14
ps = Gem::PathSupport.new
16
assert_equal ENV["GEM_HOME"], ps.home
19
assert_equal expected, ps.path, "defaults to GEM_PATH"
22
def test_initialize_home
23
ps = Gem::PathSupport.new "GEM_HOME" => "#{@tempdir}/foo"
25
expected = File.join(@tempdir, "foo")
26
assert_equal expected, ps.home
28
assert_equal [expected, *util_path], ps.path
31
if defined?(File::ALT_SEPARATOR) and File::ALT_SEPARATOR
32
def test_initialize_home_normalize
33
alternate = @tempdir.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
34
ps = Gem::PathSupport.new "GEM_HOME" => alternate
36
assert_equal @tempdir, ps.home, "normalize values"
40
def test_initialize_path
41
ps = Gem::PathSupport.new "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar]
43
assert_equal ENV["GEM_HOME"], ps.home
47
File.join(@tempdir, 'foo'),
48
File.join(@tempdir, 'bar'),
51
assert_equal expected, ps.path
54
def test_initialize_home_path
55
ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
56
"GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar])
58
assert_equal File.join(@tempdir, "foo"), ps.home
60
expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
61
assert_equal expected, ps.path
65
ps = Gem::PathSupport.new
67
ps.send :path=, ['a', 'b']
69
assert_equal [@tempdir, 'a', 'b'], ps.path
72
def test_path_equals_empty
73
ps = Gem::PathSupport.new
77
assert_equal [@tempdir, 'something'], ps.path
80
def test_path_equals_empty_no_GEM_PATH
83
ps = Gem::PathSupport.new
87
assert_equal [@tempdir, *Gem.default_path], ps.path
91
ENV["GEM_PATH"].split(File::PATH_SEPARATOR)