1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
######################################################################
# This file is imported from the rubygems project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require 'rubygems/test_case'
require 'rubygems'
require 'fileutils'
class TestGemPathSupport < Gem::TestCase
def setup
super
ENV["GEM_HOME"] = @tempdir
ENV["GEM_PATH"] = [@tempdir, "something"].join(File::PATH_SEPARATOR)
end
def test_initialize
ps = Gem::PathSupport.new
assert_equal ENV["GEM_HOME"], ps.home
expected = util_path
assert_equal expected, ps.path, "defaults to GEM_PATH"
end
def test_initialize_home
ps = Gem::PathSupport.new "GEM_HOME" => "#{@tempdir}/foo"
assert_equal File.join(@tempdir, "foo"), ps.home
expected = util_path + [File.join(@tempdir, 'foo')]
assert_equal expected, ps.path
end
def test_initialize_path
ps = Gem::PathSupport.new "GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar]
assert_equal ENV["GEM_HOME"], ps.home
expected = [
File.join(@tempdir, 'foo'),
File.join(@tempdir, 'bar'),
ENV["GEM_HOME"],
]
assert_equal expected, ps.path
end
def test_initialize_home_path
ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
"GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar])
assert_equal File.join(@tempdir, "foo"), ps.home
expected = [File.join(@tempdir, 'foo'), File.join(@tempdir, 'bar')]
assert_equal expected, ps.path
end
def util_path
ENV["GEM_PATH"].split(File::PATH_SEPARATOR)
end
end
|