rubygems-update 1.0.1 → 1.1.0

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 (172) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +248 -0
  3. data/README +2 -0
  4. data/Rakefile +47 -23
  5. data/bin/gem +9 -4
  6. data/bin/update_rubygems +15 -1
  7. data/examples/application/bin/myapp +0 -0
  8. data/lib/rubygems.rb +506 -373
  9. data/lib/rubygems/builder.rb +14 -7
  10. data/lib/rubygems/command.rb +9 -9
  11. data/lib/rubygems/command_manager.rb +1 -0
  12. data/lib/rubygems/commands/cleanup_command.rb +67 -69
  13. data/lib/rubygems/commands/environment_command.rb +16 -10
  14. data/lib/rubygems/commands/fetch_command.rb +7 -9
  15. data/lib/rubygems/commands/install_command.rb +9 -3
  16. data/lib/rubygems/commands/list_command.rb +2 -4
  17. data/lib/rubygems/commands/mirror_command.rb +1 -1
  18. data/lib/rubygems/commands/query_command.rb +52 -5
  19. data/lib/rubygems/commands/sources_command.rb +19 -10
  20. data/lib/rubygems/commands/specification_command.rb +10 -6
  21. data/lib/rubygems/commands/uninstall_command.rb +23 -6
  22. data/lib/rubygems/commands/unpack_command.rb +15 -3
  23. data/lib/rubygems/commands/update_command.rb +27 -25
  24. data/lib/rubygems/custom_require.rb +1 -1
  25. data/lib/rubygems/defaults.rb +8 -1
  26. data/lib/rubygems/dependency_installer.rb +72 -104
  27. data/lib/rubygems/digest/digest_adapter.rb +0 -0
  28. data/lib/rubygems/digest/md5.rb +0 -0
  29. data/lib/rubygems/digest/sha1.rb +0 -0
  30. data/lib/rubygems/digest/sha2.rb +0 -0
  31. data/lib/rubygems/exceptions.rb +22 -1
  32. data/lib/rubygems/format.rb +16 -10
  33. data/lib/rubygems/indexer.rb +46 -33
  34. data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
  35. data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
  36. data/lib/rubygems/indexer/master_index_builder.rb +9 -8
  37. data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
  38. data/lib/rubygems/install_update_options.rb +7 -1
  39. data/lib/rubygems/installer.rb +8 -5
  40. data/lib/rubygems/package.rb +17 -774
  41. data/lib/rubygems/package/f_sync_dir.rb +24 -0
  42. data/lib/rubygems/package/tar_header.rb +245 -0
  43. data/lib/rubygems/package/tar_input.rb +219 -0
  44. data/lib/rubygems/package/tar_output.rb +143 -0
  45. data/lib/rubygems/package/tar_reader.rb +86 -0
  46. data/lib/rubygems/package/tar_reader/entry.rb +99 -0
  47. data/lib/rubygems/package/tar_writer.rb +180 -0
  48. data/lib/rubygems/remote_fetcher.rb +131 -16
  49. data/lib/rubygems/requirement.rb +2 -0
  50. data/lib/rubygems/rubygems_version.rb +1 -1
  51. data/lib/rubygems/security.rb +1 -0
  52. data/lib/rubygems/server.rb +85 -104
  53. data/lib/rubygems/source_index.rb +412 -329
  54. data/lib/rubygems/source_info_cache.rb +232 -99
  55. data/lib/rubygems/source_info_cache_entry.rb +14 -4
  56. data/lib/rubygems/specification.rb +9 -10
  57. data/lib/rubygems/timer.rb +0 -0
  58. data/lib/rubygems/uninstaller.rb +56 -32
  59. data/lib/rubygems/user_interaction.rb +4 -10
  60. data/lib/rubygems/validator.rb +0 -0
  61. data/scripts/gemdoc.rb +0 -0
  62. data/scripts/specdoc.rb +0 -0
  63. data/setup.rb +56 -19
  64. data/test/gem_installer_test_case.rb +86 -0
  65. data/test/gem_installer_test_case.rbc +0 -0
  66. data/test/gem_package_tar_test_case.rb +146 -0
  67. data/test/gem_package_tar_test_case.rbc +0 -0
  68. data/test/gemutilities.rb +123 -38
  69. data/test/gemutilities.rbc +0 -0
  70. data/test/mockgemui.rb +5 -13
  71. data/test/mockgemui.rbc +0 -0
  72. data/test/private_key.pem +27 -0
  73. data/test/public_cert.pem +20 -0
  74. data/test/simple_gem.rbc +0 -0
  75. data/test/test_config.rbc +0 -0
  76. data/test/test_gem.rb +46 -4
  77. data/test/test_gem.rbc +0 -0
  78. data/test/test_gem_builder.rbc +0 -0
  79. data/test/test_gem_command.rbc +0 -0
  80. data/test/test_gem_command_manager.rb +4 -2
  81. data/test/test_gem_command_manager.rbc +0 -0
  82. data/test/test_gem_commands_build_command.rbc +0 -0
  83. data/test/test_gem_commands_cert_command.rb +5 -1
  84. data/test/test_gem_commands_cert_command.rbc +0 -0
  85. data/test/test_gem_commands_check_command.rbc +0 -0
  86. data/test/test_gem_commands_contents_command.rbc +0 -0
  87. data/test/test_gem_commands_dependency_command.rbc +0 -0
  88. data/test/test_gem_commands_environment_command.rb +17 -1
  89. data/test/test_gem_commands_environment_command.rbc +0 -0
  90. data/test/test_gem_commands_fetch_command.rb +6 -5
  91. data/test/test_gem_commands_fetch_command.rbc +0 -0
  92. data/test/test_gem_commands_generate_index_command.rbc +0 -0
  93. data/test/test_gem_commands_install_command.rb +36 -28
  94. data/test/test_gem_commands_install_command.rbc +0 -0
  95. data/test/test_gem_commands_mirror_command.rbc +0 -0
  96. data/test/test_gem_commands_pristine_command.rbc +0 -0
  97. data/test/test_gem_commands_query_command.rb +143 -19
  98. data/test/test_gem_commands_query_command.rbc +0 -0
  99. data/test/test_gem_commands_server_command.rb +1 -1
  100. data/test/test_gem_commands_server_command.rbc +0 -0
  101. data/test/test_gem_commands_sources_command.rb +67 -9
  102. data/test/test_gem_commands_sources_command.rbc +0 -0
  103. data/test/test_gem_commands_specification_command.rb +3 -2
  104. data/test/test_gem_commands_specification_command.rbc +0 -0
  105. data/test/test_gem_commands_unpack_command.rb +46 -4
  106. data/test/test_gem_commands_unpack_command.rbc +0 -0
  107. data/test/test_gem_commands_update_command.rb +174 -0
  108. data/test/test_gem_commands_update_command.rbc +0 -0
  109. data/test/test_gem_config_file.rbc +0 -0
  110. data/test/test_gem_dependency.rbc +0 -0
  111. data/test/test_gem_dependency_installer.rb +172 -187
  112. data/test/test_gem_dependency_installer.rbc +0 -0
  113. data/test/test_gem_dependency_list.rbc +0 -0
  114. data/test/test_gem_digest.rb +0 -0
  115. data/test/test_gem_digest.rbc +0 -0
  116. data/test/test_gem_doc_manager.rbc +0 -0
  117. data/test/test_gem_ext_configure_builder.rb +9 -6
  118. data/test/test_gem_ext_configure_builder.rbc +0 -0
  119. data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
  120. data/test/test_gem_ext_rake_builder.rbc +0 -0
  121. data/test/test_gem_format.rb +1 -1
  122. data/test/test_gem_format.rbc +0 -0
  123. data/test/test_gem_gem_path_searcher.rbc +0 -0
  124. data/test/test_gem_gem_runner.rbc +0 -0
  125. data/test/test_gem_indexer.rb +7 -2
  126. data/test/test_gem_indexer.rbc +0 -0
  127. data/test/test_gem_install_update_options.rbc +0 -0
  128. data/test/test_gem_installer.rb +5 -84
  129. data/test/test_gem_installer.rbc +0 -0
  130. data/test/test_gem_local_remote_options.rbc +0 -0
  131. data/test/test_gem_outdated_command.rbc +0 -0
  132. data/test/test_gem_package_tar_header.rb +137 -0
  133. data/test/test_gem_package_tar_header.rbc +0 -0
  134. data/test/test_gem_package_tar_input.rb +119 -0
  135. data/test/test_gem_package_tar_input.rbc +0 -0
  136. data/test/test_gem_package_tar_output.rb +104 -0
  137. data/test/test_gem_package_tar_output.rbc +0 -0
  138. data/test/test_gem_package_tar_reader.rb +53 -0
  139. data/test/test_gem_package_tar_reader.rbc +0 -0
  140. data/test/test_gem_package_tar_reader_entry.rb +116 -0
  141. data/test/test_gem_package_tar_reader_entry.rbc +0 -0
  142. data/test/test_gem_package_tar_writer.rb +151 -0
  143. data/test/test_gem_package_tar_writer.rbc +0 -0
  144. data/test/test_gem_platform.rbc +0 -0
  145. data/test/test_gem_remote_fetcher.rb +189 -17
  146. data/test/test_gem_remote_fetcher.rbc +0 -0
  147. data/test/test_gem_requirement.rbc +0 -0
  148. data/test/test_gem_server.rb +13 -12
  149. data/test/test_gem_server.rbc +0 -0
  150. data/test/test_gem_source_index.rb +305 -56
  151. data/test/test_gem_source_index.rbc +0 -0
  152. data/test/test_gem_source_info_cache.rb +179 -53
  153. data/test/test_gem_source_info_cache.rbc +0 -0
  154. data/test/test_gem_source_info_cache_entry.rb +41 -10
  155. data/test/test_gem_source_info_cache_entry.rbc +0 -0
  156. data/test/test_gem_specification.rb +7 -7
  157. data/test/test_gem_specification.rbc +0 -0
  158. data/test/test_gem_stream_ui.rbc +0 -0
  159. data/test/test_gem_uninstaller.rb +43 -0
  160. data/test/test_gem_uninstaller.rbc +0 -0
  161. data/test/test_gem_validator.rbc +0 -0
  162. data/test/test_gem_version.rb +1 -1
  163. data/test/test_gem_version.rbc +0 -0
  164. data/test/test_gem_version_option.rbc +0 -0
  165. data/test/test_kernel.rb +1 -0
  166. data/test/test_kernel.rbc +0 -0
  167. metadata +85 -8
  168. metadata.gz.sig +0 -0
  169. data/lib/rubygems/gem_open_uri.rb +0 -7
  170. data/lib/rubygems/open-uri.rb +0 -773
  171. data/test/test_open_uri.rb +0 -13
  172. data/test/test_package.rb +0 -608
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
3
+ YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
4
+ ZXQwHhcNMDcxMjIxMDIwNDE0WhcNMDgxMjIwMDIwNDE0WjBBMRAwDgYDVQQDDAdk
5
+ cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
6
+ FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
7
+ LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
8
+ U5ddZCVywn5nnAQ+Ui7jMW54CYt5/H6f2US6U0hQOjJR6cpfiymgxGdfyTiVcvTm
9
+ Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
10
+ mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
11
+ g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
12
+ sCANiQ8BAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
13
+ BBS5k4Z75VSpdM0AclG2UvzFA/VW5DANBgkqhkiG9w0BAQUFAAOCAQEAHagT4lfX
14
+ kP/hDaiwGct7XPuVGbrOsKRVD59FF5kETBxEc9UQ1clKWngf8JoVuEoKD774dW19
15
+ bU0GOVWO+J6FMmT/Cp7nuFJ79egMf/gy4gfUfQMuvfcr6DvZUPIs9P/TlK59iMYF
16
+ DIOQ3DxdF3rMzztNUCizN4taVscEsjCcgW6WkUJnGdqlu3OHWpQxZBJkBTjPCoc6
17
+ UW6on70SFPmAy/5Cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag
18
+ 14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v
19
+ x52qPcexcYZR7w==
20
+ -----END CERTIFICATE-----
Binary file
Binary file
@@ -1,4 +1,3 @@
1
- require 'test/unit'
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
2
  require 'rubygems'
4
3
  require 'rubygems/gem_openssl'
@@ -20,6 +19,7 @@ class TestGem < RubyGemTestCase
20
19
  expected = [
21
20
  File.join(@gemhome, *%W[gems #{@a1.full_name} lib]),
22
21
  File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
22
+ File.join(@gemhome, *%W[gems #{@a_evil9.full_name} lib]),
23
23
  File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
24
24
  File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
25
25
  File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
@@ -75,6 +75,8 @@ class TestGem < RubyGemTestCase
75
75
  install_gem foo
76
76
  end
77
77
 
78
+ Gem.source_index = nil
79
+
78
80
  gem 'foo'
79
81
 
80
82
  expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
@@ -212,6 +214,7 @@ class TestGem < RubyGemTestCase
212
214
 
213
215
  expected = [
214
216
  File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
217
+ File.join(@gemhome, *%W[gems #{@a_evil9.full_name} lib]),
215
218
  File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
216
219
  File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
217
220
  File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
@@ -225,7 +228,7 @@ class TestGem < RubyGemTestCase
225
228
  install_gem foo
226
229
  Gem.source_index = nil
227
230
 
228
- Gem.activate 'foo', false
231
+ Gem.activate 'foo'
229
232
 
230
233
  assert_equal true, Gem.loaded_specs.keys.include?('foo')
231
234
  end
@@ -234,9 +237,29 @@ class TestGem < RubyGemTestCase
234
237
  assert_equal [Gem.dir], Gem.path
235
238
  end
236
239
 
240
+ def test_self_path_APPLE_GEM_HOME
241
+ Gem.clear_paths
242
+ Gem.const_set :APPLE_GEM_HOME, '/tmp/apple_gem_home'
243
+
244
+ assert Gem.path.include?('/tmp/apple_gem_home')
245
+ ensure
246
+ Gem.send :remove_const, :APPLE_GEM_HOME
247
+ end
248
+
249
+ def test_self_path_APPLE_GEM_HOME_GEM_PATH
250
+ Gem.clear_paths
251
+ ENV['GEM_PATH'] = @gemhome
252
+ Gem.const_set :APPLE_GEM_HOME, '/tmp/apple_gem_home'
253
+
254
+ assert !Gem.path.include?('/tmp/apple_gem_home')
255
+ ensure
256
+ Gem.send :remove_const, :APPLE_GEM_HOME
257
+ end
258
+
237
259
  def test_self_path_ENV_PATH
238
260
  Gem.clear_paths
239
261
  path_count = Gem.path.size
262
+ path_count -= 1 if defined? APPLE_GEM_HOME
240
263
  Gem.clear_paths
241
264
  util_ensure_gem_dirs
242
265
 
@@ -256,8 +279,8 @@ class TestGem < RubyGemTestCase
256
279
  ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
257
280
 
258
281
  assert_equal @gemhome, Gem.dir
282
+
259
283
  paths = [Gem.dir]
260
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
261
284
  assert_equal @additional + paths, Gem.path
262
285
  end
263
286
 
@@ -269,8 +292,8 @@ class TestGem < RubyGemTestCase
269
292
  ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
270
293
 
271
294
  assert_equal @gemhome, Gem.dir
295
+
272
296
  paths = [Gem.dir]
273
- paths.insert(0, APPLE_GEM_HOME) if defined? APPLE_GEM_HOME
274
297
  assert_equal @additional + paths, Gem.path
275
298
  end
276
299
 
@@ -283,6 +306,18 @@ class TestGem < RubyGemTestCase
283
306
  assert_equal File.dirname(File.dirname(file_name)), Gem.prefix
284
307
  end
285
308
 
309
+ def test_self_prefix_odd
310
+ orig_sitelibdir = Gem::ConfigMap[:sitelibdir]
311
+
312
+ file_name = File.expand_path __FILE__
313
+ prefix = File.join File.dirname(File.dirname(file_name)), 'lib'
314
+ Gem::ConfigMap[:sitelibdir] = prefix.sub(/[\w]\//, '\&/')
315
+
316
+ assert_nil Gem.prefix
317
+ ensure
318
+ Gem::ConfigMap[:sitelibdir] = orig_sitelibdir
319
+ end
320
+
286
321
  def test_self_required_location
287
322
  util_make_gems
288
323
 
@@ -294,6 +329,13 @@ class TestGem < RubyGemTestCase
294
329
  Gem.required_location("a", "code.rb", "= 2")
295
330
  end
296
331
 
332
+ def test_self_ruby_version
333
+ version = RUBY_VERSION.dup
334
+ version << ".#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
335
+
336
+ assert_equal Gem::Version.new(version), Gem.ruby_version
337
+ end
338
+
297
339
  def test_self_searcher
298
340
  assert_kind_of Gem::GemPathSearcher, Gem.searcher
299
341
  end
Binary file
Binary file
Binary file
@@ -67,11 +67,12 @@ class TestGemCommandManager < RubyGemTestCase
67
67
  assert_equal true, check_options[:wrappers]
68
68
  assert_equal Gem::Requirement.default, check_options[:version]
69
69
  assert_equal Gem.dir, check_options[:install_dir]
70
+ assert_equal nil, check_options[:bin_dir]
70
71
 
71
72
  #check settings
72
73
  check_options = nil
73
74
  @command_manager.process_args(
74
- "install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper")
75
+ "install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
75
76
  assert_equal true, check_options[:test]
76
77
  assert_equal true, check_options[:generate_rdoc]
77
78
  assert_equal true, check_options[:force]
@@ -79,6 +80,7 @@ class TestGemCommandManager < RubyGemTestCase
79
80
  assert_equal false, check_options[:wrappers]
80
81
  assert_equal Gem::Requirement.new('3.0'), check_options[:version]
81
82
  assert_equal Dir.pwd, check_options[:install_dir]
83
+ assert_equal Dir.pwd, check_options[:bin_dir]
82
84
 
83
85
  #check remote domain
84
86
  check_options = nil
@@ -164,7 +166,7 @@ class TestGemCommandManager < RubyGemTestCase
164
166
 
165
167
  #check defaults
166
168
  @command_manager.process_args("query")
167
- assert_equal(/.*/, check_options[:name])
169
+ assert_equal(//, check_options[:name])
168
170
  assert_equal :local, check_options[:domain]
169
171
  assert_equal false, check_options[:details]
170
172
 
@@ -3,6 +3,10 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
3
 
4
4
  require 'rubygems/commands/cert_command'
5
5
 
6
+ unless defined? OpenSSL then
7
+ warn "`gem cert` tests are being skipped, module OpenSSL not found"
8
+ end
9
+
6
10
  class TestGemCommandsCertCommand < RubyGemTestCase
7
11
 
8
12
  def setup
@@ -118,5 +122,5 @@ class TestGemCommandsCertCommand < RubyGemTestCase
118
122
  # HACK this test sucks
119
123
  end
120
124
 
121
- end
125
+ end if defined? OpenSSL
122
126
 
@@ -25,7 +25,8 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
25
25
  assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
26
26
  @ui.output
27
27
  assert_match %r|RUBYGEMS PREFIX: |, @ui.output
28
- assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output
28
+ assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:RUBY_INSTALL_NAME]}|,
29
+ @ui.output
29
30
  assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
30
31
  assert_match %r|- #{Gem::Platform.local}|, @ui.output
31
32
  assert_match %r|GEM PATHS:|, @ui.output
@@ -61,6 +62,21 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
61
62
  assert_equal '', @ui.error
62
63
  end
63
64
 
65
+ def test_execute_gempath_multiple
66
+ Gem.clear_paths
67
+ path = [@gemhome, "#{@gemhome}2"].join File::PATH_SEPARATOR
68
+ ENV['GEM_PATH'] = path
69
+
70
+ @cmd.send :handle_options, %w[gempath]
71
+
72
+ use_ui @ui do
73
+ @cmd.execute
74
+ end
75
+
76
+ assert_equal "#{Gem.path.join File::PATH_SEPARATOR}\n", @ui.output
77
+ assert_equal '', @ui.error
78
+ end
79
+
64
80
  def test_execute_packageversion
65
81
  @cmd.send :handle_options, %w[packageversion]
66
82
 
@@ -1,5 +1,7 @@
1
1
  require 'test/unit'
2
2
  require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
+ require 'rubygems/package'
4
+ require 'rubygems/security'
3
5
  require 'rubygems/commands/fetch_command'
4
6
 
5
7
  class TestGemCommandsFetchCommand < RubyGemTestCase
@@ -13,13 +15,12 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
13
15
  def test_execute
14
16
  util_setup_fake_fetcher
15
17
 
16
- util_build_gem @gem1
17
18
  @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
18
19
  @source_index.dump
19
- @fetcher.data["#{@gem_repo}/gems/#{@gem1.full_name}.gem"] =
20
- File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
20
+ @fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] =
21
+ File.read(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
21
22
 
22
- @cmd.options[:args] = [@gem1.name]
23
+ @cmd.options[:args] = [@a2.name]
23
24
 
24
25
  use_ui @ui do
25
26
  Dir.chdir @tempdir do
@@ -27,7 +28,7 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
27
28
  end
28
29
  end
29
30
 
30
- assert File.exist?(File.join(@tempdir, "#{@gem1.full_name}.gem"))
31
+ assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem"))
31
32
  end
32
33
 
33
34
  end
@@ -34,25 +34,26 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
34
34
  util_setup_fake_fetcher
35
35
  @cmd.options[:domain] = :local
36
36
 
37
- gem1 = quick_gem 'gem_one'
38
- util_build_gem gem1
39
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
37
+ FileUtils.mv File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"),
40
38
  File.join(@tempdir)
41
39
 
42
- @cmd.options[:args] = [gem1.name]
40
+ @cmd.options[:args] = [@a2.name]
43
41
 
44
42
  use_ui @ui do
45
43
  orig_dir = Dir.pwd
46
44
  begin
47
45
  Dir.chdir @tempdir
48
- @cmd.execute
46
+ e = assert_raises Gem::SystemExitException do
47
+ @cmd.execute
48
+ end
49
+ assert_equal 0, e.exit_code
49
50
  ensure
50
51
  Dir.chdir orig_dir
51
52
  end
52
53
  end
53
54
 
54
55
  out = @ui.output.split "\n"
55
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
56
+ assert_equal "Successfully installed #{@a2.full_name}", out.shift
56
57
  assert_equal "1 gem installed", out.shift
57
58
  assert out.empty?, out.inspect
58
59
  end
@@ -61,14 +62,17 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
61
62
  util_setup_fake_fetcher
62
63
  @cmd.options[:domain] = :local
63
64
 
64
- @cmd.options[:args] = %w[gem_one]
65
+ @cmd.options[:args] = %w[no_such_gem]
65
66
 
66
67
  use_ui @ui do
67
- @cmd.execute
68
+ e = assert_raises Gem::SystemExitException do
69
+ @cmd.execute
70
+ end
71
+ assert_equal 2, e.exit_code
68
72
  end
69
73
 
70
74
  # HACK no repository was checked
71
- assert_equal "ERROR: could not find gem_one locally or in a repository\n",
75
+ assert_equal "ERROR: could not find no_such_gem locally or in a repository\n",
72
76
  @ui.error
73
77
  end
74
78
 
@@ -88,7 +92,10 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
88
92
  @cmd.options[:args] = %w[nonexistent]
89
93
 
90
94
  use_ui @ui do
91
- @cmd.execute
95
+ e = assert_raises Gem::SystemExitException do
96
+ @cmd.execute
97
+ end
98
+ assert_equal 2, e.exit_code
92
99
  end
93
100
 
94
101
  assert_equal "ERROR: could not find nonexistent locally or in a repository\n",
@@ -100,25 +107,27 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
100
107
  @cmd.options[:generate_ri] = true
101
108
  util_setup_fake_fetcher
102
109
 
103
- util_build_gem @gem1
104
110
  @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
105
111
  @source_index.dump
106
- @fetcher.data["#{@gem_repo}/gems/gem_one-0.0.2.gem"] =
107
- File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
112
+ @fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] =
113
+ read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
108
114
 
109
- @cmd.options[:args] = [@gem1.name]
115
+ @cmd.options[:args] = [@a2.name]
110
116
 
111
117
  use_ui @ui do
112
- @cmd.execute
118
+ e = assert_raises Gem::SystemExitException do
119
+ @cmd.execute
120
+ end
121
+ assert_equal 0, e.exit_code
113
122
  end
114
123
 
115
124
  out = @ui.output.split "\n"
116
125
  assert_match %r|Bulk updating|, out.shift
117
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
126
+ assert_equal "Successfully installed #{@a2.full_name}", out.shift
118
127
  assert_equal "1 gem installed", out.shift
119
- assert_equal "Installing ri documentation for #{@gem1.full_name}...",
128
+ assert_equal "Installing ri documentation for #{@a2.full_name}...",
120
129
  out.shift
121
- assert_equal "Installing RDoc documentation for #{@gem1.full_name}...",
130
+ assert_equal "Installing RDoc documentation for #{@a2.full_name}...",
122
131
  out.shift
123
132
  assert out.empty?, out.inspect
124
133
  end
@@ -127,31 +136,30 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
127
136
  util_setup_fake_fetcher
128
137
  @cmd.options[:domain] = :local
129
138
 
130
- gem1 = quick_gem 'gem_one'
131
- util_build_gem gem1
132
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
139
+ FileUtils.mv File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"),
133
140
  File.join(@tempdir)
134
141
 
135
- gem2 = quick_gem 'gem_two'
136
- util_build_gem gem2
137
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem2.full_name}.gem"),
142
+ FileUtils.mv File.join(@gemhome, 'cache', "#{@b2.full_name}.gem"),
138
143
  File.join(@tempdir)
139
144
 
140
- @cmd.options[:args] = [gem1.name, gem2.name]
145
+ @cmd.options[:args] = [@a2.name, @b2.name]
141
146
 
142
147
  use_ui @ui do
143
148
  orig_dir = Dir.pwd
144
149
  begin
145
150
  Dir.chdir @tempdir
146
- @cmd.execute
151
+ e = assert_raises Gem::SystemExitException do
152
+ @cmd.execute
153
+ end
154
+ assert_equal 0, e.exit_code
147
155
  ensure
148
156
  Dir.chdir orig_dir
149
157
  end
150
158
  end
151
159
 
152
160
  out = @ui.output.split "\n"
153
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
154
- assert_equal "Successfully installed #{@gem2.full_name}", out.shift
161
+ assert_equal "Successfully installed #{@a2.full_name}", out.shift
162
+ assert_equal "Successfully installed #{@b2.full_name}", out.shift
155
163
  assert_equal "2 gems installed", out.shift
156
164
  assert out.empty?, out.inspect
157
165
  end
@@ -7,20 +7,32 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
7
7
  def setup
8
8
  super
9
9
 
10
- @foo_gem = quick_gem 'foo' do |spec|
11
- spec.summary = 'This is a lot of text. ' * 5
12
- end
13
- @foo_gem_p = quick_gem 'foo' do |spec|
14
- spec.summary = 'This is a lot of text. ' * 5
15
- spec.platform = Gem::Platform::CURRENT
16
- end
17
- @bar_gem = quick_gem 'bar'
10
+ util_make_gems
11
+
12
+ @a2.summary = 'This is a lot of text. ' * 4
18
13
 
19
14
  @cmd = Gem::Commands::QueryCommand.new
15
+
16
+ @si = util_setup_source_info_cache @a1, @a2, @pl1
17
+ util_setup_fake_fetcher
18
+
19
+ @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] = proc do
20
+ raise Gem::RemoteFetcher::FetchError
21
+ end
20
22
  end
21
23
 
22
24
  def test_execute
23
- util_setup_source_info_cache @foo_gem, @foo_gem_p
25
+ cache = Gem::SourceInfoCache.cache
26
+ cache.update
27
+ cache.write_cache
28
+ cache.reset_cache_data
29
+ Gem::SourceInfoCache.reset
30
+
31
+ a2_name = @a2.full_name
32
+ @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
33
+ @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
34
+ @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
35
+ Marshal.dump @si
24
36
 
25
37
  @cmd.handle_options %w[-r]
26
38
 
@@ -32,16 +44,52 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
32
44
 
33
45
  *** REMOTE GEMS ***
34
46
 
35
- foo (2)
47
+ a (2)
48
+ pl (1)
36
49
  EOF
37
50
 
38
51
  assert_equal expected, @ui.output
39
52
  assert_equal '', @ui.error
40
53
  end
41
54
 
42
- def test_execute_details
43
- util_setup_source_info_cache @foo_gem
55
+ def test_execute_all
56
+ cache = Gem::SourceInfoCache.cache
57
+ cache.update
58
+ cache.write_cache
59
+ cache.reset_cache_data
60
+ Gem::SourceInfoCache.reset
61
+
62
+ a1_name = @a1.full_name
63
+ a2_name = @a2.full_name
64
+ @fetcher.data["#{@gem_repo}/quick/index.rz"] =
65
+ util_zip [a1_name, a2_name].join("\n")
66
+ @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
67
+ @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a1_name}.gemspec.rz"] = util_zip Marshal.dump(@a1)
68
+ @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
69
+ @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
70
+ Marshal.dump @si
71
+
72
+ @cmd.handle_options %w[-r --all]
73
+
74
+ use_ui @ui do
75
+ @cmd.execute
76
+ end
77
+
78
+ expected = <<-EOF
79
+
80
+ *** REMOTE GEMS ***
44
81
 
82
+ Updating metadata for 1 gems from http://gems.example.com/
83
+ .
84
+ complete
85
+ a (2, 1)
86
+ EOF
87
+
88
+ assert_equal expected, @ui.output
89
+ assert_equal '', @ui.error
90
+ end
91
+
92
+ def test_execute_details
45
93
  @cmd.handle_options %w[-r -d]
46
94
 
47
95
  use_ui @ui do
@@ -52,18 +100,94 @@ foo (2)
52
100
 
53
101
  *** REMOTE GEMS ***
54
102
 
55
- foo (2)
56
- This is a lot of text. This is a lot of text. This is a lot of
57
- text. This is a lot of text. This is a lot of text.
103
+ a (2, 1)
104
+ This is a lot of text. This is a lot of text. This is a lot of text.
105
+ This is a lot of text.
106
+
107
+ pl (1)
108
+ this is a summary
58
109
  EOF
59
110
 
60
111
  assert_equal expected, @ui.output
61
112
  assert_equal '', @ui.error
62
113
  end
63
114
 
64
- def test_execute_no_versions
65
- util_setup_source_info_cache @foo_gem, @bar_gem
115
+ def test_execute_installed
116
+ @cmd.handle_options %w[-n c --installed]
117
+
118
+ e = assert_raise Gem::SystemExitException do
119
+ use_ui @ui do
120
+ @cmd.execute
121
+ end
122
+ end
123
+
124
+ assert_equal 0, e.exit_code
125
+
126
+ assert_equal "true\n", @ui.output
127
+ assert_equal '', @ui.error
128
+ end
129
+
130
+ def test_execute_installed_no_name
131
+ @cmd.handle_options %w[--installed]
132
+
133
+ e = assert_raise Gem::SystemExitException do
134
+ use_ui @ui do
135
+ @cmd.execute
136
+ end
137
+ end
138
+
139
+ assert_equal '', @ui.output
140
+ assert_equal "ERROR: You must specify a gem name\n", @ui.error
141
+
142
+ assert_equal 4, e.exit_code
143
+ end
144
+
145
+ def test_execute_installed_not_installed
146
+ @cmd.handle_options %w[-n not_installed --installed]
147
+
148
+ e = assert_raise Gem::SystemExitException do
149
+ use_ui @ui do
150
+ @cmd.execute
151
+ end
152
+ end
153
+
154
+ assert_equal "false\n", @ui.output
155
+ assert_equal '', @ui.error
156
+
157
+ assert_equal 1, e.exit_code
158
+ end
159
+
160
+ def test_execute_installed_version
161
+ @cmd.handle_options %w[-n c --installed --version 1.2]
66
162
 
163
+ e = assert_raise Gem::SystemExitException do
164
+ use_ui @ui do
165
+ @cmd.execute
166
+ end
167
+ end
168
+
169
+ assert_equal "true\n", @ui.output
170
+ assert_equal '', @ui.error
171
+
172
+ assert_equal 0, e.exit_code
173
+ end
174
+
175
+ def test_execute_installed_version_not_installed
176
+ @cmd.handle_options %w[-n c --installed --version 2]
177
+
178
+ e = assert_raise Gem::SystemExitException do
179
+ use_ui @ui do
180
+ @cmd.execute
181
+ end
182
+ end
183
+
184
+ assert_equal "false\n", @ui.output
185
+ assert_equal '', @ui.error
186
+
187
+ assert_equal 1, e.exit_code
188
+ end
189
+
190
+ def test_execute_no_versions
67
191
  @cmd.handle_options %w[-r --no-versions]
68
192
 
69
193
  use_ui @ui do
@@ -74,8 +198,8 @@ foo (2)
74
198
 
75
199
  *** REMOTE GEMS ***
76
200
 
77
- bar
78
- foo
201
+ a
202
+ pl
79
203
  EOF
80
204
 
81
205
  assert_equal expected, @ui.output