aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_resolver_api_set.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 23:27:30 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 23:27:30 +0000
commit5307d803f5cce7b14a6afd1d51f6d53ec85ca87d (patch)
treeaac2997a9ff000fbf2f1f9f27077bb7b2403f2c9 /test/rubygems/test_gem_resolver_api_set.rb
parentb1529a30e08040b717adef8ac1fa8be1c060e7e1 (diff)
downloadruby-5307d803f5cce7b14a6afd1d51f6d53ec85ca87d.tar.gz
* lib/rubygems: Update to RubyGems master 50a8210. Important changes
in this commit: RubyGems now automatically checks for gem.deps.rb or Gemfile when running ruby executables. This behavior is similar to `bundle exec rake`. This change may be reverted before Ruby 2.1.0 if too many bugs are found. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_resolver_api_set.rb')
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb151
1 files changed, 146 insertions, 5 deletions
diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb
index 976d861cdf..288f496c93 100644
--- a/test/rubygems/test_gem_resolver_api_set.rb
+++ b/test/rubygems/test_gem_resolver_api_set.rb
@@ -6,20 +6,161 @@ class TestGemResolverAPISet < Gem::TestCase
super
@DR = Gem::Resolver
+ @dep_uri = URI "#{@gem_repo}api/v1/dependencies"
end
def test_initialize
set = @DR::APISet.new
- assert_equal URI('https://rubygems.org/api/v1/dependencies'),
- set.dep_uri
+ assert_equal URI('https://rubygems.org/api/v1/dependencies'), set.dep_uri
+ assert_equal URI('https://rubygems.org'), set.uri
+ assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source
end
def test_initialize_uri
- set = @DR::APISet.new @gem_repo
+ set = @DR::APISet.new @dep_uri
- assert_equal URI('http://gems.example.com/'),
- set.dep_uri
+ assert_equal URI("#{@gem_repo}api/v1/dependencies"), set.dep_uri
+ assert_equal URI("#{@gem_repo}"), set.uri
+ end
+
+ def test_find_all
+ spec_fetcher
+
+ data = [
+ { :name => 'a',
+ :number => '1',
+ :platform => 'ruby',
+ :dependencies => [], },
+ ]
+
+ @fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+
+ expected = [
+ @DR::APISpecification.new(set, data.first)
+ ]
+
+ assert_equal expected, set.find_all(a_dep)
+ end
+
+ def test_find_all_cache
+ spec_fetcher
+
+ data = [
+ { :name => 'a',
+ :number => '1',
+ :platform => 'ruby',
+ :dependencies => [], },
+ ]
+
+ @fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+
+ set.prefetch [a_dep]
+
+ @fetcher.data.delete "#{@dep_uri}?gems=a"
+
+ expected = [
+ @DR::APISpecification.new(set, data.first)
+ ]
+
+ assert_equal expected, set.find_all(a_dep)
+ end
+
+ def test_find_all_missing
+ spec_fetcher
+
+ @fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump []
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+
+ assert_empty set.find_all(a_dep)
+
+ @fetcher.data.delete "#{@dep_uri}?gems=a"
+
+ assert_empty set.find_all(a_dep)
+ end
+
+ def test_prefetch
+ spec_fetcher
+
+ data = [
+ { :name => 'a',
+ :number => '1',
+ :platform => 'ruby',
+ :dependencies => [], },
+ ]
+
+ @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
+ @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump []
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+ b_dep = @DR::DependencyRequest.new dep('b'), nil
+
+ set.prefetch [a_dep, b_dep]
+
+ assert_equal %w[a-1], set.find_all(a_dep).map { |s| s.full_name }
+ assert_empty set.find_all(b_dep)
+ end
+
+ def test_prefetch_cache
+ spec_fetcher
+
+ data = [
+ { :name => 'a',
+ :number => '1',
+ :platform => 'ruby',
+ :dependencies => [], },
+ ]
+
+ @fetcher.data["#{@dep_uri}?gems=a"] = Marshal.dump data
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+ b_dep = @DR::DependencyRequest.new dep('b'), nil
+
+ set.prefetch [a_dep]
+
+ @fetcher.data.delete "#{@dep_uri}?gems=a"
+ @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump []
+
+ set.prefetch [a_dep, b_dep]
+ end
+
+ def test_prefetch_cache_missing
+ spec_fetcher
+
+ data = [
+ { :name => 'a',
+ :number => '1',
+ :platform => 'ruby',
+ :dependencies => [], },
+ ]
+
+ @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
+
+ set = @DR::APISet.new @dep_uri
+
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
+ b_dep = @DR::DependencyRequest.new dep('b'), nil
+
+ set.prefetch [a_dep, b_dep]
+
+ @fetcher.data.delete "#{@dep_uri}?gems=a,b"
+
+ set.prefetch [a_dep, b_dep]
end
end