aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_request_set.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-10 17:51:40 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-10 17:51:40 +0000
commit4f6779bac7b4e294bc473782d60cbd071f0d0f8d (patch)
treed37b54da20f8c0adf2d98e810aacc8259b0602ff /test/rubygems/test_gem_request_set.rb
parent31d355aaa9436e2b24efd5e6501cabd876267c46 (diff)
downloadruby-4f6779bac7b4e294bc473782d60cbd071f0d0f8d.tar.gz
* lib/rubygems: Update to RubyGems master 4bdc4f2. Important changes
in this commit: RubyGems now chooses the test server port reliably. Patch by akr. Partial implementation of bundler's Gemfile format. Refactorings to improve the new resolver. Fixes bugs in the resolver. * test/rubygems: Tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_request_set.rb')
-rw-r--r--test/rubygems/test_gem_request_set.rb73
1 files changed, 66 insertions, 7 deletions
diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
index 12a1942d54..4aaa15ac68 100644
--- a/test/rubygems/test_gem_request_set.rb
+++ b/test/rubygems/test_gem_request_set.rb
@@ -6,6 +6,8 @@ class TestGemRequestSet < Gem::TestCase
super
Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
+
+ @DR = Gem::DependencyResolver
end
def test_gem
@@ -17,6 +19,15 @@ class TestGemRequestSet < Gem::TestCase
assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies
end
+ def test_gem_duplicate
+ rs = Gem::RequestSet.new
+
+ rs.gem 'a', '1'
+ rs.gem 'a', '2'
+
+ assert_equal [dep('a', '= 1', '= 2')], rs.dependencies
+ end
+
def test_import
rs = Gem::RequestSet.new
rs.gem 'a'
@@ -26,6 +37,26 @@ class TestGemRequestSet < Gem::TestCase
assert_equal [dep('a'), dep('b')], rs.dependencies
end
+ def test_install_from_gemdeps
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ end
+
+ rs = Gem::RequestSet.new
+ installed = []
+
+ Tempfile.open 'gem.deps.rb' do |io|
+ io.puts 'gem "a"'
+ io.flush
+
+ rs.install_from_gemdeps :gemdeps => io.path do |req, installer|
+ installed << req.full_name
+ end
+ end
+
+ assert_includes installed, 'a-2'
+ end
+
def test_load_gemdeps
rs = Gem::RequestSet.new
@@ -41,6 +72,19 @@ class TestGemRequestSet < Gem::TestCase
assert rs.vendor_set
end
+ def test_load_gemdeps_without_groups
+ rs = Gem::RequestSet.new
+
+ Tempfile.open 'gem.deps.rb' do |io|
+ io.puts 'gem "a", :group => :test'
+ io.flush
+
+ rs.load_gemdeps io.path, [:test]
+ end
+
+ assert_empty rs.dependencies
+ end
+
def test_resolve
a = util_spec "a", "2", "b" => ">= 2"
b = util_spec "b", "2"
@@ -56,6 +100,21 @@ class TestGemRequestSet < Gem::TestCase
assert_equal ["a-2", "b-2"], names
end
+ def test_resolve_incompatible
+ a1 = util_spec 'a', 1
+ a2 = util_spec 'a', 2
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a', '= 1'
+ rs.gem 'a', '= 2'
+
+ set = StaticSet.new [a1, a2]
+
+ assert_raises Gem::UnsatisfiableDependencyError do
+ rs.resolve set
+ end
+ end
+
def test_resolve_vendor
a_name, _, a_directory = vendor_gem 'a', 1 do |s|
s.add_dependency 'b', '~> 2.0'
@@ -82,6 +141,9 @@ class TestGemRequestSet < Gem::TestCase
names = res.map { |s| s.full_name }.sort
assert_equal ["a-1", "b-2"], names
+
+ assert_equal [@DR::IndexSet, @DR::VendorSet],
+ rs.sets.map { |set| set.class }
end
def test_sorted_requests
@@ -99,13 +161,10 @@ class TestGemRequestSet < Gem::TestCase
end
def test_install_into
- a, ad = util_gem "a", "1", "b" => "= 1"
- b, bd = util_gem "b", "1"
-
- util_setup_spec_fetcher a, b
-
- @fetcher.data["http://gems.example.com/gems/#{a.file_name}"] = Gem.read_binary(ad)
- @fetcher.data["http://gems.example.com/gems/#{b.file_name}"] = Gem.read_binary(bd)
+ spec_fetcher do |fetcher|
+ fetcher.gem "a", "1", "b" => "= 1"
+ fetcher.gem "b", "1"
+ end
rs = Gem::RequestSet.new
rs.gem "a"