rubygems-update 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (146) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +8 -1
  3. data/ChangeLog +164 -0
  4. data/History.txt +52 -1
  5. data/Manifest.txt +8 -8
  6. data/README +3 -2
  7. data/Rakefile +49 -5
  8. data/bin/gem +2 -2
  9. data/bin/update_rubygems +9 -11
  10. data/cruise_config.rb +4 -3
  11. data/hide_lib_for_update/note.txt +5 -0
  12. data/lib/rbconfig/datadir.rb +10 -14
  13. data/lib/rubygems.rb +117 -140
  14. data/lib/rubygems/builder.rb +4 -2
  15. data/lib/rubygems/command.rb +51 -48
  16. data/lib/rubygems/command_manager.rb +2 -0
  17. data/lib/rubygems/commands/dependency_command.rb +10 -5
  18. data/lib/rubygems/commands/environment_command.rb +1 -1
  19. data/lib/rubygems/commands/fetch_command.rb +6 -5
  20. data/lib/rubygems/commands/install_command.rb +1 -0
  21. data/lib/rubygems/commands/mirror_command.rb +8 -8
  22. data/lib/rubygems/commands/owner_command.rb +75 -0
  23. data/lib/rubygems/commands/pristine_command.rb +1 -1
  24. data/lib/rubygems/commands/push_command.rb +45 -0
  25. data/lib/rubygems/commands/query_command.rb +4 -1
  26. data/lib/rubygems/commands/rdoc_command.rb +24 -9
  27. data/lib/rubygems/commands/server_command.rb +6 -0
  28. data/lib/rubygems/commands/setup_command.rb +14 -4
  29. data/lib/rubygems/commands/unpack_command.rb +2 -2
  30. data/lib/rubygems/commands/update_command.rb +2 -2
  31. data/lib/rubygems/commands/which_command.rb +7 -9
  32. data/lib/rubygems/config_file.rb +100 -26
  33. data/lib/rubygems/defaults.rb +1 -1
  34. data/lib/rubygems/dependency.rb +133 -75
  35. data/lib/rubygems/dependency_installer.rb +28 -10
  36. data/lib/rubygems/dependency_list.rb +41 -12
  37. data/lib/rubygems/doc_manager.rb +7 -0
  38. data/lib/rubygems/format.rb +16 -20
  39. data/lib/rubygems/gem_openssl.rb +1 -1
  40. data/lib/rubygems/gem_path_searcher.rb +10 -12
  41. data/lib/rubygems/gemcutter_utilities.rb +49 -0
  42. data/lib/rubygems/indexer.rb +2 -2
  43. data/lib/rubygems/install_update_options.rb +1 -9
  44. data/lib/rubygems/installer.rb +35 -76
  45. data/lib/rubygems/local_remote_options.rb +1 -2
  46. data/lib/rubygems/package.rb +0 -1
  47. data/lib/rubygems/package/tar_input.rb +3 -1
  48. data/lib/rubygems/package_task.rb +16 -11
  49. data/lib/rubygems/remote_fetcher.rb +22 -8
  50. data/lib/rubygems/requirement.rb +78 -100
  51. data/lib/rubygems/server.rb +41 -10
  52. data/lib/rubygems/source_index.rb +5 -5
  53. data/lib/rubygems/spec_fetcher.rb +2 -2
  54. data/lib/rubygems/specification.rb +66 -16
  55. data/lib/rubygems/test_utilities.rb +33 -4
  56. data/lib/rubygems/uninstaller.rb +3 -3
  57. data/lib/rubygems/user_interaction.rb +45 -0
  58. data/lib/rubygems/validator.rb +6 -7
  59. data/lib/rubygems/version.rb +206 -149
  60. data/lib/rubygems/version_option.rb +16 -0
  61. data/test/fake_certlib/openssl.rb +1 -1
  62. data/test/functional.rb +0 -7
  63. data/test/gem_installer_test_case.rb +4 -4
  64. data/test/gem_package_tar_test_case.rb +1 -1
  65. data/test/gemutilities.rb +35 -31
  66. data/test/insure_session.rb +0 -8
  67. data/test/mockgemui.rb +0 -8
  68. data/test/simple_gem.rb +2 -8
  69. data/test/test_config.rb +3 -10
  70. data/test/test_gem.rb +9 -14
  71. data/test/test_gem_builder.rb +1 -7
  72. data/test/test_gem_command.rb +1 -8
  73. data/test/test_gem_command_manager.rb +1 -7
  74. data/test/test_gem_commands_build_command.rb +4 -4
  75. data/test/test_gem_commands_cert_command.rb +1 -2
  76. data/test/test_gem_commands_check_command.rb +1 -7
  77. data/test/test_gem_commands_contents_command.rb +1 -1
  78. data/test/test_gem_commands_dependency_command.rb +17 -31
  79. data/test/test_gem_commands_environment_command.rb +1 -1
  80. data/test/test_gem_commands_fetch_command.rb +14 -12
  81. data/test/test_gem_commands_generate_index_command.rb +1 -1
  82. data/test/test_gem_commands_install_command.rb +22 -20
  83. data/test/test_gem_commands_list_command.rb +1 -1
  84. data/test/test_gem_commands_lock_command.rb +1 -1
  85. data/test/test_gem_commands_mirror_command.rb +5 -5
  86. data/test/test_gem_commands_outdated_command.rb +3 -5
  87. data/test/test_gem_commands_owner_command.rb +105 -0
  88. data/test/test_gem_commands_pristine_command.rb +2 -2
  89. data/test/test_gem_commands_push_command.rb +61 -0
  90. data/test/test_gem_commands_query_command.rb +23 -56
  91. data/test/test_gem_commands_server_command.rb +1 -1
  92. data/test/test_gem_commands_sources_command.rb +1 -70
  93. data/test/test_gem_commands_specification_command.rb +3 -4
  94. data/test/test_gem_commands_stale_command.rb +1 -1
  95. data/test/test_gem_commands_uninstall_command.rb +3 -4
  96. data/test/test_gem_commands_unpack_command.rb +1 -1
  97. data/test/test_gem_commands_update_command.rb +13 -13
  98. data/test/test_gem_commands_which_command.rb +66 -0
  99. data/test/test_gem_config_file.rb +13 -7
  100. data/test/test_gem_dependency.rb +82 -134
  101. data/test/test_gem_dependency_installer.rb +55 -30
  102. data/test/test_gem_dependency_list.rb +28 -7
  103. data/test/test_gem_doc_manager.rb +1 -7
  104. data/test/test_gem_ext_configure_builder.rb +2 -2
  105. data/test/test_gem_ext_ext_conf_builder.rb +1 -1
  106. data/test/test_gem_ext_rake_builder.rb +1 -1
  107. data/test/test_gem_format.rb +14 -11
  108. data/test/test_gem_gem_path_searcher.rb +12 -1
  109. data/test/test_gem_gem_runner.rb +1 -1
  110. data/test/test_gem_gemcutter_utilities.rb +103 -0
  111. data/test/test_gem_indexer.rb +44 -51
  112. data/test/test_gem_install_update_options.rb +1 -7
  113. data/test/test_gem_installer.rb +22 -82
  114. data/test/test_gem_local_remote_options.rb +1 -1
  115. data/test/test_gem_package_tar_header.rb +1 -8
  116. data/test/test_gem_package_tar_input.rb +1 -8
  117. data/test/test_gem_package_tar_output.rb +1 -8
  118. data/test/test_gem_package_tar_reader.rb +1 -8
  119. data/test/test_gem_package_tar_reader_entry.rb +1 -8
  120. data/test/test_gem_package_tar_writer.rb +1 -8
  121. data/test/test_gem_package_task.rb +1 -25
  122. data/test/test_gem_platform.rb +4 -4
  123. data/test/test_gem_remote_fetcher.rb +31 -21
  124. data/test/test_gem_requirement.rb +210 -140
  125. data/test/test_gem_server.rb +36 -1
  126. data/test/test_gem_source_index.rb +7 -13
  127. data/test/test_gem_spec_fetcher.rb +17 -47
  128. data/test/test_gem_specification.rb +7 -20
  129. data/test/test_gem_stream_ui.rb +21 -1
  130. data/test/test_gem_uninstaller.rb +1 -2
  131. data/test/test_gem_validator.rb +2 -8
  132. data/test/test_gem_version.rb +110 -254
  133. data/test/test_gem_version_option.rb +1 -1
  134. data/test/test_kernel.rb +1 -7
  135. data/util/CL2notes +1 -1
  136. data/util/gem_prelude.rb.template +64 -41
  137. metadata +33 -71
  138. metadata.gz.sig +0 -0
  139. data/lib/rubygems/digest/digest_adapter.rb +0 -49
  140. data/lib/rubygems/digest/md5.rb +0 -23
  141. data/lib/rubygems/digest/sha1.rb +0 -22
  142. data/lib/rubygems/digest/sha2.rb +0 -22
  143. data/lib/rubygems/timer.rb +0 -28
  144. data/test/test_gem_digest.rb +0 -46
  145. data/test/test_gem_source_info_cache.rb +0 -447
  146. data/test/test_gem_source_info_cache_entry.rb +0 -78
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/environment_command'
3
3
 
4
4
  class TestGemCommandsEnvironmentCommand < RubyGemTestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/package'
3
3
  require 'rubygems/security'
4
4
  require 'rubygems/commands/fetch_command'
@@ -15,8 +15,8 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
15
15
  util_setup_fake_fetcher
16
16
  util_setup_spec_fetcher @a2
17
17
 
18
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
19
- File.read(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
18
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
19
+ File.read(File.join(@gemhome, 'cache', @a2.file_name))
20
20
 
21
21
  @cmd.options[:args] = [@a2.name]
22
22
 
@@ -26,19 +26,21 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
26
26
  end
27
27
  end
28
28
 
29
- assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem")),
29
+ assert File.exist?(File.join(@tempdir, @a2.file_name)),
30
30
  "#{@a2.full_name} fetched"
31
31
  end
32
32
 
33
- def test_execute_legacy
34
- util_setup_fake_fetcher
35
- util_setup_source_info_cache @a2
33
+ def test_execute_prerelease
34
+ util_setup_fake_fetcher true
35
+ util_setup_spec_fetcher @a2, @a2_pre
36
36
 
37
- @fetcher.data["#{@gem_repo}yaml"] = ''
38
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
39
- File.read(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
37
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
38
+ File.read(File.join(@gemhome, 'cache', @a2.file_name))
39
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
40
+ File.read(File.join(@gemhome, 'cache', @a2_pre.file_name))
40
41
 
41
42
  @cmd.options[:args] = [@a2.name]
43
+ @cmd.options[:prerelease] = true
42
44
 
43
45
  use_ui @ui do
44
46
  Dir.chdir @tempdir do
@@ -46,8 +48,8 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
46
48
  end
47
49
  end
48
50
 
49
- assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem")),
50
- "#{@a2.full_name} fetched"
51
+ assert File.exist?(File.join(@tempdir, @a2_pre.file_name)),
52
+ "#{@a2_pre.full_name} not fetched"
51
53
  end
52
54
 
53
55
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/indexer'
3
3
  require 'rubygems/commands/generate_index_command'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/install_command'
3
3
 
4
4
  class TestGemCommandsInstallCommand < RubyGemTestCase
@@ -15,10 +15,10 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
15
15
  util_setup_fake_fetcher(:prerelease)
16
16
  util_setup_spec_fetcher @a2, @a2_pre
17
17
 
18
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
19
- read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
20
- @fetcher.data["#{@gem_repo}gems/#{@a2_pre.full_name}.gem"] =
21
- read_binary(File.join(@gemhome, 'cache', "#{@a2_pre.full_name}.gem"))
18
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
19
+ read_binary(File.join(@gemhome, 'cache', @a2.file_name))
20
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
21
+ read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
22
22
 
23
23
  @cmd.options[:args] = [@a2.name]
24
24
 
@@ -37,10 +37,10 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
37
37
  util_setup_fake_fetcher(:prerelease)
38
38
  util_setup_spec_fetcher @a2, @a2_pre
39
39
 
40
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
41
- read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
42
- @fetcher.data["#{@gem_repo}gems/#{@a2_pre.full_name}.gem"] =
43
- read_binary(File.join(@gemhome, 'cache', "#{@a2_pre.full_name}.gem"))
40
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
41
+ read_binary(File.join(@gemhome, 'cache', @a2.file_name))
42
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
43
+ read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
44
44
 
45
45
  @cmd.handle_options [@a2_pre.name, '--version', @a2_pre.version.to_s]
46
46
  assert @cmd.options[:prerelease]
@@ -79,7 +79,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
79
79
  util_setup_fake_fetcher
80
80
  @cmd.options[:domain] = :local
81
81
 
82
- FileUtils.mv File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"),
82
+ FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
83
83
  File.join(@tempdir)
84
84
 
85
85
  @cmd.options[:args] = [@a2.name]
@@ -109,7 +109,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
109
109
  util_setup_fake_fetcher
110
110
  @cmd.options[:user_install] = false
111
111
 
112
- FileUtils.mv File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"),
112
+ FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
113
113
  File.join(@tempdir)
114
114
 
115
115
  @cmd.options[:args] = [@a2.name]
@@ -178,10 +178,10 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
178
178
  util_setup_fake_fetcher(:prerelease)
179
179
  util_setup_spec_fetcher @a2, @a2_pre
180
180
 
181
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
182
- read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
183
- @fetcher.data["#{@gem_repo}gems/#{@a2_pre.full_name}.gem"] =
184
- read_binary(File.join(@gemhome, 'cache', "#{@a2_pre.full_name}.gem"))
181
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
182
+ read_binary(File.join(@gemhome, 'cache', @a2.file_name))
183
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
184
+ read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
185
185
 
186
186
  @cmd.options[:prerelease] = true
187
187
  @cmd.options[:args] = [@a2_pre.name]
@@ -204,14 +204,16 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
204
204
  util_setup_fake_fetcher
205
205
  util_setup_spec_fetcher @a2
206
206
 
207
- @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
208
- read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
207
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
208
+ read_binary(File.join(@gemhome, 'cache', @a2.file_name))
209
209
 
210
210
  @cmd.options[:args] = [@a2.name]
211
211
 
212
212
  use_ui @ui do
213
213
  e = assert_raises Gem::SystemExitException do
214
- @cmd.execute
214
+ capture_io do
215
+ @cmd.execute
216
+ end
215
217
  end
216
218
  assert_equal 0, e.exit_code
217
219
  end
@@ -230,10 +232,10 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
230
232
  util_setup_fake_fetcher
231
233
  @cmd.options[:domain] = :local
232
234
 
233
- FileUtils.mv File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"),
235
+ FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
234
236
  File.join(@tempdir)
235
237
 
236
- FileUtils.mv File.join(@gemhome, 'cache', "#{@b2.full_name}.gem"),
238
+ FileUtils.mv File.join(@gemhome, 'cache', @b2.file_name),
237
239
  File.join(@tempdir)
238
240
 
239
241
  @cmd.options[:args] = [@a2.name, @b2.name]
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/list_command'
3
3
 
4
4
  class TestGemCommandsListCommand < RubyGemTestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/lock_command'
3
3
 
4
4
  class TestGemCommandsLockCommand < RubyGemTestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/indexer'
3
3
  require 'rubygems/commands/mirror_command'
4
4
 
@@ -46,10 +46,10 @@ class TestGemCommandsMirrorCommand < RubyGemTestCase
46
46
  @cmd.execute
47
47
  end
48
48
 
49
- assert File.exist?(File.join(mirror, 'gems', "#{@a1.full_name}.gem"))
50
- assert File.exist?(File.join(mirror, 'gems', "#{@a2.full_name}.gem"))
51
- assert File.exist?(File.join(mirror, 'gems', "#{@b2.full_name}.gem"))
52
- assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
49
+ assert File.exist?(File.join(mirror, 'gems', @a1.file_name))
50
+ assert File.exist?(File.join(mirror, 'gems', @a2.file_name))
51
+ assert File.exist?(File.join(mirror, 'gems', @b2.file_name))
52
+ assert File.exist?(File.join(mirror, 'gems', @c1_2.file_name))
53
53
  assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
54
54
  ensure
55
55
  orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/outdated_command'
3
3
 
4
4
  class TestGemCommandsOutdatedCommand < RubyGemTestCase
@@ -19,12 +19,10 @@ class TestGemCommandsOutdatedCommand < RubyGemTestCase
19
19
  remote_10 = quick_gem 'foo', '1.0'
20
20
  remote_20 = quick_gem 'foo', '2.0'
21
21
 
22
- remote_spec_file = File.join @gemhome, 'specifications',
23
- remote_10.full_name + ".gemspec"
22
+ remote_spec_file = File.join @gemhome, 'specifications', remote_10.spec_name
24
23
  FileUtils.rm remote_spec_file
25
24
 
26
- remote_spec_file = File.join @gemhome, 'specifications',
27
- remote_20.full_name + ".gemspec"
25
+ remote_spec_file = File.join @gemhome, 'specifications', remote_20.spec_name
28
26
  FileUtils.rm remote_spec_file
29
27
 
30
28
  @fetcher = Gem::FakeFetcher.new
@@ -0,0 +1,105 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/commands/owner_command'
3
+
4
+ class TestGemCommandsOwnerCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @fetcher = Gem::FakeFetcher.new
10
+ Gem::RemoteFetcher.fetcher = @fetcher
11
+ Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
12
+
13
+ @cmd = Gem::Commands::OwnerCommand.new
14
+ end
15
+
16
+ def test_show_owners
17
+ response = <<EOF
18
+ ---
19
+ - email: user1@example.com
20
+ - email: user2@example.com
21
+ EOF
22
+
23
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
24
+
25
+ use_ui @ui do
26
+ @cmd.show_owners("freewill")
27
+ end
28
+
29
+ assert_equal Net::HTTP::Get, @fetcher.last_request.class
30
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
31
+
32
+ assert_match %r{Owners for gem: freewill}, @ui.output
33
+ assert_match %r{- user1@example.com}, @ui.output
34
+ assert_match %r{- user2@example.com}, @ui.output
35
+ end
36
+
37
+ def test_show_owners_denied
38
+ response = "You don't have permission to push to this gem"
39
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
40
+
41
+ assert_raises MockGemUi::TermError do
42
+ use_ui @ui do
43
+ @cmd.show_owners("freewill")
44
+ end
45
+ end
46
+
47
+ assert_match response, @ui.output
48
+ end
49
+
50
+ def test_add_owners
51
+ response = "Owner added successfully."
52
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
53
+
54
+ use_ui @ui do
55
+ @cmd.add_owners("freewill", ["user-new1@example.com"])
56
+ end
57
+
58
+ assert_equal Net::HTTP::Post, @fetcher.last_request.class
59
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
60
+ assert_equal "email=user-new1%40example.com", @fetcher.last_request.body
61
+
62
+ assert_match response, @ui.output
63
+ end
64
+
65
+ def test_add_owners_denied
66
+ response = "You don't have permission to push to this gem"
67
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
68
+
69
+ assert_raises MockGemUi::TermError do
70
+ use_ui @ui do
71
+ @cmd.add_owners("freewill", ["user-new1@example.com"])
72
+ end
73
+ end
74
+
75
+ assert_match response, @ui.output
76
+ end
77
+
78
+ def test_remove_owners
79
+ response = "Owner removed successfully."
80
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
81
+
82
+ use_ui @ui do
83
+ @cmd.remove_owners("freewill", ["user-remove1@example.com"])
84
+ end
85
+
86
+ assert_equal Net::HTTP::Delete, @fetcher.last_request.class
87
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
88
+ assert_equal "email=user-remove1%40example.com", @fetcher.last_request.body
89
+
90
+ assert_match response, @ui.output
91
+ end
92
+
93
+ def test_remove_owners_denied
94
+ response = "You don't have permission to push to this gem"
95
+ @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
96
+
97
+ assert_raises MockGemUi::TermError do
98
+ use_ui @ui do
99
+ @cmd.remove_owners("freewill", ["user-remove1@example.com"])
100
+ end
101
+ end
102
+
103
+ assert_match response, @ui.output
104
+ end
105
+ end
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/pristine_command'
3
3
 
4
4
  class TestGemCommandsPristineCommand < RubyGemTestCase
@@ -75,7 +75,7 @@ class TestGemCommandsPristineCommand < RubyGemTestCase
75
75
 
76
76
  install_gem a
77
77
 
78
- FileUtils.rm File.join(@gemhome, 'cache', "#{a.full_name}.gem")
78
+ FileUtils.rm File.join(@gemhome, 'cache', a.file_name)
79
79
 
80
80
  @cmd.options[:args] = %w[a]
81
81
 
@@ -0,0 +1,61 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'rubygems/commands/push_command'
3
+
4
+ class TestGemCommandsPushCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @gems_dir = File.join @tempdir, 'gems'
10
+ @cache_dir = File.join @gemhome, 'cache'
11
+ FileUtils.mkdir @gems_dir
12
+ Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
13
+ @spec, @path = util_gem("freewill", "1.0.0")
14
+
15
+ @fetcher = Gem::FakeFetcher.new
16
+ Gem::RemoteFetcher.fetcher = @fetcher
17
+
18
+ @cmd = Gem::Commands::PushCommand.new
19
+ end
20
+
21
+ def test_sending_gem
22
+ response = "Successfully registered gem: freewill (1.0.0)"
23
+ @fetcher.data["https://rubygems.org/api/v1/gems"] = [response, 200, 'OK']
24
+
25
+ use_ui @ui do
26
+ @cmd.send_gem(@path)
27
+ end
28
+
29
+ assert_match %r{Pushing gem to RubyGems.org...}, @ui.output
30
+
31
+ assert_equal Net::HTTP::Post, @fetcher.last_request.class
32
+ assert_equal Gem.read_binary(@path), @fetcher.last_request.body
33
+ assert_equal File.size(@path), @fetcher.last_request["Content-Length"].to_i
34
+ assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"]
35
+ assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
36
+
37
+ assert_match response, @ui.output
38
+ end
39
+
40
+ def test_raises_error_with_no_arguments
41
+ def @cmd.sign_in; end
42
+ assert_raises Gem::CommandLineError do
43
+ @cmd.execute
44
+ end
45
+ end
46
+
47
+ def test_sending_gem_denied
48
+ response = "You don't have permission to push to this gem"
49
+ @fetcher.data["https://rubygems.org/api/v1/gems"] = [response, 403, 'Forbidden']
50
+
51
+ assert_raises MockGemUi::TermError do
52
+ use_ui @ui do
53
+ @cmd.send_gem(@path)
54
+ end
55
+ end
56
+
57
+ assert_match response, @ui.output
58
+ end
59
+
60
+ end
61
+
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
1
+ require File.expand_path('../gemutilities', __FILE__)
2
2
  require 'rubygems/commands/query_command'
3
3
 
4
4
  class TestGemCommandsQueryCommand < RubyGemTestCase
@@ -58,6 +58,28 @@ pl (1)
58
58
  assert_equal '', @ui.error
59
59
  end
60
60
 
61
+ def test_execute_all_prerelease
62
+ a1_name = @a1.full_name
63
+ a2_name = @a2.full_name
64
+
65
+ @cmd.handle_options %w[-r --all --prerelease]
66
+
67
+ use_ui @ui do
68
+ @cmd.execute
69
+ end
70
+
71
+ expected = <<-EOF
72
+
73
+ *** REMOTE GEMS ***
74
+
75
+ a (3.a, 2, 1)
76
+ pl (1)
77
+ EOF
78
+
79
+ assert_equal expected, @ui.output
80
+ assert_equal '', @ui.error
81
+ end
82
+
61
83
  def test_execute_details
62
84
  @a2.summary = 'This is a lot of text. ' * 4
63
85
  @a2.authors = ['Abraham Lincoln', 'Hirohito']
@@ -216,61 +238,6 @@ pl (1)
216
238
  assert_equal 1, e.exit_code
217
239
  end
218
240
 
219
- def test_execute_legacy
220
- Gem::SpecFetcher.fetcher = nil
221
- si = util_setup_source_info_cache @a1, @a2, @pl1
222
-
223
- @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
224
- @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
225
- si.dump
226
-
227
- @fetcher.data.delete "#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"
228
-
229
- @cmd.handle_options %w[-r]
230
-
231
- use_ui @ui do
232
- @cmd.execute
233
- end
234
-
235
- expected = <<-EOF
236
-
237
- *** REMOTE GEMS ***
238
-
239
- a (2)
240
- pl (1)
241
- EOF
242
-
243
- assert_equal expected, @ui.output
244
-
245
- expected = <<-EOF
246
- WARNING: RubyGems 1.2+ index not found for:
247
- \t#{@gem_repo}
248
-
249
- RubyGems will revert to legacy indexes degrading performance.
250
- EOF
251
-
252
- assert_equal expected, @ui.error
253
- end
254
-
255
- def test_execute_legacy_prerelease
256
- Gem::SpecFetcher.fetcher = nil
257
- si = util_setup_source_info_cache @a1, @a2, @pl1
258
-
259
- @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
260
- @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
261
- si.dump
262
-
263
- @fetcher.data.delete "#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"
264
-
265
- @cmd.handle_options %w[-r --prerelease]
266
-
267
- e = assert_raises Gem::OperationNotSupportedError do
268
- @cmd.execute
269
- end
270
-
271
- assert_equal 'Prereleases not supported on legacy repositories', e.message
272
- end
273
-
274
241
  def test_execute_local_details
275
242
  @a3a.summary = 'This is a lot of text. ' * 4
276
243
  @a3a.authors = ['Abraham Lincoln', 'Hirohito']