2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-09-09 20:52:14 -04:00
|
|
|
require 'rubygems/test_case'
|
2013-10-15 20:14:16 -04:00
|
|
|
require 'rubygems/available_set'
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverIndexSpecification < Gem::TestCase
|
2013-09-09 20:52:14 -04:00
|
|
|
|
|
|
|
def test_initialize
|
2013-11-18 19:34:13 -05:00
|
|
|
set = Gem::Resolver::IndexSet.new
|
2013-09-09 20:52:14 -04:00
|
|
|
source = Gem::Source.new @gem_repo
|
|
|
|
version = Gem::Version.new '3.0.3'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
spec = Gem::Resolver::IndexSpecification.new(
|
2013-09-09 20:52:14 -04:00
|
|
|
set, 'rails', version, source, Gem::Platform::RUBY)
|
|
|
|
|
|
|
|
assert_equal 'rails', spec.name
|
|
|
|
assert_equal version, spec.version
|
|
|
|
assert_equal Gem::Platform::RUBY, spec.platform
|
|
|
|
|
|
|
|
assert_equal source, spec.source
|
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
def test_initialize_platform
|
2013-11-18 19:34:13 -05:00
|
|
|
set = Gem::Resolver::IndexSet.new
|
2013-10-15 20:14:16 -04:00
|
|
|
source = Gem::Source::Local.new
|
|
|
|
version = Gem::Version.new '3.0.3'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
spec = Gem::Resolver::IndexSpecification.new(
|
2013-10-15 20:14:16 -04:00
|
|
|
set, 'rails', version, source, Gem::Platform.local)
|
|
|
|
|
|
|
|
assert_equal Gem::Platform.local.to_s, spec.platform
|
|
|
|
end
|
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
def test_install
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
set = Gem::Resolver::IndexSet.new
|
|
|
|
source = Gem::Source.new @gem_repo
|
|
|
|
|
|
|
|
spec = Gem::Resolver::IndexSpecification.new(
|
|
|
|
set, 'a', v(2), source, Gem::Platform::RUBY)
|
|
|
|
|
|
|
|
called = false
|
|
|
|
|
|
|
|
spec.install({}) do |installer|
|
|
|
|
called = installer
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_path_exists File.join @gemhome, 'specifications', 'a-2.gemspec'
|
|
|
|
|
|
|
|
assert_kind_of Gem::Installer, called
|
|
|
|
end
|
|
|
|
|
2013-09-09 20:52:14 -04:00
|
|
|
def test_spec
|
2013-11-11 19:16:41 -05:00
|
|
|
specs = spec_fetcher do |fetcher|
|
2013-11-10 12:51:40 -05:00
|
|
|
fetcher.spec 'a', 2
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|
2013-09-09 20:52:14 -04:00
|
|
|
|
|
|
|
source = Gem::Source.new @gem_repo
|
|
|
|
version = v 2
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
set = Gem::Resolver::IndexSet.new
|
|
|
|
i_spec = Gem::Resolver::IndexSpecification.new \
|
2013-09-09 20:52:14 -04:00
|
|
|
set, 'a', version, source, Gem::Platform.local
|
|
|
|
|
|
|
|
spec = i_spec.spec
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
|
2013-09-09 20:52:14 -04:00
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
def test_spec_local
|
2013-11-11 19:16:41 -05:00
|
|
|
a_2_p = util_spec 'a', 2 do |s| s.platform = Gem::Platform.local end
|
2013-10-15 20:14:16 -04:00
|
|
|
Gem::Package.build a_2_p
|
|
|
|
|
|
|
|
source = Gem::Source::Local.new
|
2013-11-18 19:34:13 -05:00
|
|
|
set = Gem::Resolver::InstallerSet.new :local
|
2013-10-15 20:14:16 -04:00
|
|
|
set.always_install << a_2_p
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
i_spec = Gem::Resolver::IndexSpecification.new \
|
2013-10-15 20:14:16 -04:00
|
|
|
set, 'a', v(2), source, Gem::Platform.local
|
|
|
|
|
|
|
|
spec = i_spec.spec
|
|
|
|
|
|
|
|
assert_equal a_2_p.full_name, spec.full_name
|
|
|
|
end
|
2013-09-09 20:52:14 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
|