summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_path_support.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
commitd22130922e7842226d38d59680e4bbb48a28a5f0 (patch)
tree39594d3a14641dd5488a99a5e633239296fa5742 /test/rubygems/test_gem_path_support.rb
parent4752539e3f3e563d559732c52424206bd6f12dbd (diff)
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_path_support.rb')
-rw-r--r--test/rubygems/test_gem_path_support.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_path_support.rb b/test/rubygems/test_gem_path_support.rb
new file mode 100644
index 0000000000..7fb0ccacc5
--- /dev/null
+++ b/test/rubygems/test_gem_path_support.rb
@@ -0,0 +1,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