Sha256: 5a3bf0582333303105c22640dd2e975f5574a873b7e77fa0dd19e129f4e0bd61

Contents?: true

Size: 1.94 KB

Versions: 36

Compression:

Stored size: 1.94 KB

Contents

require 'rubygems/test_case'
require 'rubygems/available_set'
require 'rubygems/security'

class TestGemAvailableSet < Gem::TestCase
  def setup
    super

    @source = Gem::Source.new(@gem_repo)
  end

  def test_add_and_empty
    a1, _ = util_gem 'a', '1'

    set = Gem::AvailableSet.new
    assert set.empty?

    set.add a1, @source

    refute set.empty?

    assert_equal [a1], set.all_specs
  end

  def test_match_platform
    a1, _ = util_gem 'a', '1' do |g|
      g.platform = "something-weird-yep"
    end

    a1c, _ = util_gem 'a', '2' do |g|
      g.platform = Gem::Platform.local
    end

    a2, _ = util_gem 'a', '2'

    set = Gem::AvailableSet.new
    set.add a1, @source
    set.add a1c, @source
    set.add a2, @source

    set.match_platform!

    assert_equal [a1c, a2], set.all_specs
  end

  def test_best
    a1, _ = util_gem 'a', '1'
    a2, _  = util_gem 'a', '2'

    set = Gem::AvailableSet.new
    set.add a1, @source
    set.add a2, @source

    set.pick_best!

    assert_equal [a2], set.all_specs
  end

  def test_remove_installed_bang
    a1, _ = util_gem 'a', '1'

    a1.activate

    set = Gem::AvailableSet.new
    set.add a1, @source

    dep = Gem::Dependency.new "a", ">= 0"

    set.remove_installed! dep

    assert set.empty?
  end

  def test_sorted_normal_versions
    a1, _ = util_gem 'a', '1'
    a2, _  = util_gem 'a', '2'

    set = Gem::AvailableSet.new
    set.add a1, @source
    set.add a2, @source

    g = set.sorted

    assert_equal a2, g[0].spec
    assert_equal a1, g[1].spec
  end

  def test_sorted_respect_pre
    a1a, _ = util_gem 'a', '1.a'
    a1,  _ = util_gem 'a', '1'
    a2a, _ = util_gem 'a', '2.a'
    a2,  _ = util_gem 'a', '2'
    a3a, _ = util_gem 'a', '3.a'

    set = Gem::AvailableSet.new
    set.add a1, @source
    set.add a1a, @source
    set.add a3a, @source
    set.add a2a, @source
    set.add a2, @source

    g = set.sorted.map { |t| t.spec }

    assert_equal [a3a, a2, a2a, a1, a1a], g
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
rubygems-update-2.0.17 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.16 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.15 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.11 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.14 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.10 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.13 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.12 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.9 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.8 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.7 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.11 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.6 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.10 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.5 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.4 test/rubygems/test_gem_available_set.rb
rubygems-update-2.0.9 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.3 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.2 test/rubygems/test_gem_available_set.rb
rubygems-update-2.1.1 test/rubygems/test_gem_available_set.rb