2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2015-07-01 17:50:14 -04:00
|
|
|
require 'rubygems/installer'
|
2013-12-07 20:22:39 -05:00
|
|
|
require 'rubygems/resolver'
|
|
|
|
|
|
|
|
class TestGemResolverLockSpecification < Gem::TestCase
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@LS = Gem::Resolver::LockSpecification
|
|
|
|
|
|
|
|
@source = Gem::Source.new @gem_repo
|
2014-09-13 23:30:02 -04:00
|
|
|
@set = Gem::Resolver::LockSet.new [@source]
|
2013-12-07 20:22:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_initialize
|
2016-02-01 07:43:26 -05:00
|
|
|
spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY
|
2013-12-07 20:22:39 -05:00
|
|
|
|
|
|
|
assert_equal 'a', spec.name
|
|
|
|
assert_equal v(2), spec.version
|
|
|
|
assert_equal Gem::Platform::RUBY, spec.platform
|
|
|
|
|
|
|
|
assert_equal @source, spec.source
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_dependency
|
2016-02-01 07:43:26 -05:00
|
|
|
l_spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY
|
2013-12-07 20:22:39 -05:00
|
|
|
|
|
|
|
b_dep = dep('b', '>= 0')
|
|
|
|
|
|
|
|
l_spec.add_dependency b_dep
|
|
|
|
|
|
|
|
assert_equal [b_dep], l_spec.dependencies
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_install
|
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
2013-12-07 20:22:39 -05:00
|
|
|
end
|
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY
|
2013-12-07 20:22:39 -05:00
|
|
|
|
|
|
|
called = false
|
|
|
|
|
|
|
|
spec.install({}) do |installer|
|
|
|
|
called = installer
|
|
|
|
end
|
|
|
|
|
|
|
|
refute_nil called
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_install_installed
|
2016-02-01 07:43:26 -05:00
|
|
|
spec = @LS.new @set, 'a', v(2), [@source], Gem::Platform::RUBY
|
2013-12-07 20:22:39 -05:00
|
|
|
|
|
|
|
FileUtils.touch File.join(@gemhome, 'specifications', spec.spec.spec_name)
|
|
|
|
|
|
|
|
called = false
|
|
|
|
|
|
|
|
spec.install({}) do |installer|
|
|
|
|
called = installer
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_nil called
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_spec
|
|
|
|
version = v(2)
|
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
l_spec = @LS.new @set, 'a', version, [@source], Gem::Platform::RUBY
|
2013-12-07 20:22:39 -05:00
|
|
|
|
|
|
|
b_dep = dep 'b', '>= 0'
|
|
|
|
c_dep = dep 'c', '~> 1'
|
|
|
|
|
|
|
|
l_spec.add_dependency b_dep
|
|
|
|
l_spec.add_dependency c_dep
|
|
|
|
|
|
|
|
spec = l_spec.spec
|
|
|
|
|
|
|
|
assert_equal 'a', spec.name
|
|
|
|
assert_equal version, spec.version
|
|
|
|
assert_equal Gem::Platform::RUBY, spec.platform
|
|
|
|
|
|
|
|
assert_equal [b_dep, c_dep], l_spec.spec.dependencies
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_spec_loaded
|
|
|
|
real_spec = util_spec 'a', 2
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs real_spec
|
2014-09-13 23:30:02 -04:00
|
|
|
real_spec.activate
|
|
|
|
|
|
|
|
version = v(2)
|
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
l_spec = @LS.new @set, 'a', version, [@source], Gem::Platform::RUBY
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
assert_same real_spec, l_spec.spec
|
|
|
|
end
|
2013-12-07 20:22:39 -05:00
|
|
|
end
|