Sha256: fded93a13790ad35da7b124241742e2acd72e0c782ec2b97407b4cf5790e6577

Contents?: true

Size: 1.81 KB

Versions: 22

Compression:

Stored size: 1.81 KB

Contents

require 'rubygems/test_case'
require 'rubygems/source_local'

require 'fileutils'

class TestGemSourceLocal < Gem::TestCase
  def setup
    super

    @sl = Gem::Source::Local.new

    @a, @a_gem = util_gem "a", '1'
    @ap, @ap_gem = util_gem "a", '2.a'
    @b, @b_gem = util_gem "b", '1'

    FileUtils.mv @a_gem, @tempdir
    FileUtils.mv @ap_gem, @tempdir
    FileUtils.mv @b_gem, @tempdir
  end

  def test_load_specs_released
    assert_equal [@a.name_tuple, @b.name_tuple].sort,
                 @sl.load_specs(:released).sort
  end

  def test_load_specs_prerelease
    assert_equal [@ap.name_tuple], @sl.load_specs(:prerelease)
  end

  def test_load_specs_latest
    a2, a2_gem = util_gem "a", "2"

    FileUtils.mv a2_gem, @tempdir

    assert_equal [a2.name_tuple, @b.name_tuple].sort,
                 @sl.load_specs(:latest).sort
  end

  def test_find_gem
    assert_equal "a-1", @sl.find_gem("a").full_name
  end

  def test_find_gem_highest_version
    _, a2_gem = util_gem "a", "2"
    FileUtils.mv a2_gem, @tempdir

    assert_equal "a-2", @sl.find_gem("a").full_name
  end

  def test_find_gem_specific_version
    _, a2_gem = util_gem "a", "2"
    FileUtils.mv a2_gem, @tempdir

    req = Gem::Requirement.create("= 1")

    assert_equal "a-1", @sl.find_gem("a", req).full_name
  end

  def test_find_gem_prerelease
    req = Gem::Requirement.create(">= 0")
    assert_equal "a-2.a", @sl.find_gem("a", req, true).full_name
  end

  def test_fetch_spec
    s = @sl.fetch_spec @a.name_tuple
    assert_equal s, @a
  end

  def test_download
    path = @sl.download @a

    assert_equal File.expand_path(@a.file_name), path
  end

  def test_compare
    uri = URI.parse "http://gems.example/foo"
    s = Gem::Source.new uri

    assert_equal(-1, (@sl <=> s))
    assert_equal 1, (s <=> @sl)
    assert_equal 0, (@sl <=> @sl)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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