diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-26 20:24:51 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-26 20:24:51 +0000 |
commit | e487a7f53cffbadf0bf15ff169c9cb5898503250 (patch) | |
tree | eaa80eb4ced6fcdcc8b327d1cc5e47f66703fd1b /test | |
parent | cddd93a57568966b416e300529bdffc0c7e87b51 (diff) | |
download | ruby-e487a7f53cffbadf0bf15ff169c9cb5898503250.tar.gz |
* lib/rubygems: Import RubyGems 2.1.0 Release Candidate
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_gem.rb | 22 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_uninstall_command.rb | 21 | ||||
-rw-r--r-- | test/rubygems/test_gem_package_task.rb | 25 | ||||
-rw-r--r-- | test/rubygems/test_gem_security_policy.rb | 11 | ||||
-rw-r--r-- | test/rubygems/test_gem_security_signer.rb | 6 | ||||
-rw-r--r-- | test/rubygems/test_gem_source.rb | 23 | ||||
-rw-r--r-- | test/rubygems/test_gem_source_installed.rb | 28 | ||||
-rw-r--r-- | test/rubygems/test_gem_source_local.rb | 35 | ||||
-rw-r--r-- | test/rubygems/test_gem_source_specific_file.rb | 38 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 12 |
10 files changed, 205 insertions, 16 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 0ee8d36f8e..38a63c3b2c 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1181,6 +1181,28 @@ class TestGem < Gem::TestCase assert_equal nil, Gem.find_unresolved_default_spec("README") end + def test_default_gems_use_full_paths + begin + engine = RUBY_ENGINE + Object.send :remove_const, :RUBY_ENGINE + Object.const_set :RUBY_ENGINE, 'ruby' + refute Gem.default_gems_use_full_paths? + ensure + Object.send :remove_const, :RUBY_ENGINE + Object.const_set :RUBY_ENGINE, engine + end + + begin + engine = RUBY_ENGINE + Object.send :remove_const, :RUBY_ENGINE + Object.const_set :RUBY_ENGINE, 'jruby' + assert Gem.default_gems_use_full_paths? + ensure + Object.send :remove_const, :RUBY_ENGINE + Object.const_set :RUBY_ENGINE, engine + end + end + def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", @@project_dir) diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index 5a11948ee6..9ba1371b79 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -191,21 +191,30 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase end def test_execute_all - ui = Gem::MockGemUi.new "y\n" - util_make_gems - util_setup_gem ui - assert Gem::Specification.find_all_by_name('a').length > 1 + default = new_default_spec 'default', '1' + install_default_gems default + + gemhome2 = "#{@gemhome}2" + + a_4 = quick_spec 'a', 4 + install_gem a_4, :install_dir => gemhome2 + + Gem::Specification.dirs = [@gemhome, gemhome2] + + assert_includes Gem::Specification.all_names, 'a-1' + assert_includes Gem::Specification.all_names, 'a-4' + assert_includes Gem::Specification.all_names, 'default-1' @cmd.options[:all] = true @cmd.options[:args] = [] - use_ui ui do + use_ui @ui do @cmd.execute end - refute_includes Gem::Specification.all_names, 'a' + assert_equal %w[a-4 default-1], Gem::Specification.all_names.sort end end diff --git a/test/rubygems/test_gem_package_task.rb b/test/rubygems/test_gem_package_task.rb index 35b38cdbc7..1526e825fe 100644 --- a/test/rubygems/test_gem_package_task.rb +++ b/test/rubygems/test_gem_package_task.rb @@ -4,16 +4,37 @@ require 'rubygems/package_task' class TestGemPackageTask < Gem::TestCase + def setup + super + + Rake.application = Rake::Application.new + RakeFileUtils.verbose_flag = false + end + def test_gem_package gem = Gem::Specification.new do |g| g.name = "pkgr" g.version = "1.2.3" - g.files = Rake::FileList["x"].resolve + + g.authors = %w[author] + g.files = %w[x] + g.summary = 'summary' end + pkg = Gem::PackageTask.new(gem) do |p| p.package_files << "y" end - assert_equal ["x", "y"], pkg.package_files + + assert_equal %w[x y], pkg.package_files + + Dir.chdir @tempdir do + FileUtils.touch 'x' + FileUtils.touch 'y' + + Rake.application['package'].invoke + + assert_path_exists 'pkg/pkgr-1.2.3.gem' + end end def test_gem_package_with_current_platform diff --git a/test/rubygems/test_gem_security_policy.rb b/test/rubygems/test_gem_security_policy.rb index 5b960c4d48..a2115e709a 100644 --- a/test/rubygems/test_gem_security_policy.rb +++ b/test/rubygems/test_gem_security_policy.rb @@ -351,6 +351,17 @@ class TestGemSecurityPolicy < Gem::TestCase end end + def test_verify_no_signatures_no_digests + Gem::Security.trust_dir.trust_cert PUBLIC_CERT + + use_ui @ui do + @no.verify [PUBLIC_CERT], nil, {}, {}, 'some_gem' + end + + assert_empty @ui.output + assert_empty @ui.error + end + def test_verify_not_enough_signatures Gem::Security.trust_dir.trust_cert PUBLIC_CERT diff --git a/test/rubygems/test_gem_security_signer.rb b/test/rubygems/test_gem_security_signer.rb index c984382947..f077a46413 100644 --- a/test/rubygems/test_gem_security_signer.rb +++ b/test/rubygems/test_gem_security_signer.rb @@ -84,6 +84,12 @@ class TestGemSecuritySigner < Gem::TestCase assert_equal ENCRYPTED_PRIVATE_KEY.to_s, signer.key.to_s end + def test_extract_name + signer = Gem::Security::Signer.new nil, nil + + assert_equal 'child@example', signer.extract_name(CHILD_CERT) + end + def test_load_cert_chain Gem::Security.trust_dir.trust_cert PUBLIC_CERT diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index 1303978a8e..cb43121ddd 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -184,5 +184,28 @@ class TestGemSource < Gem::TestCase end end + def test_spaceship + remote = @source + specific = Gem::Source::SpecificFile.new(@a1.cache_file) + installed = Gem::Source::Installed.new + local = Gem::Source::Local.new + + assert_equal( 0, remote. <=>(remote), 'remote <=> remote') + + assert_equal(-1, remote. <=>(specific), 'remote <=> specific') + assert_equal( 1, specific. <=>(remote), 'specific <=> remote') + + assert_equal(-1, remote. <=>(local), 'remote <=> local') + assert_equal( 1, local. <=>(remote), 'local <=> remote') + + assert_equal(-1, remote. <=>(installed), 'remote <=> installed') + assert_equal( 1, installed.<=>(remote), 'installed <=> remote') + + no_uri = @source.dup + no_uri.instance_variable_set :@uri, nil + + assert_equal(-1, remote. <=>(no_uri), 'remote <=> no_uri') + end + end diff --git a/test/rubygems/test_gem_source_installed.rb b/test/rubygems/test_gem_source_installed.rb new file mode 100644 index 0000000000..1119ad0c2b --- /dev/null +++ b/test/rubygems/test_gem_source_installed.rb @@ -0,0 +1,28 @@ +require 'rubygems/test_case' +require 'rubygems/source' + +class TestGemSourceInstalled < Gem::TestCase + + def test_spaceship + a1 = quick_gem 'a', '1' + util_build_gem a1 + + remote = Gem::Source.new @gem_repo + specific = Gem::Source::SpecificFile.new a1.cache_file + installed = Gem::Source::Installed.new + local = Gem::Source::Local.new + + assert_equal( 0, installed.<=>(installed), 'installed <=> installed') + + assert_equal(-1, remote. <=>(installed), 'remote <=> installed') + assert_equal( 1, installed.<=>(remote), 'installed <=> remote') + + assert_equal( 1, installed.<=>(local), 'installed <=> local') + assert_equal(-1, local. <=>(installed), 'local <=> installed') + + assert_equal(-1, specific. <=>(installed), 'specific <=> installed') + assert_equal( 1, installed.<=>(specific), 'installed <=> specific') + end + +end + diff --git a/test/rubygems/test_gem_source_local.rb b/test/rubygems/test_gem_source_local.rb index 8e901cfd21..b3b444ccde 100644 --- a/test/rubygems/test_gem_source_local.rb +++ b/test/rubygems/test_gem_source_local.rb @@ -66,18 +66,41 @@ class TestGemSourceLocal < Gem::TestCase assert_equal s, @a end + def test_inspect + assert_equal '#<Gem::Source::Local specs: "NOT LOADED">', @sl.inspect + + @sl.load_specs :released + + inner = [@a, @ap, @b].map { |t| t.name_tuple }.inspect + + assert_equal "#<Gem::Source::Local specs: #{inner}>", @sl.inspect + end + def test_download path = @sl.download @a assert_equal File.expand_path(@a.file_name), path end - def test_compare - uri = URI.parse "http://gems.example/foo" - s = Gem::Source.new uri + def test_spaceship + a1 = quick_gem 'a', '1' + util_build_gem a1 - assert_equal(-1, s <=> @sl) - assert_equal 0, @sl <=> @sl - assert_equal 1, @sl <=> s + remote = Gem::Source.new @gem_repo + specific = Gem::Source::SpecificFile.new a1.cache_file + installed = Gem::Source::Installed.new + local = Gem::Source::Local.new + + assert_equal( 0, local. <=>(local), 'local <=> local') + + assert_equal(-1, remote. <=>(local), 'remote <=> local') + assert_equal( 1, local. <=>(remote), 'local <=> remote') + + assert_equal( 1, installed.<=>(local), 'installed <=> local') + assert_equal(-1, local. <=>(installed), 'local <=> installed') + + assert_equal(-1, specific. <=>(local), 'specific <=> local') + assert_equal( 1, local. <=>(specific), 'local <=> specific') end + end diff --git a/test/rubygems/test_gem_source_specific_file.rb b/test/rubygems/test_gem_source_specific_file.rb index 1d8351781f..8ccbe50c91 100644 --- a/test/rubygems/test_gem_source_specific_file.rb +++ b/test/rubygems/test_gem_source_specific_file.rb @@ -30,4 +30,42 @@ class TestGemSourceSpecificFile < Gem::TestCase def test_download assert_equal @a_gem, @sf.download(@a) end + + def test_spaceship + a1 = quick_gem 'a', '1' + util_build_gem a1 + + remote = Gem::Source.new @gem_repo + specific = Gem::Source::SpecificFile.new a1.cache_file + installed = Gem::Source::Installed.new + local = Gem::Source::Local.new + + assert_equal( 0, specific. <=>(specific), 'specific <=> specific') + + assert_equal(-1, remote. <=>(specific), 'remote <=> specific') + assert_equal( 1, specific. <=>(remote), 'specific <=> remote') + + assert_equal(-1, specific. <=>(local), 'specific <=> local') + assert_equal( 1, local. <=>(specific), 'local <=> specific') + + assert_equal(-1, specific. <=>(installed), 'specific <=> installed') + assert_equal( 1, installed.<=>(specific), 'installed <=> specific') + + a2 = quick_gem 'a', '2' + util_build_gem a2 + + b1 = quick_gem 'b', '1' + util_build_gem b1 + + a1_source = specific + a2_source = Gem::Source::SpecificFile.new a2.cache_file + b1_source = Gem::Source::SpecificFile.new b1.cache_file + + assert_nil a1_source.<=>(b1_source), 'a1_source <=> b1_source' + + assert_equal(-1, a1_source.<=>(a2_source), 'a1_source <=> a2_source') + assert_equal( 0, a1_source.<=>(a1_source), 'a1_source <=> a1_source') + assert_equal( 1, a2_source.<=>(a1_source), 'a2_source <=> a1_source') + end + end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index dce7ad260b..efda6f6f19 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -445,6 +445,14 @@ end end end + def test_self_all_equals + a = new_spec "foo", "1", nil, "lib/foo.rb" + + Gem::Specification.all = [a] + + assert_equal a, Gem::Specification.find_inactive_by_path('foo') + end + def test_self_attribute_names expected_value = %w[ authors @@ -1313,7 +1321,7 @@ dependencies: [] end def test_base_dir_not_loaded - @a1.instance_variable_set :@filename, nil + @a1.instance_variable_set :@loaded_from, nil assert_equal Gem.dir, @a1.base_dir end @@ -1322,7 +1330,7 @@ dependencies: [] default_dir = File.join Gem::Specification.default_specifications_dir, @a1.spec_name - @a1.instance_variable_set :@filename, default_dir + @a1.instance_variable_set :@loaded_from, default_dir assert_equal Gem.default_dir, @a1.base_dir end |