Sha256: d11db806902ffbd30f6ef84025f82943034d9aef60f5e17269ef31ce3e720132

Contents?: true

Size: 1.7 KB

Versions: 26

Compression:

Stored size: 1.7 KB

Contents

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

  if defined?(File::ALT_SEPARATOR) and File::ALT_SEPARATOR
    def test_initialize_home_normalize
      alternate = @tempdir.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
      ps = Gem::PathSupport.new "GEM_HOME" => alternate

      assert_equal @tempdir, ps.home, "normalize values"
    end
  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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
rubygems-update-2.0.17 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.16 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.15 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.14 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.13 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.12 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.11 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.10 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.9 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.8 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.7 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.6 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.5 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.4 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.3 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.2 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.0 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.0.rc.2 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.0.rc.1 test/rubygems/test_gem_path_support.rb
rubygems-update-2.0.0.preview2.2 test/rubygems/test_gem_path_support.rb