2013-10-17 21:57:00 -04:00
|
|
|
require 'rubygems/test_case'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverVendorSet < Gem::TestCase
|
2013-10-17 21:57:00 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
@set = Gem::Resolver::VendorSet.new
|
2013-10-17 21:57:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_vendor_gem
|
|
|
|
name, version, directory = vendor_gem
|
|
|
|
|
|
|
|
@set.add_vendor_gem name, directory
|
|
|
|
|
|
|
|
spec = @set.load_spec name, version, Gem::Platform::RUBY, nil
|
|
|
|
|
|
|
|
assert_equal "#{name}-#{version}", spec.full_name
|
2013-11-25 14:14:49 -05:00
|
|
|
|
|
|
|
assert_equal File.expand_path(directory), spec.full_gem_path
|
2013-10-17 21:57:00 -04:00
|
|
|
end
|
|
|
|
|
2013-10-19 20:31:12 -04:00
|
|
|
def test_add_vendor_gem_missing
|
2013-11-10 12:51:40 -05:00
|
|
|
name, _, directory = vendor_gem
|
2013-10-19 20:31:12 -04:00
|
|
|
|
|
|
|
FileUtils.rm_r directory
|
|
|
|
|
|
|
|
e = assert_raises Gem::GemNotFoundException do
|
|
|
|
@set.add_vendor_gem name, directory
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal "unable to find #{directory}/#{name}.gemspec for gem #{name}",
|
|
|
|
e.message
|
|
|
|
end
|
|
|
|
|
2013-10-17 21:57:00 -04:00
|
|
|
def test_find_all
|
|
|
|
name, version, directory = vendor_gem
|
|
|
|
|
|
|
|
@set.add_vendor_gem name, directory
|
|
|
|
|
|
|
|
dependency = dep 'a', '~> 1'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
req = Gem::Resolver::DependencyRequest.new dependency, nil
|
2013-10-17 21:57:00 -04:00
|
|
|
|
|
|
|
found = @set.find_all req
|
|
|
|
|
|
|
|
spec = @set.load_spec name, version, Gem::Platform::RUBY, nil
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
source = Gem::Source::Vendor.new directory
|
|
|
|
|
2013-10-17 21:57:00 -04:00
|
|
|
expected = [
|
2013-11-18 19:34:13 -05:00
|
|
|
Gem::Resolver::VendorSpecification.new(@set, spec, source)
|
2013-10-17 21:57:00 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
assert_equal expected, found
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_load_spec
|
2013-11-10 12:51:40 -05:00
|
|
|
error = Object.const_defined?(:KeyError) ? KeyError : IndexError
|
|
|
|
|
|
|
|
assert_raises error do
|
2013-12-08 14:32:07 -05:00
|
|
|
@set.load_spec 'b', v(1), Gem::Platform::RUBY, nil
|
2013-10-17 21:57:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|