diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-28 22:25:55 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-28 22:25:55 +0000 |
commit | a5dfaca00a94bc3d135aae52b4458f5a355bf0ed (patch) | |
tree | 77c9580bb289422d6e97749934a8c24c8aadc76c /test/rubygems/test_gem_dependency_resolver_api_set.rb | |
parent | 3fc7731297d8de1f52cec9382a4f1f0a08bea949 (diff) | |
download | ruby-a5dfaca00a94bc3d135aae52b4458f5a355bf0ed.tar.gz |
* lib/rubygems/ext/builder.rb: Fix incompatibilities when installing
extensions. Patch by Nobu.
[ruby-trunk - Bug #7968] [ruby-trunk - Bug #7971]
* lib/rubygems/ext/ext_conf_builder.rb: ditto.
* lib/rubygems/installer.rb: ditto.
* test/rubygems/test_gem_ext_ext_conf_builder.rb: Test for the above.
* test/rubygems/test_gem_installer.rb: ditto.
* lib/rubygems/commands/sources_command.rb: Prefer HTTPS over HTTP.
* lib/rubygems/defaults.rb: ditto
* lib/rubygems/dependency_resolver.rb: Ditto.
* lib/rubygems/source.rb: ditto.
* lib/rubygems/spec_fetcher.rb: ditto.
* lib/rubygems/specification.rb: ditto.
* lib/rubygems/test_utilities.rb: ditto.
* test/rubygems/test_gem.rb: Test for the above.
* test/rubygems/test_gem_commands_sources_command.rb: ditto.
* test/rubygems/test_gem_dependency_resolver_api_set.rb: ditto.
* test/rubygems/test_gem_remote_fetcher.rb: ditto.
* test/rubygems/test_gem_source.rb: ditto.
* test/rubygems/test_gem_spec_fetcher.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_dependency_resolver_api_set.rb')
-rw-r--r-- | test/rubygems/test_gem_dependency_resolver_api_set.rb | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_dependency_resolver_api_set.rb b/test/rubygems/test_gem_dependency_resolver_api_set.rb new file mode 100644 index 0000000000..c1e7eda191 --- /dev/null +++ b/test/rubygems/test_gem_dependency_resolver_api_set.rb @@ -0,0 +1,80 @@ +require 'rubygems/test_case' +require 'rubygems/dependency_resolver' + +class TestGemDependencyResolverAPISet < Gem::TestCase + + def setup + super + + @DR = Gem::DependencyResolver + + @api_set = @DR::APISet.new + @uri = 'https://rubygems.org/api/v1/dependencies' + @fetcher = Gem::FakeFetcher.new + Gem::RemoteFetcher.fetcher = @fetcher + end + + def test_find_all + b_entry = { + :name => 'b', + :number => '2', + :platform => 'ruby', + :dependencies => [['a', '>= 0']], + } + + @fetcher.data["#{@uri}?gems=b"] = Marshal.dump [b_entry] + + b_req = @DR::DependencyRequest.new dep('b', '>= 0'), nil + + expected = [ + @DR::APISpecification.new(@api_set, b_entry) + ] + + assert_equal expected, @api_set.find_all(b_req) + end + + def test_prefetch + b_entry = { + :name => 'b', + :number => '2', + :platform => 'ruby', + :dependencies => [['a', '>= 0']], + } + + a_entry = { + :name => 'a', + :number => '2', + :platform => 'ruby', + :dependencies => [], + } + + @fetcher.data["#{@uri}?gems=a,b"] = Marshal.dump [a_entry, b_entry] + + a_req = @DR::DependencyRequest.new dep('a', '>= 0'), nil + b_req = @DR::DependencyRequest.new dep('b', '>= 0'), nil + + @api_set.prefetch([b_req, a_req]) + + assert_equal [a_entry], @api_set.versions('a') + assert_equal [b_entry], @api_set.versions('b') + end + + def test_versions_cache + entry = { + :name => 'b', + :number => '2', + :platform => 'ruby', + :dependencies => [['a', '>= 0']], + } + + @fetcher.data["#{@uri}?gems=b"] = Marshal.dump [entry] + + assert_equal [entry], @api_set.versions('b') + + @fetcher.data["#{@uri}?gems=b"] = 'garbage' + + assert_equal [entry], @api_set.versions('b'), 'version data must be cached' + end + +end + |