From 44d0a6dcd7563526a8b05ccdfa21d9425b94e62b Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 12 Nov 2013 00:16:41 +0000 Subject: * lib/rubygems: Update to RubyGems master b9213d7. Changes include: Fixed tests on Windows (I hope) by forcing platform for platform-dependent tests. Fixed File.exists? warnings. Improved testing infrastructure. * test/rubygems: ditto. * test/rdoc/test_rdoc_rubygems_hook.rb: Switch to util_spec like RubyGems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_rubygems_hook.rb | 2 +- test/rubygems/test_gem.rb | 24 +- test/rubygems/test_gem_commands_build_command.rb | 2 +- test/rubygems/test_gem_commands_cleanup_command.rb | 26 +- .../test_gem_commands_dependency_command.rb | 47 ++-- test/rubygems/test_gem_commands_fetch_command.rb | 91 +++---- test/rubygems/test_gem_commands_install_command.rb | 301 ++++++++++----------- test/rubygems/test_gem_commands_list_command.rb | 6 +- .../rubygems/test_gem_commands_outdated_command.rb | 8 +- .../rubygems/test_gem_commands_pristine_command.rb | 46 ++-- test/rubygems/test_gem_commands_query_command.rb | 172 ++++++++---- test/rubygems/test_gem_commands_sources_command.rb | 53 +--- .../test_gem_commands_specification_command.rb | 30 +- test/rubygems/test_gem_commands_stale_command.rb | 4 +- .../test_gem_commands_uninstall_command.rb | 6 +- test/rubygems/test_gem_commands_unpack_command.rb | 46 ++-- test/rubygems/test_gem_commands_update_command.rb | 256 +++++++++--------- test/rubygems/test_gem_commands_which_command.rb | 2 +- test/rubygems/test_gem_dependency_list.rb | 34 +-- .../test_gem_dependency_resolution_error.rb | 2 +- test/rubygems/test_gem_dependency_resolver.rb | 6 +- ..._gem_dependency_resolver_dependency_conflict.rb | 2 +- ..._gem_dependency_resolver_index_specification.rb | 10 +- ..._dependency_resolver_installed_specification.rb | 2 +- .../test_gem_dependency_resolver_installer_set.rb | 8 +- test/rubygems/test_gem_doctor.rb | 2 +- test/rubygems/test_gem_ext_builder.rb | 2 +- test/rubygems/test_gem_indexer.rb | 12 +- test/rubygems/test_gem_installer.rb | 12 +- test/rubygems/test_gem_local_remote_options.rb | 2 +- test/rubygems/test_gem_rdoc.rb | 2 +- test/rubygems/test_gem_request_set.rb | 35 ++- .../test_gem_request_set_gem_dependency_api.rb | 24 ++ test/rubygems/test_gem_server.rb | 8 +- test/rubygems/test_gem_source.rb | 104 +++---- test/rubygems/test_gem_spec_fetcher.rb | 168 +++++++----- test/rubygems/test_gem_specification.rb | 105 +++---- test/rubygems/test_gem_uninstaller.rb | 2 +- 38 files changed, 837 insertions(+), 827 deletions(-) (limited to 'test') diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index da9c3edd9f..499d5ac071 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -10,7 +10,7 @@ class TestRDocRubygemsHook < Gem::TestCase skip 'requires RubyGems 1.9+' unless Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9') - @a = quick_spec 'a' do |s| + @a = util_spec 'a' do |s| s.rdoc_options = %w[--main MyTitle] s.extra_rdoc_files = %w[README] end diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index f42225635e..fd4d1de5c6 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -116,7 +116,7 @@ class TestGem < Gem::TestCase end def test_self_bin_path_nonexistent_binfile - quick_spec 'a', '2' do |s| + util_spec 'a', '2' do |s| s.executables = ['exec'] end assert_raises(Gem::GemNotFoundException) do @@ -125,7 +125,7 @@ class TestGem < Gem::TestCase end def test_self_bin_path_no_bin_file - quick_spec 'a', '1' + util_spec 'a', '1' assert_raises(ArgumentError) do Gem.bin_path('a', nil, '1') end @@ -139,7 +139,7 @@ class TestGem < Gem::TestCase def test_self_bin_path_bin_file_gone_in_latest util_exec_gem - quick_spec 'a', '10' do |s| + util_spec 'a', '10' do |s| s.executables = [] end # Should not find a-10's non-abin (bug) @@ -183,7 +183,7 @@ class TestGem < Gem::TestCase fp.puts 'blah' end - foo = quick_spec 'foo' do |s| s.files = %w[data/foo.txt] end + foo = util_spec 'foo' do |s| s.files = %w[data/foo.txt] end install_gem foo end @@ -420,17 +420,15 @@ class TestGem < Gem::TestCase end def test_self_latest_spec_for - a2 = nil - - spec_fetcher do |fetcher| + gems = spec_fetcher do |fetcher| fetcher.spec 'a', 1 fetcher.spec 'a', '3.a' - a2 = fetcher.spec 'a', 2 + fetcher.spec 'a', 2 end spec = Gem.latest_spec_for 'a' - assert_equal a2, spec + assert_equal gems['a-2'], spec end def test_self_latest_rubygems_version @@ -458,7 +456,7 @@ class TestGem < Gem::TestCase end def test_self_loaded_specs - foo = quick_spec 'foo' + foo = util_spec 'foo' install_gem foo foo.activate @@ -959,13 +957,13 @@ class TestGem < Gem::TestCase fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end" end - foo1 = quick_spec 'foo', '1' do |s| + foo1 = util_spec 'foo', '1' do |s| s.files << plugin_path end install_gem foo1 - foo2 = quick_spec 'foo', '2' do |s| + foo2 = util_spec 'foo', '2' do |s| s.files << plugin_path end @@ -1275,7 +1273,7 @@ class TestGem < Gem::TestCase end def util_exec_gem - spec, _ = quick_spec 'a', '4' do |s| + spec, _ = util_spec 'a', '4' do |s| s.executables = ['exec', 'abin'] end diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index 7904a2ea36..5f870c0765 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -7,7 +7,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase def setup super - @gem = quick_spec 'some_gem' do |s| + @gem = util_spec 'some_gem' do |s| s.rubyforge_project = 'example' end diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb index 6fd06d26e0..fdaac545af 100644 --- a/test/rubygems/test_gem_commands_cleanup_command.rb +++ b/test/rubygems/test_gem_commands_cleanup_command.rb @@ -8,8 +8,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase @cmd = Gem::Commands::CleanupCommand.new - @a_1 = quick_spec 'a', 1 - @a_2 = quick_spec 'a', 2 + @a_1 = util_spec 'a', 1 + @a_2 = util_spec 'a', 2 install_gem @a_1 install_gem @a_2 @@ -39,8 +39,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase end def test_execute_all_dependencies - @b_1 = quick_spec 'b', 1 do |s| s.add_dependency 'a', '1' end - @b_2 = quick_spec 'b', 2 do |s| s.add_dependency 'a', '2' end + @b_1 = util_spec 'b', 1 do |s| s.add_dependency 'a', '1' end + @b_2 = util_spec 'b', 2 do |s| s.add_dependency 'a', '2' end install_gem @b_1 install_gem @b_2 @@ -60,8 +60,8 @@ class TestGemCommandsCleanupCommand < Gem::TestCase Gem.use_paths @gemhome, gemhome2 - @b_1 = quick_spec 'b', 1 - @b_2 = quick_spec 'b', 2 + @b_1 = util_spec 'b', 1 + @b_2 = util_spec 'b', 2 install_gem @b_1 install_gem @b_2 @@ -78,7 +78,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase end def test_execute_all_user - @a_1_1 = quick_spec 'a', '1.1' + @a_1_1 = util_spec 'a', '1.1' @a_1_1 = install_gem_user @a_1_1 # pick up user install path Gem::Specification.dirs = [Gem.dir, Gem.user_dir] @@ -97,7 +97,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase def test_execute_all_user_no_sudo FileUtils.chmod 0555, @gemhome - @a_1_1 = quick_spec 'a', '1.1' + @a_1_1 = util_spec 'a', '1.1' @a_1_1 = install_gem_user @a_1_1 # pick up user install path Gem::Specification.dirs = [Gem.dir, Gem.user_dir] @@ -125,10 +125,10 @@ class TestGemCommandsCleanupCommand < Gem::TestCase end def test_execute_keeps_older_versions_with_deps - @b_1 = quick_spec 'b', 1 - @b_2 = quick_spec 'b', 2 + @b_1 = util_spec 'b', 1 + @b_2 = util_spec 'b', 2 - @c = quick_spec 'c', 1 do |s| + @c = util_spec 'c', 1 do |s| s.add_dependency 'b', '1' end @@ -146,9 +146,9 @@ class TestGemCommandsCleanupCommand < Gem::TestCase def test_execute_ignore_default_gem_verbose Gem.configuration.verbose = :really - @b_1 = quick_spec 'b', 1 + @b_1 = util_spec 'b', 1 @b_default = new_default_spec "b", "2" - @b_2 = quick_spec 'b', 3 + @b_2 = util_spec 'b', 3 install_gem @b_1 install_default_specs @b_default diff --git a/test/rubygems/test_gem_commands_dependency_command.rb b/test/rubygems/test_gem_commands_dependency_command.rb index 99b04bcd19..e22b240afe 100644 --- a/test/rubygems/test_gem_commands_dependency_command.rb +++ b/test/rubygems/test_gem_commands_dependency_command.rb @@ -8,8 +8,6 @@ class TestGemCommandsDependencyCommand < Gem::TestCase @cmd = Gem::Commands::DependencyCommand.new @cmd.options[:domain] = :local - - util_setup_fake_fetcher true end def test_execute @@ -30,6 +28,13 @@ class TestGemCommandsDependencyCommand < Gem::TestCase end def test_execute_no_args + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'dep_x', 1, 'x' => '>= 1' + fetcher.legacy_platform + end + @cmd.options[:args] = [] use_ui @ui do @@ -41,23 +46,11 @@ Gem a-1 Gem a-2.a -Gem a-2 - -Gem a-3.a - -Gem a_evil-9 - -Gem b-2 - -Gem c-1.2 - Gem dep_x-1 x (>= 1) Gem pl-1-x86-linux -Gem x-1 - EOF assert_equal expected, @ui.output @@ -78,7 +71,7 @@ Gem x-1 end def test_execute_pipe_format - quick_spec 'foo' do |gem| + util_spec 'foo' do |gem| gem.add_dependency 'bar', '> 1' end @@ -94,6 +87,13 @@ Gem x-1 end def test_execute_regexp + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'a_evil', 9 + fetcher.spec 'b', 2 + end + @cmd.options[:args] = %w[/[ab]/] use_ui @ui do @@ -105,10 +105,6 @@ Gem a-1 Gem a-2.a -Gem a-2 - -Gem a-3.a - Gem a_evil-9 Gem b-2 @@ -187,7 +183,10 @@ ERROR: Only reverse dependencies for local gems are supported. @fetcher = Gem::FakeFetcher.new Gem::RemoteFetcher.fetcher = @fetcher - util_setup_spec_fetcher @a1, @a2 + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + end @cmd.options[:args] = %w[a] @cmd.options[:domain] = :remote @@ -202,11 +201,9 @@ ERROR: Only reverse dependencies for local gems are supported. end def test_execute_prerelease - @fetcher = Gem::FakeFetcher.new - Gem::RemoteFetcher.fetcher = @fetcher - - util_clear_gems - util_setup_spec_fetcher @a2_pre + spec_fetcher do |fetcher| + fetcher.spec 'a', '2.a' + end @cmd.options[:args] = %w[a] @cmd.options[:domain] = :remote diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb index 364881a132..c452e79f14 100644 --- a/test/rubygems/test_gem_commands_fetch_command.rb +++ b/test/rubygems/test_gem_commands_fetch_command.rb @@ -12,15 +12,13 @@ class TestGemCommandsFetchCommand < Gem::TestCase end def test_execute - util_setup_fake_fetcher - util_setup_spec_fetcher @a2 - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - File.read(@a2.cache_file) + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end refute_path_exists File.join(@tempdir, 'cache'), 'sanity check' - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do Dir.chdir @tempdir do @@ -28,24 +26,23 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a2.file_name), - "#{@a2.full_name} not fetched") + a2 = specs['a-2'] + + assert_path_exists(File.join(@tempdir, a2.file_name), + "#{a2.full_name} not fetched") refute_path_exists File.join(@tempdir, 'cache'), 'gem repository directories must not be created' end def test_execute_latest - util_setup_fake_fetcher - util_setup_spec_fetcher @a1, @a2 - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = - File.read(@a1.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - File.read(@a2.cache_file) + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + end refute_path_exists File.join(@tempdir, 'cache'), 'sanity check' - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] @cmd.options[:version] = req('>= 0.1') use_ui @ui do @@ -54,23 +51,20 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a2.file_name), - "#{@a2.full_name} not fetched") + a2 = specs['a-2'] + assert_path_exists(File.join(@tempdir, a2.file_name), + "#{a2.full_name} not fetched") refute_path_exists File.join(@tempdir, 'cache'), 'gem repository directories must not be created' end def test_execute_prerelease - util_setup_fake_fetcher true - util_clear_gems - util_setup_spec_fetcher @a2, @a2_pre - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - File.read(@a2.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - File.read(@a2_pre.cache_file) + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'a', '2.a' + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] @cmd.options[:prerelease] = true use_ui @ui do @@ -79,21 +73,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a2.file_name), - "#{@a2.full_name} not fetched") + a2 = specs['a-2'] + + assert_path_exists(File.join(@tempdir, a2.file_name), + "#{a2.full_name} not fetched") end def test_execute_specific_prerelease - util_setup_fake_fetcher true - util_clear_gems - util_setup_spec_fetcher @a2, @a2_pre - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - File.read(@a2.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - File.read(@a2_pre.cache_file) + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'a', '2.a' + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] @cmd.options[:prerelease] = true @cmd.options[:version] = "2.a" @@ -103,18 +95,19 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a2_pre.file_name), - "#{@a2_pre.full_name} not fetched") + a2_pre = specs['a-2.a'] + + assert_path_exists(File.join(@tempdir, a2_pre.file_name), + "#{a2_pre.full_name} not fetched") end def test_execute_version - util_setup_fake_fetcher - util_setup_spec_fetcher @a1, @a2 - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = - File.read(@a1.cache_file) + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] @cmd.options[:version] = Gem::Requirement.new '1' use_ui @ui do @@ -123,8 +116,10 @@ class TestGemCommandsFetchCommand < Gem::TestCase end end - assert_path_exists(File.join(@tempdir, @a1.file_name), - "#{@a1.full_name} not fetched") + a1 = specs['a-1'] + + assert_path_exists(File.join(@tempdir, a1.file_name), + "#{a1.full_name} not fetched") end end diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 55246502a5..ed7f72d6a5 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -27,15 +27,12 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_exclude_prerelease - util_setup_fake_fetcher :prerelease - util_setup_spec_fetcher - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - read_binary(@a2_pre.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'a', '2.pre' + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -47,18 +44,17 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_explicit_version_includes_prerelease - util_setup_fake_fetcher :prerelease - util_setup_spec_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'a', '2.a' + end - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - read_binary(@a2_pre.cache_file) + a2_pre = specs['a-2.a'] - @cmd.handle_options [@a2_pre.name, '--version', @a2_pre.version.to_s, + @cmd.handle_options [a2_pre.name, '--version', a2_pre.version.to_s, "--no-ri", "--no-rdoc"] assert @cmd.options[:prerelease] - assert @cmd.options[:version].satisfied_by?(@a2_pre.version) + assert @cmd.options[:version].satisfied_by?(a2_pre.version) use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -70,12 +66,15 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_local - util_setup_fake_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end + @cmd.options[:domain] = :local - FileUtils.mv @a2.cache_file, @tempdir + FileUtils.mv specs['a-2'].cache_file, @tempdir - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do orig_dir = Dir.pwd @@ -97,12 +96,15 @@ class TestGemCommandsInstallCommand < Gem::TestCase def test_execute_no_user_install skip 'skipped on MS Windows (chmod has no effect)' if win_platform? - util_setup_fake_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end + @cmd.options[:user_install] = false - FileUtils.mv @a2.cache_file, @tempdir + FileUtils.mv specs['a-2'].cache_file, @tempdir - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do orig_dir = Dir.pwd @@ -122,7 +124,8 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_local_missing - util_setup_fake_fetcher + spec_fetcher + @cmd.options[:domain] = :local @cmd.options[:args] = %w[no_such_gem] @@ -147,8 +150,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_nonexistent - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher @cmd.options[:args] = %w[nonexistent] @@ -163,8 +165,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase end def test_execute_bad_source - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher # This is needed because we need to exercise the cache path # within SpecFetcher @@ -197,8 +198,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase misspelled = "nonexistent_with_hint" correctly_spelled = "non_existent_with_hint" - util_setup_fake_fetcher - util_setup_spec_fetcher quick_spec(correctly_spelled, '2') + spec_fetcher do |fetcher| + fetcher.spec correctly_spelled, 2 + end @cmd.options[:args] = [misspelled] @@ -221,8 +223,10 @@ ERROR: Possible alternatives: non_existent_with_hint misspelled = "non-existent_with-hint" correctly_spelled = "nonexistent-with_hint" - util_setup_fake_fetcher - util_setup_spec_fetcher quick_spec(correctly_spelled, '2') + spec_fetcher do |fetcher| + fetcher.spec correctly_spelled, 2 + fetcher.clear + end @cmd.options[:args] = [misspelled] @@ -257,17 +261,13 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_prerelease_skipped_when_no_flag_set - util_setup_fake_fetcher :prerelease - util_clear_gems - util_setup_spec_fetcher @a1, @a2_pre - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = - read_binary(@a1.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - read_binary(@a2_pre.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', '3.a' + end @cmd.options[:prerelease] = false - @cmd.options[:args] = [@a2_pre.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -279,17 +279,14 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_prerelease_wins_over_previous_ver - util_setup_fake_fetcher :prerelease - util_clear_gems - util_setup_spec_fetcher @a1, @a2_pre - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = - read_binary(@a1.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - read_binary(@a2_pre.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', '2.a' + fetcher.clear + end @cmd.options[:prerelease] = true - @cmd.options[:args] = [@a2_pre.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -301,17 +298,13 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_prerelease_skipped_when_non_pre_available - util_setup_fake_fetcher :prerelease - util_clear_gems - util_setup_spec_fetcher @a2, @a2_pre - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) - @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] = - read_binary(@a2_pre.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', '2.pre' + fetcher.gem 'a', 2 + end @cmd.options[:prerelease] = true - @cmd.options[:args] = [@a2_pre.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -323,16 +316,19 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_rdoc - util_setup_fake_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end Gem.done_installing(&Gem::RDoc.method(:generation_hook)) @cmd.options[:document] = %w[rdoc ri] @cmd.options[:domain] = :local - FileUtils.mv @a2.cache_file, @tempdir + a2 = specs['a-2'] + FileUtils.mv a2.cache_file, @tempdir - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do # Don't use Dir.chdir with a block, it warnings a lot because @@ -351,22 +347,25 @@ ERROR: Possible alternatives: non_existent_with_hint wait_for_child_process_to_exit - assert_path_exists File.join(@a2.doc_dir, 'ri') - assert_path_exists File.join(@a2.doc_dir, 'rdoc') + assert_path_exists File.join(a2.doc_dir, 'ri') + assert_path_exists File.join(a2.doc_dir, 'rdoc') end def test_execute_saves_build_args - util_setup_fake_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end args = %w!--with-awesome=true --more-awesome=yes! Gem::Command.build_args = args - @cmd.options[:domain] = :local + a2 = specs['a-2'] + FileUtils.mv a2.cache_file, @tempdir - FileUtils.mv @a2.cache_file, @tempdir + @cmd.options[:domain] = :local - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do # Don't use Dir.chdir with a block, it warnings a lot because @@ -383,21 +382,19 @@ ERROR: Possible alternatives: non_existent_with_hint end end - path = @a2.build_info_file + path = a2.build_info_file assert_path_exists path - assert_equal args, @a2.build_args + assert_equal args, a2.build_args end def test_execute_remote - util_setup_fake_fetcher - util_setup_spec_fetcher - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -411,17 +408,22 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_remote_ignores_files - util_setup_fake_fetcher - util_setup_spec_fetcher + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + end @cmd.options[:domain] = :remote - FileUtils.mv @a2.cache_file, @tempdir + a1 = specs['a-1'] + a2 = specs['a-2'] + + FileUtils.mv a2.cache_file, @tempdir - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a1.cache_file) + @fetcher.data["#{@gem_repo}gems/#{a2.file_name}"] = + read_binary(a1.cache_file) - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = [a2.name] gemdir = File.join @gemhome, 'specifications' @@ -451,14 +453,17 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_two - util_setup_fake_fetcher - @cmd.options[:domain] = :local + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'b', 2 + end - FileUtils.mv @a2.cache_file, @tempdir + FileUtils.mv specs['a-2'].cache_file, @tempdir + FileUtils.mv specs['b-2'].cache_file, @tempdir - FileUtils.mv @b2.cache_file, @tempdir + @cmd.options[:domain] = :local - @cmd.options[:args] = [@a2.name, @b2.name] + @cmd.options[:args] = %w[a b] use_ui @ui do orig_dir = Dir.pwd @@ -498,17 +503,17 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_conservative - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher do |fetcher| + fetcher.gem 'b', 2 - @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = - read_binary(@b2.cache_file) + fetcher.clear - uninstall_gem(@b2) + fetcher.gem 'a', 2 + end @cmd.options[:conservative] = true - @cmd.options[:args] = [@a2.name, @b2.name] + @cmd.options[:args] = %w[a b] use_ui @ui do orig_dir = Dir.pwd @@ -529,14 +534,14 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_parses_requirement_from_gemname - util_setup_fake_fetcher - @cmd.options[:domain] = :local - - FileUtils.mv @a2.cache_file, @tempdir + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.gem 'b', 2 + end - FileUtils.mv @b2.cache_file, @tempdir + @cmd.options[:domain] = :local - req = "#{@a2.name}:10.0" + req = "a:10.0" @cmd.options[:args] = [req] @@ -581,15 +586,14 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_show_source_problems_even_on_success - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.clear + end Gem.sources << "http://nonexistent.example" - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) - - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do assert_raises Gem::MockGemUi::SystemExitException, @ui.error do @@ -608,11 +612,9 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_uses_from_a_gemdeps - util_setup_fake_fetcher - util_setup_spec_fetcher - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end File.open @gemdeps, "w" do |f| f << "gem 'a'" @@ -632,12 +634,10 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_installs_from_a_gemdeps - util_setup_fake_fetcher - util_setup_spec_fetcher @a2 - util_clear_gems - - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = - read_binary(@a2.cache_file) + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + fetcher.clear + end File.open @gemdeps, "w" do |f| f << "gem 'a'" @@ -657,15 +657,11 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_installs_deps_a_gemdeps - q, q_gem = util_gem 'q', '1.0' - r, r_gem = util_gem 'r', '2.0', 'q' => nil - - util_setup_fake_fetcher - util_setup_spec_fetcher q, r - util_clear_gems - - add_to_fetcher q, q_gem - add_to_fetcher r, r_gem + spec_fetcher do |fetcher| + fetcher.gem 'q', '1.0' + fetcher.gem 'r', '2.0', 'q' => nil + fetcher.clear + end File.open @gemdeps, "w" do |f| f << "gem 'r'" @@ -688,16 +684,13 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_uses_deps_a_gemdeps - q, _ = util_gem 'q', '1.0' - r, r_gem = util_gem 'r', '2.0', 'q' => nil + spec_fetcher do |fetcher| + fetcher.gem 'r', '2.0', 'q' => nil - util_setup_fake_fetcher - util_setup_spec_fetcher q, r - util_clear_gems + fetcher.clear - add_to_fetcher r, r_gem - - Gem::Specification.add_specs q + fetcher.spec 'q', '1.0' + end File.open @gemdeps, "w" do |f| f << "gem 'r'" @@ -720,15 +713,11 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_installs_deps_a_gemdeps_into_a_path - q, q_gem = util_gem 'q', '1.0' - r, r_gem = util_gem 'r', '2.0', 'q' => nil - - util_setup_fake_fetcher - util_setup_spec_fetcher q, r - util_clear_gems - - add_to_fetcher q, q_gem - add_to_fetcher r, r_gem + spec_fetcher do |fetcher| + fetcher.gem 'q', '1.0' + fetcher.gem 'r', '2.0', 'q' => nil + fetcher.clear + end File.open @gemdeps, "w" do |f| f << "gem 'r'" @@ -755,17 +744,13 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_with_gemdeps_path_ignores_system - q, q_gem = util_gem 'q', '1.0' - r, r_gem = util_gem 'r', '2.0', 'q' => nil - - util_setup_fake_fetcher - util_setup_spec_fetcher q, r - util_clear_gems - - add_to_fetcher q, q_gem - add_to_fetcher r, r_gem + specs = spec_fetcher do |fetcher| + fetcher.gem 'q', '1.0' + fetcher.gem 'r', '2.0', 'q' => nil + fetcher.clear + end - Gem::Specification.add_specs q + Gem::Specification.add_specs specs['q-1.0'] File.open @gemdeps, "w" do |f| f << "gem 'r'" @@ -792,16 +777,12 @@ ERROR: Possible alternatives: non_existent_with_hint end def test_execute_uses_deps_a_gemdeps_with_a_path - q, q_gem = util_gem 'q', '1.0' - r, r_gem = util_gem 'r', '2.0', 'q' => nil - - util_setup_fake_fetcher - util_setup_spec_fetcher q, r - util_clear_gems - - add_to_fetcher r, r_gem + specs = spec_fetcher do |fetcher| + fetcher.gem 'q', '1.0' + fetcher.gem 'r', '2.0', 'q' => nil + end - i = Gem::Installer.new q_gem, :install_dir => "gf-path" + i = Gem::Installer.new specs['q-1.0'].cache_file, :install_dir => "gf-path" i.install assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed" diff --git a/test/rubygems/test_gem_commands_list_command.rb b/test/rubygems/test_gem_commands_list_command.rb index 05afbc6f8d..b03f166e1b 100644 --- a/test/rubygems/test_gem_commands_list_command.rb +++ b/test/rubygems/test_gem_commands_list_command.rb @@ -8,9 +8,9 @@ class TestGemCommandsListCommand < Gem::TestCase @cmd = Gem::Commands::ListCommand.new - util_setup_fake_fetcher - - @si = util_setup_spec_fetcher @a1, @a2, @pl1 + spec_fetcher do |fetcher| + fetcher.spec 'c', 1 + end @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do raise Gem::RemoteFetcher::FetchError diff --git a/test/rubygems/test_gem_commands_outdated_command.rb b/test/rubygems/test_gem_commands_outdated_command.rb index eee273af5c..d369c6b14b 100644 --- a/test/rubygems/test_gem_commands_outdated_command.rb +++ b/test/rubygems/test_gem_commands_outdated_command.rb @@ -17,13 +17,11 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase spec_fetcher do |fetcher| fetcher.spec 'foo', '1.0' fetcher.spec 'foo', '2.0' + fetcher.clear + fetcher.gem 'foo', '0.1' + fetcher.gem 'foo', '0.2' end - quick_gem 'foo', '0.1' - quick_gem 'foo', '0.2' - - Gem::Specification.reset - use_ui @ui do @cmd.execute end diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index 1dde7d1219..7ea2b042c9 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -9,7 +9,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute - a = quick_spec 'a' do |s| + a = util_spec 'a' do |s| s.executables = %w[foo] s.files = %w[bin/foo lib/a.rb] end @@ -51,7 +51,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_all - a = quick_spec 'a' do |s| s.executables = %w[foo] end + a = util_spec 'a' do |s| s.executables = %w[foo] end write_file File.join(@tempdir, 'bin', 'foo') do |fp| fp.puts "#!/usr/bin/ruby" end @@ -81,7 +81,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_env_shebang - a = quick_spec 'a' do |s| + a = util_spec 'a' do |s| s.executables = %w[foo] s.files = %w[bin/foo] end @@ -111,7 +111,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_extensions_explicit - a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end + a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' write_file ext_path do |io| @@ -124,7 +124,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase RUBY end - b = quick_spec 'b' + b = util_spec 'b' install_gem a install_gem b @@ -147,7 +147,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_no_extension - a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end + a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' write_file ext_path do |io| @@ -172,7 +172,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_with_extension_with_build_args - a = quick_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end + a = util_spec 'a' do |s| s.extensions << 'ext/a/extconf.rb' end ext_path = File.join @tempdir, 'ext', 'a', 'extconf.rb' write_file ext_path do |io| @@ -205,8 +205,8 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_many - a = quick_spec 'a' - b = quick_spec 'b' + a = util_spec 'a' + b = util_spec 'b' install_gem a install_gem b @@ -226,14 +226,14 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_many_multi_repo - a = quick_spec 'a' + a = util_spec 'a' install_gem a Gem.clear_paths gemhome2 = File.join @tempdir, 'gemhome2' Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 } - b = quick_spec 'b' + b = util_spec 'b' install_gem b @cmd.options[:args] = %w[a b] @@ -256,24 +256,14 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_missing_cache_gem - a_2 = quick_spec 'a', 2 - a_3 = quick_spec 'a', 3 - - install_gem a_2 - install_gem a_3 - - a_2_data = nil - open File.join(@gemhome, 'cache', a_2.file_name), 'rb' do |fp| - a_2_data = fp.read + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + fetcher.gem 'a', 3 + fetcher.gem 'a', '3.a' end - util_setup_fake_fetcher - util_setup_spec_fetcher a_2 - - url = "http://gems.example.com/gems/#{a_2.file_name}" - Gem::RemoteFetcher.fetcher.data[url] = a_2_data - - FileUtils.rm a_2.cache_file + FileUtils.rm specs['a-2'].cache_file @cmd.options[:args] = %w[a] @@ -310,7 +300,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase end def test_execute_only_executables - a = quick_spec 'a' do |s| + a = util_spec 'a' do |s| s.executables = %w[foo] s.files = %w[bin/foo lib/a.rb] end diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb index ccd64810fb..43fa82571d 100644 --- a/test/rubygems/test_gem_commands_query_command.rb +++ b/test/rubygems/test_gem_commands_query_command.rb @@ -8,9 +8,11 @@ class TestGemCommandsQueryCommand < Gem::TestCase @cmd = Gem::Commands::QueryCommand.new - util_setup_fake_fetcher - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1, @a3a + @specs = spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + end @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do raise Gem::RemoteFetcher::FetchError @@ -18,6 +20,10 @@ class TestGemCommandsQueryCommand < Gem::TestCase end def test_execute + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r] use_ui @ui do @@ -37,13 +43,18 @@ pl (1 i386-linux) end def test_execute_platform - @a1r = @a1.dup + spec_fetcher do |fetcher| + fetcher.clear - @a1.platform = 'x86-linux' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 1 + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1 + fetcher.spec 'a', 2 do |s| + s.platform = 'universal-darwin' + end + end @cmd.handle_options %w[-r -a] @@ -56,8 +67,6 @@ pl (1 i386-linux) *** REMOTE GEMS *** a (2 universal-darwin, 1 ruby x86-linux) -b (2) -pl (1 i386-linux) EOF assert_equal expected, @ui.output @@ -65,6 +74,10 @@ pl (1 i386-linux) end def test_execute_all + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --all] use_ui @ui do @@ -84,6 +97,10 @@ pl (1 i386-linux) end def test_execute_all_prerelease + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --all --prerelease] use_ui @ui do @@ -103,12 +120,15 @@ pl (1 i386-linux) end def test_execute_details - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' + spec_fetcher do |fetcher| + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-r -d] @@ -140,15 +160,22 @@ pl (1) end def test_execute_details_platform - @a1.platform = 'x86-linux' + spec_fetcher do |fetcher| + fetcher.clear + + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + s.platform = 'universal-darwin' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-r -d] @@ -282,6 +309,10 @@ pl (1) end def test_execute_local + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :local use_ui @ui do @@ -301,6 +332,10 @@ pl (1 i386-linux) end def test_execute_local_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[] @ui.outs.tty = false @@ -319,6 +354,10 @@ pl (1 i386-linux) end def test_execute_local_quiet + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :local Gem.configuration.verbose = false @@ -336,6 +375,10 @@ pl (1 i386-linux) end def test_execute_no_versions + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r --no-versions] use_ui @ui do @@ -355,6 +398,10 @@ pl end def test_execute_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-r] @ui.outs.tty = false @@ -391,6 +438,10 @@ a (3.a) end def test_execute_prerelease_local + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[-l --prerelease] use_ui @ui do @@ -410,6 +461,10 @@ pl (1 i386-linux) end def test_execute_remote + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :remote use_ui @ui do @@ -429,6 +484,10 @@ pl (1 i386-linux) end def test_execute_remote_notty + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[] @ui.outs.tty = false @@ -447,6 +506,10 @@ pl (1 i386-linux) end def test_execute_remote_quiet + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.options[:domain] = :remote Gem.configuration.verbose = false @@ -464,15 +527,22 @@ pl (1 i386-linux) end def test_execute_local_details - @a1.platform = 'x86-linux' + spec_fetcher do |fetcher| + fetcher.clear - @a2.summary = 'This is a lot of text. ' * 4 - @a2.authors = ['Abraham Lincoln', 'Hirohito'] - @a2.homepage = 'http://a.example.com/' - @a2.platform = 'universal-darwin' + fetcher.spec 'a', 1 do |s| + s.platform = 'x86-linux' + end + + fetcher.spec 'a', 2 do |s| + s.summary = 'This is a lot of text. ' * 4 + s.authors = ['Abraham Lincoln', 'Hirohito'] + s.homepage = 'http://a.example.com/' + s.platform = 'universal-darwin' + end - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @pl1 + fetcher.legacy_platform + end @cmd.handle_options %w[-l -d] @@ -486,6 +556,7 @@ pl (1 i386-linux) str.gsub!(/at: [^\n]*/, "at: -") expected = <<-EOF + *** LOCAL GEMS *** a (2, 1) @@ -500,7 +571,7 @@ a (2, 1) This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. -pl \(1\) +pl (1) Platform: i386-linux Author: A User Homepage: http://example.com @@ -509,13 +580,18 @@ pl \(1\) this is a summary EOF - assert_match expected, @ui.output + assert_equal expected, @ui.output end def test_execute_default_details - default_gem_dir = Gem::Specification.default_specifications_dir - @a1.loaded_from = - File.join default_gem_dir, @a1.spec_name + spec_fetcher do |fetcher| + fetcher.clear + + fetcher.spec 'a', 2 + end + + a1 = new_default_spec 'a', 1 + install_default_specs a1 @cmd.handle_options %w[-l -d] @@ -527,20 +603,11 @@ pl \(1\) *** LOCAL GEMS *** -a (3.a, 2, 1) - Author: A User - Homepage: http://example.com - Installed at (3.a): #{@gemhome} - (2): #{@gemhome} - (1, default): #{@a1.base_dir} - - this is a summary - -pl \(1\) - Platform: i386-linux +a (2, 1) Author: A User Homepage: http://example.com - Installed at: #{@gemhome} + Installed at (2): #{@gemhome} + (1, default): #{a1.base_dir} this is a summary EOF @@ -549,15 +616,18 @@ pl \(1\) end def test_make_entry + a_2_name = @specs['a-2'].original_name + @fetcher.data.delete \ - "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{@a2.original_name}.gemspec.rz" + "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz" + a2 = @specs['a-2'] entry_tuples = [ - [Gem::NameTuple.new(@a2.name, @a2.version, @a2.platform), + [Gem::NameTuple.new(a2.name, a2.version, a2.platform), Gem.sources.first], ] - platforms = { @a2.version => [@a2.platform] } + platforms = { a2.version => [a2.platform] } entry = @cmd.send :make_entry, entry_tuples, platforms @@ -566,6 +636,10 @@ pl \(1\) # Test for multiple args handling! def test_execute_multiple_args + spec_fetcher do |fetcher| + fetcher.legacy_platform + end + @cmd.handle_options %w[a pl] use_ui @ui do diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb index d1f39425ed..8ee0fd3cb7 100644 --- a/test/rubygems/test_gem_commands_sources_command.rb +++ b/test/rubygems/test_gem_commands_sources_command.rb @@ -6,7 +6,7 @@ class TestGemCommandsSourcesCommand < Gem::TestCase def setup super - util_setup_fake_fetcher + spec_fetcher @cmd = Gem::Commands::SourcesCommand.new @@ -18,7 +18,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase end def test_execute - util_setup_spec_fetcher @cmd.handle_options [] use_ui @ui do @@ -36,9 +35,9 @@ class TestGemCommandsSourcesCommand < Gem::TestCase end def test_execute_add - util_setup_fake_fetcher - - install_specs @a1 + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end specs = Gem::Specification.map { |spec| [spec.name, spec.version, spec.original_platform] @@ -54,8 +53,6 @@ class TestGemCommandsSourcesCommand < Gem::TestCase @cmd.handle_options %W[--add #{@new_repo}] - util_setup_spec_fetcher - use_ui @ui do @cmd.execute end @@ -71,19 +68,13 @@ class TestGemCommandsSourcesCommand < Gem::TestCase end def test_execute_add_nonexistent_source - util_setup_fake_fetcher - uri = "http://beta-gems.example.com/specs.#{@marshal_version}.gz" @fetcher.data[uri] = proc do raise Gem::RemoteFetcher::FetchError.new('it died', uri) end - Gem::RemoteFetcher.fetcher = @fetcher - @cmd.handle_options %w[--add http://beta-gems.example.com] - util_setup_spec_fetcher - use_ui @ui do assert_raises Gem::MockGemUi::TermError do @cmd.execute @@ -102,8 +93,6 @@ Error fetching http://beta-gems.example.com: def test_execute_add_redundant_source @cmd.handle_options %W[--add #{@gem_repo}] - util_setup_spec_fetcher - use_ui @ui do @cmd.execute end @@ -120,9 +109,10 @@ source #{@gem_repo} already present in the cache def test_execute_add_http_rubygems_org http_rubygems_org = 'http://rubygems.org' - util_setup_fake_fetcher - install_specs @a1 + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end specs = Gem::Specification.map { |spec| [spec.name, spec.version, spec.original_platform] @@ -138,8 +128,6 @@ source #{@gem_repo} already present in the cache @cmd.handle_options %W[--add #{http_rubygems_org}] - util_setup_spec_fetcher - ui = Gem::MockGemUi.new "n" use_ui ui do @@ -160,8 +148,6 @@ source #{@gem_repo} already present in the cache def test_execute_add_bad_uri @cmd.handle_options %w[--add beta-gems.example.com] - util_setup_spec_fetcher - use_ui @ui do assert_raises Gem::MockGemUi::TermError do @cmd.execute @@ -181,8 +167,6 @@ beta-gems.example.com is not a URI def test_execute_clear_all @cmd.handle_options %w[--clear-all] - util_setup_spec_fetcher - use_ui @ui do @cmd.execute end @@ -218,8 +202,6 @@ beta-gems.example.com is not a URI def test_execute_remove @cmd.handle_options %W[--remove #{@gem_repo}] - util_setup_spec_fetcher - use_ui @ui do @cmd.execute end @@ -233,8 +215,6 @@ beta-gems.example.com is not a URI def test_execute_remove_no_network @cmd.handle_options %W[--remove #{@gem_repo}] - util_setup_fake_fetcher - @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do raise Gem::RemoteFetcher::FetchError end @@ -252,22 +232,9 @@ beta-gems.example.com is not a URI def test_execute_update @cmd.handle_options %w[--update] - util_setup_fake_fetcher - util_setup_spec_fetcher @a1 - - specs = Gem::Specification.map { |spec| - [spec.name, spec.version, spec.original_platform] - } - - @fetcher.data["#{@gem_repo}specs.#{Gem.marshal_version}.gz"] = - util_gzip Marshal.dump(specs) - - latest_specs = Gem::Specification.latest_specs.map { |spec| - [spec.name, spec.version, spec.original_platform] - } - - @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = - util_gzip Marshal.dump(latest_specs) + spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + end use_ui @ui do @cmd.execute diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb index fb28302cc3..80564f9dce 100644 --- a/test/rubygems/test_gem_commands_specification_command.rb +++ b/test/rubygems/test_gem_commands_specification_command.rb @@ -10,7 +10,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute - foo = quick_spec 'foo' + foo = util_spec 'foo' install_specs foo @@ -26,8 +26,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute_all - quick_spec 'foo', '0.0.1' - quick_spec 'foo', '0.0.2' + util_spec 'foo', '0.0.1' + util_spec 'foo', '0.0.2' @cmd.options[:args] = %w[foo] @cmd.options[:all] = true @@ -44,8 +44,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute_all_conflicts_with_version - quick_spec 'foo', '0.0.1' - quick_spec 'foo', '0.0.2' + util_spec 'foo', '0.0.1' + util_spec 'foo', '0.0.2' @cmd.options[:args] = %w[foo] @cmd.options[:all] = true @@ -89,8 +89,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute_exact_match - quick_spec 'foo' - quick_spec 'foo_bar' + util_spec 'foo' + util_spec 'foo_bar' @cmd.options[:args] = %w[foo] @@ -118,7 +118,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute_file - foo = quick_spec 'foo' do |s| + foo = util_spec 'foo' do |s| s.files = %w[lib/code.rb] end @@ -188,10 +188,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase def test_execute_remote_without_prerelease spec_fetcher do |fetcher| - foo = fetcher.spec 'foo', '2.0.0' - foo_pre = fetcher.spec 'foo', '2.0.1.pre' - - install_specs foo, foo_pre + fetcher.spec 'foo', '2.0.0' + fetcher.spec 'foo', '2.0.1.pre' end @cmd.options[:args] = %w[foo] @@ -211,10 +209,8 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase def test_execute_remote_with_prerelease spec_fetcher do |fetcher| - foo = fetcher.spec 'foo', '2.0.0' - foo_pre = fetcher.spec 'foo', '2.0.1.pre' - - install_specs foo, foo_pre + fetcher.spec 'foo', '2.0.0' + fetcher.spec 'foo', '2.0.1.pre' end @cmd.options[:args] = %w[foo] @@ -234,7 +230,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase end def test_execute_ruby - foo = quick_spec 'foo' + foo = util_spec 'foo' install_specs foo diff --git a/test/rubygems/test_gem_commands_stale_command.rb b/test/rubygems/test_gem_commands_stale_command.rb index 74f730bfa5..ca80784749 100644 --- a/test/rubygems/test_gem_commands_stale_command.rb +++ b/test/rubygems/test_gem_commands_stale_command.rb @@ -10,11 +10,11 @@ class TestGemCommandsStaleCommand < Gem::TestCase def test_execute_sorts files = %w[lib/foo_bar.rb Rakefile] - foo_bar = quick_spec 'foo_bar' do |gem| + foo_bar = util_spec 'foo_bar' do |gem| gem.files = files end - bar_baz = quick_spec 'bar_baz' do |gem| + bar_baz = util_spec 'bar_baz' do |gem| gem.files = files end diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb index ff6e368414..6f9ec104a5 100644 --- a/test/rubygems/test_gem_commands_uninstall_command.rb +++ b/test/rubygems/test_gem_commands_uninstall_command.rb @@ -24,7 +24,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase gemhome2 = "#{@gemhome}2" - a_4 = quick_spec 'a', 4 + a_4 = util_spec 'a', 4 install_gem a_4, :install_dir => gemhome2 Gem::Specification.dirs = [@gemhome, gemhome2] @@ -126,7 +126,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase end def test_execute_prerelease - @spec = quick_spec "pre", "2.b" + @spec = util_spec "pre", "2.b" @gem = File.join @tempdir, @spec.file_name FileUtils.touch @gem @@ -213,7 +213,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase gemhome2 = "#{@gemhome}2" - a_4 = quick_spec 'a', 4 + a_4 = util_spec 'a', 4 install_gem a_4, :install_dir => gemhome2 Gem::Specification.dirs = [@gemhome, gemhome2] diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb index 183a7e67c0..59f6cc6c74 100644 --- a/test/rubygems/test_gem_commands_unpack_command.rb +++ b/test/rubygems/test_gem_commands_unpack_command.rb @@ -22,31 +22,22 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_get_path - util_setup_fake_fetcher - util_clear_gems - util_setup_spec_fetcher @a1 - - a1_data = nil - - open @a1.cache_file, 'rb' do |fp| - a1_data = fp.read + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 end - Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] = - a1_data - - dep = Gem::Dependency.new(@a1.name, @a1.version) + dep = Gem::Dependency.new 'a', 1 assert_equal( @cmd.get_path(dep), - @a1.cache_file, + specs['a-1'].cache_file, 'fetches a-1 and returns the cache path' ) - FileUtils.rm @a1.cache_file + FileUtils.rm specs['a-1'].cache_file assert_equal( @cmd.get_path(dep), - @a1.cache_file, + specs['a-1'].cache_file, 'when removed from cache, refetches a-1' ) end @@ -67,8 +58,9 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_gem_path - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher do |fetcher| + fetcher.gem 'a', '3.a' + end Gem.clear_paths @@ -88,8 +80,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_gem_path_missing - util_setup_fake_fetcher - util_setup_spec_fetcher + spec_fetcher Gem.clear_paths @@ -109,18 +100,13 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_remote - util_setup_fake_fetcher - util_setup_spec_fetcher @a1, @a2 - util_clear_gems + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.gem 'a', 2 - a2_data = nil - open @a2.cache_file, 'rb' do |fp| - a2_data = fp.read + fetcher.clear end - Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] = - a2_data - Gem.configuration.verbose = :really @cmd.options[:args] = %w[a] @@ -186,8 +172,8 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_exact_match - foo_spec = quick_spec 'foo' - foo_bar_spec = quick_spec 'foo_bar' + foo_spec = util_spec 'foo' + foo_bar_spec = util_spec 'foo_bar' use_ui @ui do Dir.chdir @tempdir do diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 01e95cbbb4..7537c1c9c1 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -17,26 +17,27 @@ class TestGemCommandsUpdateCommand < Gem::TestCase @cmd.options[:document] = [] - util_setup_fake_fetcher(true) - util_clear_gems - util_setup_spec_fetcher @a1, @a2, @a3a - - @a1_path = @a1.cache_file - @a2_path = @a2.cache_file - @a3a_path = @a3a.cache_file - - @fetcher.data["#{@gem_repo}gems/#{File.basename @a1_path}"] = - read_binary @a1_path - @fetcher.data["#{@gem_repo}gems/#{File.basename @a2_path}"] = - read_binary @a2_path - @fetcher.data["#{@gem_repo}gems/#{File.basename @a3a_path}"] = - read_binary @a3a_path + @specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + fetcher.gem 'a', '3.a' + + fetcher.clear + end + + @a1_path = @specs['a-1'].cache_file + @a2_path = @specs['a-1'].cache_file + @a3a_path = @specs['a-3.a'].cache_file end def test_execute - util_clear_gems + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + + fetcher.clear - Gem::Installer.new(@a1_path).install + fetcher.spec 'a', 1 + end @cmd.options[:args] = [] @@ -46,48 +47,17 @@ class TestGemCommandsUpdateCommand < Gem::TestCase out = @ui.output.split "\n" assert_equal "Updating installed gems", out.shift - assert_equal "Updating #{@a2.name}", out.shift - assert_equal "Gems updated: #{@a2.name}", out.shift + assert_equal "Updating a", out.shift + assert_equal "Gems updated: a", out.shift assert_empty out end - def util_setup_rubygem version - gem = quick_spec('rubygems-update', version.to_s) do |s| - s.files = %w[setup.rb] - end - write_file File.join(*%W[gems #{gem.original_name} setup.rb]) - util_build_gem gem - util_setup_spec_fetcher gem - gem - end - - def util_setup_rubygem8 - @rubygem8 = util_setup_rubygem 8 - end - - def util_setup_rubygem9 - @rubygem9 = util_setup_rubygem 9 - end - - def util_setup_rubygem_current - @rubygem_current = util_setup_rubygem Gem::VERSION - end - - def util_add_to_fetcher *specs - specs.each do |spec| - gem_file = spec.cache_file - file_name = File.basename gem_file + def test_execute_system + spec_fetcher do |fetcher| + fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end - @fetcher.data["http://gems.example.com/gems/#{file_name}"] = - Gem.read_binary gem_file + fetcher.clear end - end - - def test_execute_system - util_clear_gems - util_setup_rubygem9 - util_setup_spec_fetcher @rubygem9 - util_add_to_fetcher @rubygem9 @cmd.options[:args] = [] @cmd.options[:system] = true @@ -105,10 +75,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_system_at_latest - util_clear_gems - util_setup_rubygem_current - util_setup_spec_fetcher @rubygem_current - util_add_to_fetcher @rubygem_current + spec_fetcher do |fetcher| + fetcher.gem 'rubygems-update', Gem::VERSION do |s| + s.files = %w[setup.rb] + end + + fetcher.clear + end @cmd.options[:args] = [] @cmd.options[:system] = true @@ -125,11 +98,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_system_multiple - util_clear_gems - util_setup_rubygem9 - util_setup_rubygem8 - util_setup_spec_fetcher @rubygem8, @rubygem9 - util_add_to_fetcher @rubygem8, @rubygem9 + spec_fetcher do |fetcher| + fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end + fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end + + fetcher.clear + end @cmd.options[:args] = [] @cmd.options[:system] = true @@ -147,11 +121,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_system_specific - util_clear_gems - util_setup_rubygem9 - util_setup_rubygem8 - util_setup_spec_fetcher @rubygem8, @rubygem9 - util_add_to_fetcher @rubygem8, @rubygem9 + spec_fetcher do |fetcher| + fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end + fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end + + fetcher.clear + end @cmd.options[:args] = [] @cmd.options[:system] = "8" @@ -169,11 +144,12 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_system_specifically_to_latest_version - util_clear_gems - util_setup_rubygem9 - util_setup_rubygem8 - util_setup_spec_fetcher @rubygem8, @rubygem9 - util_add_to_fetcher @rubygem8, @rubygem9 + spec_fetcher do |fetcher| + fetcher.gem 'rubygems-update', 8 do |s| s.files = %w[setup.rb] end + fetcher.gem 'rubygems-update', 9 do |s| s.files = %w[setup.rb] end + + fetcher.clear + end @cmd.options[:args] = [] @cmd.options[:system] = "9" @@ -212,36 +188,16 @@ class TestGemCommandsUpdateCommand < Gem::TestCase # a2 -> c2 def test_execute_dependencies - @a1.add_dependency 'c', '1.2' - - @c2 = quick_spec 'c', '2' do |s| - s.files = %w[lib/code.rb] - s.require_paths = %w[lib] - end + spec_fetcher do |fetcher| + fetcher.gem 'a', 2, 'b' => 2, 'c' => 2 + fetcher.gem 'b', 2 + fetcher.gem 'c', 2 - @a2.add_dependency 'c', '2' - @a2.add_dependency 'b', '2' + fetcher.clear - @b2_path = @b2.cache_file - @c1_2_path = @c1_2.cache_file - @c2_path = @c2.cache_file - - install_specs @a1, @a2, @b2, @c1_2, @c2 - - util_build_gem @a1 - util_build_gem @a2 - util_build_gem @c2 - - @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path - @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path - @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path - @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] = read_binary @c1_2_path - @fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path - - util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2 - - Gem::Installer.new(@c1_2_path).install - Gem::Installer.new(@a1_path).install + fetcher.spec 'a', 1, 'c' => '1.2' + fetcher.spec 'c', '1.2' + end Gem::Specification.reset @@ -253,23 +209,27 @@ class TestGemCommandsUpdateCommand < Gem::TestCase out = @ui.output.split "\n" assert_equal "Updating installed gems", out.shift - assert_equal "Updating #{@a2.name}", out.shift - assert_equal "Gems updated: #{@a2.name} #{@b2.name} #{@c2.name}", + assert_equal "Updating a", out.shift + assert_equal "Gems updated: a b c", out.shift assert_empty out end def test_execute_rdoc - Gem.done_installing(&Gem::RDoc.method(:generation_hook)) + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 - @cmd.options[:document] = %w[rdoc ri] + fetcher.clear - util_clear_gems + fetcher.spec 'a', 1 + end - Gem::Installer.new(@a1_path).install + Gem.done_installing(&Gem::RDoc.method(:generation_hook)) - @cmd.options[:args] = [@a1.name] + @cmd.options[:document] = %w[rdoc ri] + + @cmd.options[:args] = %w[a] use_ui @ui do @cmd.execute @@ -277,16 +237,22 @@ class TestGemCommandsUpdateCommand < Gem::TestCase wait_for_child_process_to_exit - assert_path_exists File.join(@a2.doc_dir, 'ri') - assert_path_exists File.join(@a2.doc_dir, 'rdoc') + a2 = @specs['a-2'] + + assert_path_exists File.join(a2.doc_dir, 'ri') + assert_path_exists File.join(a2.doc_dir, 'rdoc') end def test_execute_named - util_clear_gems + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + + fetcher.clear - Gem::Installer.new(@a1_path).install + fetcher.spec 'a', 1 + end - @cmd.options[:args] = [@a1.name] + @cmd.options[:args] = %w[a] use_ui @ui do @cmd.execute @@ -294,18 +260,18 @@ class TestGemCommandsUpdateCommand < Gem::TestCase out = @ui.output.split "\n" assert_equal "Updating installed gems", out.shift - assert_equal "Updating #{@a2.name}", out.shift - assert_equal "Gems updated: #{@a2.name}", out.shift + assert_equal "Updating a", out.shift + assert_equal "Gems updated: a", out.shift assert_empty out end def test_execute_named_up_to_date - util_clear_gems - - Gem::Installer.new(@a2_path).install + spec_fetcher do |fetcher| + fetcher.spec 'a', 2 + end - @cmd.options[:args] = [@a2.name] + @cmd.options[:args] = %w[a] use_ui @ui do @cmd.execute @@ -319,11 +285,15 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_named_up_to_date_prerelease - util_clear_gems + spec_fetcher do |fetcher| + fetcher.gem 'a', '3.a' - Gem::Installer.new(@a2_path).install + fetcher.clear - @cmd.options[:args] = [@a2.name] + fetcher.gem 'a', 2 + end + + @cmd.options[:args] = %w[a] @cmd.options[:prerelease] = true use_ui @ui do @@ -332,16 +302,16 @@ class TestGemCommandsUpdateCommand < Gem::TestCase out = @ui.output.split "\n" assert_equal "Updating installed gems", out.shift - assert_equal "Updating #{@a3a.name}", out.shift - assert_equal "Gems updated: #{@a3a.name}", out.shift + assert_equal "Updating a", out.shift + assert_equal "Gems updated: a", out.shift assert_empty out end def test_execute_up_to_date - util_clear_gems - - Gem::Installer.new(@a2_path).install + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 + end @cmd.options[:args] = [] @@ -357,9 +327,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_user_install - util_clear_gems + spec_fetcher do |fetcher| + fetcher.gem 'a', 2 - Gem::Installer.new(@a1_path).install + fetcher.clear + + fetcher.spec 'a', 1 + end @cmd.handle_options %w[--user-install] @@ -374,37 +348,51 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_fetch_remote_gems + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + end + expected = [ [Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(@a1) + assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) end def test_fetch_remote_gems_error Gem.sources.replace %w[http://nonexistent.example] assert_raises Gem::RemoteFetcher::FetchError do - @cmd.fetch_remote_gems @a1 + @cmd.fetch_remote_gems @specs['a-1'] end end def test_fetch_remote_gems_mismatch platform = Gem::Platform.new 'x86-freebsd9' - a2_p = quick_spec 'a', 2 do |s| s.platform = platform end - util_setup_spec_fetcher @a2, a2_p + specs = spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'a', 2 do |s| s.platform = platform end + end expected = [ [Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY), Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(@a1) + assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) end def test_fetch_remote_gems_prerelease + specs = spec_fetcher do |fetcher| + fetcher.gem 'a', 1 + fetcher.gem 'a', 2 + fetcher.gem 'a', '3.a' + end + @cmd.options[:prerelease] = true expected = [ @@ -414,7 +402,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase Gem::Source.new(@gem_repo)], ] - assert_equal expected, @cmd.fetch_remote_gems(@a1) + assert_equal expected, @cmd.fetch_remote_gems(specs['a-1']) end def test_handle_options_system diff --git a/test/rubygems/test_gem_commands_which_command.rb b/test/rubygems/test_gem_commands_which_command.rb index bf7be639c8..b19f204c4a 100644 --- a/test/rubygems/test_gem_commands_which_command.rb +++ b/test/rubygems/test_gem_commands_which_command.rb @@ -68,7 +68,7 @@ class TestGemCommandsWhichCommand < Gem::TestCase def util_foo_bar files = %w[lib/foo_bar.rb lib/directory/baz.rb Rakefile] - @foo_bar = quick_spec 'foo_bar' do |gem| + @foo_bar = util_spec 'foo_bar' do |gem| gem.files = files end diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb index 478481b88c..d25359e84b 100644 --- a/test/rubygems/test_gem_dependency_list.rb +++ b/test/rubygems/test_gem_dependency_list.rb @@ -11,17 +11,17 @@ class TestGemDependencyList < Gem::TestCase @deplist = Gem::DependencyList.new # TODO: switch to new_spec - @a1 = quick_spec 'a', '1' - @a2 = quick_spec 'a', '2' - @a3 = quick_spec 'a', '3' + @a1 = util_spec 'a', '1' + @a2 = util_spec 'a', '2' + @a3 = util_spec 'a', '3' - @b1 = quick_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end - @b2 = quick_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end + @b1 = util_spec 'b', '1' do |s| s.add_dependency 'a', '>= 1' end + @b2 = util_spec 'b', '2' do |s| s.add_dependency 'a', '>= 1' end - @c1 = quick_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end - @c2 = quick_spec 'c', '2' + @c1 = util_spec 'c', '1' do |s| s.add_dependency 'b', '>= 1' end + @c2 = util_spec 'c', '2' - @d1 = quick_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end + @d1 = util_spec 'd', '1' do |s| s.add_dependency 'c', '>= 1' end end def test_active_count @@ -57,9 +57,9 @@ class TestGemDependencyList < Gem::TestCase end def test_dependency_order_development - e1 = quick_spec 'e', '1' - f1 = quick_spec 'f', '1' - g1 = quick_spec 'g', '1' + e1 = util_spec 'e', '1' + f1 = util_spec 'f', '1' + g1 = util_spec 'g', '1' @a1.add_dependency 'e' @a1.add_dependency 'f' @@ -85,7 +85,7 @@ class TestGemDependencyList < Gem::TestCase def test_dependency_order_diamond util_diamond - e1 = quick_spec 'e', '1' + e1 = util_spec 'e', '1' @deplist.add e1 @a1.add_dependency 'e', '>= 1' @@ -161,13 +161,13 @@ class TestGemDependencyList < Gem::TestCase end def test_ok_eh_mismatch - a1 = quick_spec 'a', '1' - a2 = quick_spec 'a', '2' + a1 = util_spec 'a', '1' + a2 = util_spec 'a', '2' - b = quick_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end - c = quick_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end + b = util_spec 'b', '1' do |s| s.add_dependency 'a', '= 1' end + c = util_spec 'c', '1' do |s| s.add_dependency 'a', '= 2' end - d = quick_spec 'd', '1' do |s| + d = util_spec 'd', '1' do |s| s.add_dependency 'b' s.add_dependency 'c' end diff --git a/test/rubygems/test_gem_dependency_resolution_error.rb b/test/rubygems/test_gem_dependency_resolution_error.rb index 7f8cf0c5cc..0ac0b06028 100644 --- a/test/rubygems/test_gem_dependency_resolution_error.rb +++ b/test/rubygems/test_gem_dependency_resolution_error.rb @@ -7,7 +7,7 @@ class TestGemDependencyResolutionError < Gem::TestCase @DR = Gem::DependencyResolver - @spec = quick_spec 'a', 2 + @spec = util_spec 'a', 2 @a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil @a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil diff --git a/test/rubygems/test_gem_dependency_resolver.rb b/test/rubygems/test_gem_dependency_resolver.rb index 7d968494b8..ceecab6d55 100644 --- a/test/rubygems/test_gem_dependency_resolver.rb +++ b/test/rubygems/test_gem_dependency_resolver.rb @@ -510,9 +510,9 @@ class TestGemDependencyResolver < Gem::TestCase def test_select_local_platforms r = Gem::DependencyResolver.new nil, nil - a1 = quick_spec 'a', 1 - a1_p1 = quick_spec 'a', 1 do |s| s.platform = Gem::Platform.local end - a1_p2 = quick_spec 'a', 1 do |s| s.platform = 'unknown' end + a1 = util_spec 'a', 1 + a1_p1 = util_spec 'a', 1 do |s| s.platform = Gem::Platform.local end + a1_p2 = util_spec 'a', 1 do |s| s.platform = 'unknown' end selected = r.select_local_platforms [a1, a1_p1, a1_p2] diff --git a/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb b/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb index 964997568a..68e17f8a98 100644 --- a/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +++ b/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb @@ -23,7 +23,7 @@ class TestGemDependencyResolverDependencyConflict < Gem::TestCase def test_explanation_user_request @DR = Gem::DependencyResolver - spec = quick_spec 'a', 2 + spec = util_spec 'a', 2 a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil diff --git a/test/rubygems/test_gem_dependency_resolver_index_specification.rb b/test/rubygems/test_gem_dependency_resolver_index_specification.rb index c8e02ff62d..751ed34db3 100644 --- a/test/rubygems/test_gem_dependency_resolver_index_specification.rb +++ b/test/rubygems/test_gem_dependency_resolver_index_specification.rb @@ -31,11 +31,9 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase end def test_spec - a_2_p = nil - - spec_fetcher do |fetcher| + specs = spec_fetcher do |fetcher| fetcher.spec 'a', 2 - a_2_p = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end + fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end end source = Gem::Source.new @gem_repo @@ -47,11 +45,11 @@ class TestGemDependencyResolverIndexSpecification < Gem::TestCase spec = i_spec.spec - assert_equal a_2_p.full_name, spec.full_name + assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name end def test_spec_local - a_2_p = quick_spec 'a', 2 do |s| s.platform = Gem::Platform.local end + a_2_p = util_spec 'a', 2 do |s| s.platform = Gem::Platform.local end Gem::Package.build a_2_p source = Gem::Source::Local.new diff --git a/test/rubygems/test_gem_dependency_resolver_installed_specification.rb b/test/rubygems/test_gem_dependency_resolver_installed_specification.rb index 6586ca4654..e1f4262e4b 100644 --- a/test/rubygems/test_gem_dependency_resolver_installed_specification.rb +++ b/test/rubygems/test_gem_dependency_resolver_installed_specification.rb @@ -6,7 +6,7 @@ class TestGemDependencyResolverInstalledSpecification < Gem::TestCase def test_initialize set = Gem::DependencyResolver::CurrentSet.new - source_spec = quick_spec 'a' + source_spec = util_spec 'a' spec = Gem::DependencyResolver::InstalledSpecification.new set, source_spec diff --git a/test/rubygems/test_gem_dependency_resolver_installer_set.rb b/test/rubygems/test_gem_dependency_resolver_installer_set.rb index 516a4d03fe..6341c6bc73 100644 --- a/test/rubygems/test_gem_dependency_resolver_installer_set.rb +++ b/test/rubygems/test_gem_dependency_resolver_installer_set.rb @@ -4,11 +4,9 @@ require 'rubygems/dependency_resolver' class TestGemDependencyResolverInstallerSet < Gem::TestCase def test_load_spec - a_2_p = nil - - spec_fetcher do |fetcher| + specs = spec_fetcher do |fetcher| fetcher.spec 'a', 2 - a_2_p = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end + fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end end source = Gem::Source.new @gem_repo @@ -18,7 +16,7 @@ class TestGemDependencyResolverInstallerSet < Gem::TestCase spec = set.load_spec 'a', version, Gem::Platform.local, source - assert_equal a_2_p.full_name, spec.full_name + assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name end end diff --git a/test/rubygems/test_gem_doctor.rb b/test/rubygems/test_gem_doctor.rb index 0dce8c2eac..f4d4659c02 100644 --- a/test/rubygems/test_gem_doctor.rb +++ b/test/rubygems/test_gem_doctor.rb @@ -157,7 +157,7 @@ This directory does not appear to be a RubyGems repository, skipping refute doctor.gem_repository?, 'no gems installed' - quick_spec 'a' + util_spec 'a' doctor = Gem::Doctor.new @gemhome diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index aa8eeac2ba..d7e5880a96 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -15,7 +15,7 @@ class TestGemExtBuilder < Gem::TestCase @orig_DESTDIR = ENV['DESTDIR'] - @spec = quick_spec 'a' + @spec = util_spec 'a' @builder = Gem::Ext::Builder.new @spec, '' end diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb index ea2be55653..5ce0788c08 100644 --- a/test/rubygems/test_gem_indexer.rb +++ b/test/rubygems/test_gem_indexer.rb @@ -13,15 +13,15 @@ class TestGemIndexer < Gem::TestCase util_clear_gems util_make_gems - @d2_0 = quick_spec 'd', '2.0' do |s| + @d2_0 = util_spec 'd', '2.0' do |s| s.date = Gem::Specification::TODAY - 86400 * 3 end util_build_gem @d2_0 - @d2_0_a = quick_spec 'd', '2.0.a' + @d2_0_a = util_spec 'd', '2.0.a' util_build_gem @d2_0_a - @d2_0_b = quick_spec 'd', '2.0.b' + @d2_0_b = util_spec 'd', '2.0.b' util_build_gem @d2_0_b @default = new_default_spec 'default', 2 @@ -292,7 +292,7 @@ class TestGemIndexer < Gem::TestCase def with_system_gems Gem::Specification.reset - sys_gem = quick_spec 'systemgem', '1.0' + sys_gem = util_spec 'systemgem', '1.0' util_build_gem sys_gem Gem::Specification.add_spec sys_gem yield @@ -311,11 +311,11 @@ class TestGemIndexer < Gem::TestCase assert File.directory?(quickdir) assert File.directory?(marshal_quickdir) - @d2_1 = quick_spec 'd', '2.1' + @d2_1 = util_spec 'd', '2.1' util_build_gem @d2_1 @d2_1_tuple = [@d2_1.name, @d2_1.version, @d2_1.original_platform] - @d2_1_a = quick_spec 'd', '2.2.a' + @d2_1_a = util_spec 'd', '2.2.a' util_build_gem @d2_1_a @d2_1_a_tuple = [@d2_1_a.name, @d2_1_a.version, @d2_1_a.original_platform] diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 7ce00f0121..0abb58b655 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -185,7 +185,7 @@ gem 'other', version end unless Gem.win_platform? def test_ensure_dependency - quick_spec 'a' + util_spec 'a' dep = Gem::Dependency.new 'a', '>= 2' assert @installer.ensure_dependency(@spec, dep) @@ -606,7 +606,7 @@ gem 'other', version end def test_initialize - spec = quick_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end + spec = util_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end gem = File.join @tempdir, spec.file_name Dir.mkdir util_inst_bindir @@ -1044,7 +1044,7 @@ gem 'other', version end def test_installation_satisfies_dependency_eh - quick_spec 'a' + util_spec 'a' dep = Gem::Dependency.new 'a', '>= 2' assert @installer.installation_satisfies_dependency?(dep) @@ -1113,7 +1113,7 @@ gem 'other', version end def test_pre_install_checks_wrong_rubygems_version - spec = quick_spec 'old_rubygems_required', '1' do |s| + spec = util_spec 'old_rubygems_required', '1' do |s| s.required_rubygems_version = '< 0' end @@ -1400,7 +1400,7 @@ gem 'other', version end def old_ruby_required - spec = quick_spec 'old_ruby_required', '1' do |s| + spec = util_spec 'old_ruby_required', '1' do |s| s.required_ruby_version = '= 1.4.6' end @@ -1410,7 +1410,7 @@ gem 'other', version end def util_execless - @spec = quick_spec 'z' + @spec = util_spec 'z' util_build_gem @spec @installer = util_installer @spec, @gemhome diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb index 90142efb8f..2b4ca806da 100644 --- a/test/rubygems/test_gem_local_remote_options.rb +++ b/test/rubygems/test_gem_local_remote_options.rb @@ -40,7 +40,7 @@ class TestGemLocalRemoteOptions < Gem::TestCase end def test_clear_sources_option_idiot_proof - util_setup_fake_fetcher + spec_fetcher @cmd.add_local_remote_options @cmd.handle_options %W[--clear-sources] diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb index 0285a2fede..3ff06fe0d5 100644 --- a/test/rubygems/test_gem_rdoc.rb +++ b/test/rubygems/test_gem_rdoc.rb @@ -9,7 +9,7 @@ class TestGemRDoc < Gem::TestCase def setup super - @a = quick_spec 'a' do |s| + @a = util_spec 'a' do |s| s.rdoc_options = %w[--main MyTitle] s.extra_rdoc_files = %w[README] end diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index 4aaa15ac68..9b215c2bc7 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -160,6 +160,37 @@ class TestGemRequestSet < Gem::TestCase assert_equal %w!c-2 b-2 a-2!, names end + def test_install + spec_fetcher do |fetcher| + fetcher.gem "a", "1", "b" => "= 1" + fetcher.gem "b", "1" + + fetcher.clear + end + + rs = Gem::RequestSet.new + rs.gem 'a' + + rs.resolve + + reqs = [] + installers = [] + + installed = rs.install({}) do |req, installer| + reqs << req + installers << installer + end + + assert_equal %w[b-1 a-1], reqs.map { |req| req.full_name } + assert_equal %w[b-1 a-1], + installers.map { |installer| installer.spec.full_name } + + assert_path_exists File.join @gemhome, 'specifications', 'a-1.gemspec' + assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec' + + assert_equal %w[b-1 a-1], installed.map { |s| s.full_name } + end + def test_install_into spec_fetcher do |fetcher| fetcher.gem "a", "1", "b" => "= 1" @@ -173,8 +204,8 @@ class TestGemRequestSet < Gem::TestCase installed = rs.install_into @tempdir - assert File.exists?(File.join(@tempdir, "specifications", "a-1.gemspec")) - assert File.exists?(File.join(@tempdir, "specifications", "b-1.gemspec")) + assert_path_exists File.join @tempdir, 'specifications', 'a-1.gemspec' + assert_path_exists File.join @tempdir, 'specifications', 'b-1.gemspec' assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name } end diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb index 367f3ba20a..154449dde2 100644 --- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb +++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb @@ -89,11 +89,15 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase end def test_gem_platforms + win_platform, Gem.win_platform = Gem.win_platform?, false + with_engine_version 'ruby', '2.0.0' do @gda.gem 'a', :platforms => :ruby refute_empty @set.dependencies end + ensure + Gem.win_platform = win_platform end def test_gem_platforms_bundler_ruby @@ -145,6 +149,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase end def test_gem_platforms_maglev + win_platform, Gem.win_platform = Gem.win_platform?, false + with_engine_version 'maglev', '1.0.0' do set = Gem::RequestSet.new gda = @GDA.new set, 'gem.deps.rb' @@ -158,6 +164,8 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase refute_empty set.dependencies end + ensure + Gem.win_platform = win_platform end def test_gem_platforms_multiple @@ -308,19 +316,35 @@ end end def test_platform_mswin + win_platform, Gem.win_platform = Gem.win_platform?, false + @gda.platform :mswin do @gda.gem 'a' end assert_empty @set.dependencies + + Gem.win_platform = true + + @gda.platform :mswin do + @gda.gem 'a' + end + + refute_empty @set.dependencies + ensure + Gem.win_platform = win_platform end def test_platform_ruby + win_platform, Gem.win_platform = Gem.win_platform?, false + @gda.platform :ruby do @gda.gem 'a' end assert_equal [dep('a')], @set.dependencies + ensure + Gem.win_platform = win_platform end def test_platforms diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb index bf30399db2..b55b019268 100644 --- a/test/rubygems/test_gem_server.rb +++ b/test/rubygems/test_gem_server.rb @@ -89,7 +89,7 @@ class TestGemServer < Gem::TestCase data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" dir = "#{@gemhome}2" - spec = quick_spec 'z', 9 + spec = util_spec 'z', 9 specs_dir = File.join dir, 'specifications' FileUtils.mkdir_p specs_dir @@ -156,7 +156,7 @@ class TestGemServer < Gem::TestCase assert_equal 404, @res.status - spec = quick_spec 'z', 9 + spec = util_spec 'z', 9 specs_dir = File.join dir, 'specifications' @@ -249,7 +249,7 @@ class TestGemServer < Gem::TestCase data = StringIO.new "GET / HTTP/1.0\r\n\r\n" dir = "#{@gemhome}2" - spec = quick_spec 'z', 9 + spec = util_spec 'z', 9 specs_dir = File.join dir, 'specifications' FileUtils.mkdir_p specs_dir @@ -287,7 +287,7 @@ class TestGemServer < Gem::TestCase data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" dir = "#{@gemhome}2" - spec = quick_spec 'z', 9 + spec = util_spec 'z', 9 specs_dir = File.join dir, 'specifications' FileUtils.mkdir_p specs_dir diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index ed981cbc09..3ed40a625a 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -10,43 +10,14 @@ class TestGemSource < Gem::TestCase def setup super - util_setup_fake_fetcher - - @a_pre = new_spec 'a', '1.a' - - install_specs @a_pre + @specs = spec_fetcher do |fetcher| + fetcher.spec 'a', '1.a' + fetcher.gem 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'b', 2 + end @source = Gem::Source.new(@gem_repo) - - Gem::Specification.remove_spec @b2 - - all = Gem::Specification.map { |spec| - Gem::NameTuple.new(spec.name, spec.version, spec.original_platform) - }.sort - - @prerelease_specs, @specs = all.partition { |g| g.prerelease? } - - # TODO: couldn't all of this come from the fake spec fetcher? - @latest_specs = Gem::Specification.latest_specs.sort.map { |spec| - Gem::NameTuple.new(spec.name, spec.version, spec.original_platform) - } - - v = Gem.marshal_version - s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs))) - l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs))) - p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs))) - @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip - @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip - @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip - - @released = Gem::NameTuple.from_list \ - [["a", Gem::Version.new("1"), "ruby"], - ["a", Gem::Version.new("2"), "ruby"], - ["a_evil", Gem::Version.new("9"), "ruby"], - ["c", Gem::Version.new("1.2"), "ruby"], - ['dep_x', Gem::Version.new(1), 'ruby'], - ["pl", Gem::Version.new("1"), "i386-linux"], - ['x', Gem::Version.new(1), 'ruby']] end def test_api_uri @@ -83,59 +54,60 @@ class TestGemSource < Gem::TestCase end def test_fetch_spec - spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}" - @fetcher.data["#{spec_uri}.rz"] = util_zip(Marshal.dump(@a1)) + a1 = @specs['a-1'] + + spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}" spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby') - assert_equal @a1.full_name, spec.full_name + assert_equal a1.full_name, spec.full_name cache_dir = @source.cache_dir URI.parse(spec_uri) - cache_file = File.join cache_dir, @a1.spec_name + cache_file = File.join cache_dir, a1.spec_name assert File.exist?(cache_file) end def test_fetch_spec_cached - spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}" + a1 = @specs['a-1'] + + spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{a1.spec_name}" @fetcher.data["#{spec_uri}.rz"] = nil cache_dir = @source.cache_dir URI.parse(spec_uri) FileUtils.mkdir_p cache_dir - cache_file = File.join cache_dir, @a1.spec_name + cache_file = File.join cache_dir, a1.spec_name open cache_file, 'wb' do |io| - Marshal.dump @a1, io + Marshal.dump a1, io end spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby') - assert_equal @a1.full_name, spec.full_name + assert_equal a1.full_name, spec.full_name end def test_fetch_spec_platform - @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] = - util_zip(Marshal.dump(@pl1)) + specs = spec_fetcher do |fetcher| + fetcher.legacy_platform + end spec = @source.fetch_spec tuple('pl', Gem::Version.new(1), 'i386-linux') - assert_equal @pl1.full_name, spec.full_name + assert_equal specs['pl-1-x86-linux'].full_name, spec.full_name end def test_fetch_spec_platform_ruby - @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] = - util_zip(Marshal.dump(@a1)) - spec = @source.fetch_spec tuple('a', Gem::Version.new(1), nil) - assert_equal @a1.full_name, spec.full_name + assert_equal @specs['a-1'].full_name, spec.full_name spec = @source.fetch_spec tuple('a', Gem::Version.new(1), '') - assert_equal @a1.full_name, spec.full_name + assert_equal @specs['a-1'].full_name, spec.full_name end def test_load_specs - expected = @released - assert_equal expected, @source.load_specs(:released) + released = @source.load_specs(:released).map { |spec| spec.full_name } + assert_equal %W[a-2 a-1 b-2], released cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' assert File.exist?(cache_dir), "#{cache_dir} does not exist" @@ -145,12 +117,14 @@ class TestGemSource < Gem::TestCase end def test_load_specs_cached + latest_specs = @source.load_specs :latest + # Make sure the cached version is actually different: - @latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby') + latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby') @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] = - ' ' * Marshal.dump(@latest_specs).length + ' ' * Marshal.dump(latest_specs).length cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' @@ -159,20 +133,22 @@ class TestGemSource < Gem::TestCase cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" open cache_file, 'wb' do |io| - Marshal.dump @latest_specs, io + Marshal.dump latest_specs, io end - latest_specs = @source.load_specs :latest + cached_specs = @source.load_specs :latest - assert_equal @latest_specs, latest_specs + assert_equal latest_specs, cached_specs end def test_load_specs_cached_empty + latest_specs = @source.load_specs :latest + # Make sure the cached version is actually different: - @latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby') + latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby') # Setup valid data on the 'remote' @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = - util_gzip(Marshal.dump(@latest_specs)) + util_gzip(Marshal.dump(latest_specs)) cache_dir = File.join Gem.spec_cache_dir, 'gems.example.com%80' @@ -182,12 +158,12 @@ class TestGemSource < Gem::TestCase open cache_file, 'wb' do |io| # Setup invalid data in the cache: - io.write Marshal.dump(@latest_specs)[0, 10] + io.write Marshal.dump(latest_specs)[0, 10] end - latest_specs = @source.load_specs :latest + fixed_specs = @source.load_specs :latest - assert_equal @latest_specs, latest_specs + assert_equal latest_specs, fixed_specs end def test_load_specs_from_unavailable_uri @@ -200,7 +176,7 @@ class TestGemSource < Gem::TestCase def test_spaceship remote = @source - specific = Gem::Source::SpecificFile.new(@a1.cache_file) + specific = Gem::Source::SpecificFile.new @specs['a-1'].cache_file installed = Gem::Source::Installed.new local = Gem::Source::Local.new diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb index 54e6e4176f..6ee1a52fc7 100644 --- a/test/rubygems/test_gem_spec_fetcher.rb +++ b/test/rubygems/test_gem_spec_fetcher.rb @@ -13,43 +13,7 @@ class TestGemSpecFetcher < Gem::TestCase @uri = URI.parse @gem_repo @source = Gem::Source.new(@uri) - util_setup_fake_fetcher - - @a_pre = new_spec 'a', '1.a' - - install_specs @a_pre - - Gem::Specification.remove_spec @b2 - - all = Gem::Specification.map { |spec| - Gem::NameTuple.new(spec.name, spec.version, spec.original_platform) - }.sort - - @prerelease_specs, @specs = all.partition { |g| g.prerelease? } - - # TODO: couldn't all of this come from the fake spec fetcher? - @latest_specs = Gem::Specification.latest_specs.sort.map { |spec| - Gem::NameTuple.new(spec.name, spec.version, spec.original_platform) - } - - v = Gem.marshal_version - s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs))) - l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs))) - p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs))) - @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip - @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip - @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip - @sf = Gem::SpecFetcher.new - - @released = Gem::NameTuple.from_list \ - [["a", Gem::Version.new("1"), "ruby"], - ["a", Gem::Version.new("2"), "ruby"], - ["a_evil", Gem::Version.new("9"), "ruby"], - ["c", Gem::Version.new("1.2"), "ruby"], - ['dep_x', Gem::Version.new(1), 'ruby'], - ["pl", Gem::Version.new("1"), "i386-linux"], - ['x', Gem::Version.new(1), 'ruby']] end def test_initialize @@ -86,11 +50,12 @@ class TestGemSpecFetcher < Gem::TestCase end def test_spec_for_dependency_all - d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" - @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) - @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2)) - @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre)) - @fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a)) + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + end dep = Gem::Dependency.new 'a', ">= 1" @@ -100,7 +65,7 @@ class TestGemSpecFetcher < Gem::TestCase [spec.full_name, source_uri] end - expected = [[@a1.full_name, @source], [@a2.full_name, @source]] + expected = [['a-1', @source], ['a-2', @source]] assert_equal expected, spec_names @@ -108,10 +73,11 @@ class TestGemSpecFetcher < Gem::TestCase end def test_spec_for_dependency_latest - d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" - @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) - @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2)) - @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre)) + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + end dep = Gem::Dependency.new 'a' specs_and_sources, _ = @sf.spec_for_dependency dep @@ -120,14 +86,15 @@ class TestGemSpecFetcher < Gem::TestCase [spec.full_name, source_uri] end - assert_equal [[@a2.full_name, Gem::Source.new(@gem_repo)]], spec_names + assert_equal [['a-2', Gem::Source.new(@gem_repo)]], + spec_names end def test_spec_for_dependency_prerelease - d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" - @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) - @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2)) - @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre)) + spec_fetcher do |fetcher| + fetcher.spec 'a', '1.a' + fetcher.spec 'a', 1 + end specs_and_sources, _ = @sf.spec_for_dependency dep('a', '1.a') @@ -135,14 +102,15 @@ class TestGemSpecFetcher < Gem::TestCase [spec.full_name, source_uri] end - assert_equal [[@a_pre.full_name, Gem::Source.new(@gem_repo)]], spec_names + assert_equal [['a-1.a', Gem::Source.new(@gem_repo)]], spec_names end def test_spec_for_dependency_platform util_set_arch 'i386-linux' - @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] = - util_zip(Marshal.dump(@pl1)) + spec_fetcher do |fetcher| + fetcher.legacy_platform + end dep = Gem::Dependency.new 'pl', 1 specs_and_sources, _ = @sf.spec_for_dependency dep @@ -151,14 +119,16 @@ class TestGemSpecFetcher < Gem::TestCase [spec.full_name, source_uri] end - assert_equal [[@pl1.full_name, Gem::Source.new(@gem_repo)]], spec_names + assert_equal [['pl-1-x86-linux', Gem::Source.new(@gem_repo)]], + spec_names end def test_spec_for_dependency_mismatched_platform util_set_arch 'hrpa-989' - @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] = - util_zip(Marshal.dump(@pl1)) + spec_fetcher do |fetcher| + fetcher.legacy_platform + end dep = Gem::Dependency.new 'pl', 1 specs_and_sources, errors = @sf.spec_for_dependency dep @@ -179,11 +149,12 @@ class TestGemSpecFetcher < Gem::TestCase Gem.sources.replace [src] - d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" - @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) - @fetcher.data["#{d}#{@a2.spec_name}.rz"] = util_zip(Marshal.dump(@a2)) - @fetcher.data["#{d}#{@a_pre.spec_name}.rz"] = util_zip(Marshal.dump(@a_pre)) - @fetcher.data["#{d}#{@a3a.spec_name}.rz"] = util_zip(Marshal.dump(@a3a)) + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + end dep = Gem::Dependency.new 'a', ">= 1" @@ -198,31 +169,70 @@ class TestGemSpecFetcher < Gem::TestCase end def test_available_specs_latest + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', 2 + fetcher.spec 'a', '3.a' + fetcher.legacy_platform + end + specs, _ = @sf.available_specs(:latest) assert_equal [@source], specs.keys - assert_equal @latest_specs, specs[@source] + + expected = Gem::NameTuple.from_list \ + [['a', v(2), Gem::Platform::RUBY], + ['pl', v(1), 'i386-linux']] + + assert_equal expected, specs[@source] end def test_available_specs_released + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.legacy_platform + end + specs, _ = @sf.available_specs(:released) assert_equal [@source], specs.keys - assert_equal @released, specs[@source] + expected = Gem::NameTuple.from_list \ + [['a', v(1), Gem::Platform::RUBY], + ['pl', v(1), 'i386-linux']] + + assert_equal expected, specs[@source] end def test_available_specs_complete + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'b', 2 + fetcher.legacy_platform + end + specs, _ = @sf.available_specs(:complete) assert_equal [@source], specs.keys - expected = (@prerelease_specs + @released).sort + expected = Gem::NameTuple.from_list \ + [['a', v(1), Gem::Platform::RUBY], + ['a', v('2.a'), Gem::Platform::RUBY], + ['b', v(2), Gem::Platform::RUBY], + ['pl', v(1), 'i386-linux']] assert_equal expected, specs[@source] end def test_available_specs_complete_handles_no_prerelease + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'b', 2 + fetcher.legacy_platform + end + v = Gem.marshal_version @fetcher.data.delete "#{@gem_repo}prerelease_specs.#{v}.gz" @@ -230,10 +240,19 @@ class TestGemSpecFetcher < Gem::TestCase assert_equal [@source], specs.keys - assert_equal @released, specs[@source] + expected = Gem::NameTuple.from_list \ + [['a', v(1), Gem::Platform::RUBY], + ['b', v(2), Gem::Platform::RUBY], + ['pl', v(1), 'i386-linux']] + + assert_equal expected, specs[@source] end def test_available_specs_cache + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + specs, _ = @sf.available_specs(:latest) refute specs[@source].empty? @@ -246,6 +265,13 @@ class TestGemSpecFetcher < Gem::TestCase end def test_available_specs_cache_released + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + fetcher.spec 'b', 2 + fetcher.legacy_platform + end + specs, _ = @sf.available_specs(:released) refute specs[@source].empty? @@ -258,9 +284,17 @@ class TestGemSpecFetcher < Gem::TestCase end def test_available_specs_prerelease + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + fetcher.spec 'a', '2.a' + end + specs, _ = @sf.available_specs(:prerelease) - assert_equal @prerelease_specs, specs[@source] + expected = Gem::NameTuple.from_list \ + [['a', v('2.a'), Gem::Platform::RUBY]] + + assert_equal expected, specs[@source] end def test_available_specs_with_bad_source diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 231f10dbf1..75ea4092b7 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -41,7 +41,7 @@ end EOF def make_spec_c1 - @c1 = quick_spec 'a', '1' do |s| + @c1 = util_spec 'a', '1' do |s| s.executable = 'exec' s.extensions << 'ext/a/extconf.rb' s.test_file = 'test/suite.rb' @@ -59,7 +59,7 @@ end end def ext_spec - @ext = quick_spec 'ext', '1' do |s| + @ext = util_spec 'ext', '1' do |s| s.executable = 'exec' s.test_file = 'test/suite.rb' s.extensions = %w[ext/extconf.rb] @@ -74,7 +74,7 @@ end def setup super - @a1 = quick_spec 'a', '1' do |s| + @a1 = util_spec 'a', '1' do |s| s.executable = 'exec' s.test_file = 'test/suite.rb' s.requirements << 'A working computer' @@ -85,11 +85,11 @@ end s.files = %w[lib/code.rb] end - @a2 = quick_spec 'a', '2' do |s| + @a2 = util_spec 'a', '2' do |s| s.files = %w[lib/code.rb] end - @a3 = quick_spec 'a', '3' do |s| + @a3 = util_spec 'a', '3' do |s| s.metadata['allowed_push_host'] = "https://privategemserver.com" end @@ -840,37 +840,34 @@ dependencies: [] end def test_self_outdated - util_clear_gems - util_setup_fake_fetcher true + spec_fetcher do |fetcher| + fetcher.spec 'a', 4 - a4 = quick_gem @a1.name, '4' - util_build_gem a4 - util_setup_spec_fetcher @a1, @a2, @a3a, a4 + fetcher.clear - Gem::Specification.remove_spec @a1 - Gem::Specification.remove_spec @a2 - Gem::Specification.remove_spec a4 + fetcher.spec 'a', 3 + end assert_equal %w[a], Gem::Specification.outdated end def test_self_outdated_and_latest_remotes - util_clear_gems - util_setup_fake_fetcher true + specs = spec_fetcher do |fetcher| + fetcher.spec 'a', 4 + fetcher.spec 'b', 3 - a4 = quick_gem @a1.name, '4' - util_build_gem a4 - b3 = quick_gem @b2.name, '3' - util_build_gem b3 - util_setup_spec_fetcher @a1, @a2, @a3a, a4, @b2, b3 + fetcher.clear - Gem::Specification.remove_spec @a1 - Gem::Specification.remove_spec @a2 - Gem::Specification.remove_spec a4 - Gem::Specification.remove_spec b3 + fetcher.spec 'a', '3.a' + fetcher.spec 'b', 2 + end - assert_equal [[@a3a, a4.version], [@b2, b3.version]], - Gem::Specification.outdated_and_latest_version.to_a + expected = [ + [specs['a-3.a'], v(4)], + [specs['b-2'], v(3)], + ] + + assert_equal expected, Gem::Specification.outdated_and_latest_version.to_a end def test_self_remove_spec @@ -1062,7 +1059,7 @@ dependencies: [] end def test_add_dependency_with_type - gem = quick_spec "awesome", "1.0" do |awesome| + gem = util_spec "awesome", "1.0" do |awesome| awesome.add_dependency true awesome.add_dependency :gem_name end @@ -1071,7 +1068,7 @@ dependencies: [] end def test_add_dependency_with_type_explicit - gem = quick_spec "awesome", "1.0" do |awesome| + gem = util_spec "awesome", "1.0" do |awesome| awesome.add_development_dependency "monkey" end @@ -1370,7 +1367,7 @@ dependencies: [] assert_empty @gem.dependent_gems - bonobo = quick_spec 'bonobo' + bonobo = util_spec 'bonobo' expected = [ [@gem, @bonobo, [bonobo]], @@ -1719,7 +1716,7 @@ dependencies: [] end def test_prerelease_spec_adds_required_rubygems_version - @prerelease = quick_spec('tardis', '2.2.0.a') + @prerelease = util_spec('tardis', '2.2.0.a') refute @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.3.1')) assert @prerelease.required_rubygems_version.satisfied_by?(Gem::Version.new('1.4.0')) end @@ -2649,48 +2646,30 @@ WARNING: licenses is empty. Use a license abbreviation from: # KEEP a-3-x86-other_platform-1 def test_latest_specs - util_clear_gems - util_setup_fake_fetcher - - quick_spec 'p', '1' - - p1_curr = quick_spec 'p', '1' do |spec| - spec.platform = Gem::Platform::CURRENT - end - - quick_spec @a1.name, @a1.version do |s| - s.platform = Gem::Platform.new 'x86-my_platform1' - end + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 do |s| + s.platform = Gem::Platform.new 'x86-my_platform1' + end - quick_spec @a1.name, @a1.version do |s| - s.platform = Gem::Platform.new 'x86-third_platform1' - end + fetcher.spec 'a', 2 - quick_spec @a2.name, @a2.version do |s| - s.platform = Gem::Platform.new 'x86-my_platform1' - end + fetcher.spec 'a', 2 do |s| + s.platform = Gem::Platform.new 'x86-my_platform1' + end - quick_spec @a2.name, @a2.version do |s| - s.platform = Gem::Platform.new 'x86-other_platform1' - end + fetcher.spec 'a', 2 do |s| + s.platform = Gem::Platform.new 'x86-other_platform1' + end - quick_spec @a2.name, @a2.version.bump do |s| - s.platform = Gem::Platform.new 'x86-other_platform1' + fetcher.spec 'a', 3 do |s| + s.platform = Gem::Platform.new 'x86-other_platform1' + end end - Gem::Specification.remove_spec @b2 - Gem::Specification.remove_spec @pl1 - expected = %W[ a-2 a-2-x86-my_platform-1 a-3-x86-other_platform-1 - a_evil-9 - c-1.2 - dep_x-1 - p-1 - #{p1_curr.full_name} - x-1 ] latest_specs = Gem::Specification.latest_specs.map(&:full_name).sort @@ -2857,7 +2836,7 @@ end end def util_setup_deps - @gem = quick_spec "awesome", "1.0" do |awesome| + @gem = util_spec "awesome", "1.0" do |awesome| awesome.add_runtime_dependency "bonobo", [] awesome.add_development_dependency "monkey", [] end diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 49ccea4a5c..ed5fc3b2f4 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -27,7 +27,7 @@ class TestGemUninstaller < Gem::InstallerTestCase end def test_ask_if_ok - c = quick_spec 'c' + c = util_spec 'c' uninstaller = Gem::Uninstaller.new nil -- cgit v1.2.3