rubygems-update 1.8.30 → 2.0.0.preview2

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 (241) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -0
  4. data/.autotest +6 -3
  5. data/History.txt +137 -63
  6. data/LICENSE.txt +1 -5
  7. data/Manifest.txt +69 -32
  8. data/README.rdoc +11 -9
  9. data/Rakefile +24 -38
  10. data/bin/gem +0 -9
  11. data/bin/update_rubygems +1 -0
  12. data/lib/rubygems.rb +193 -405
  13. data/lib/rubygems/available_set.rb +95 -0
  14. data/lib/rubygems/command.rb +88 -45
  15. data/lib/rubygems/command_manager.rb +67 -40
  16. data/lib/rubygems/commands/build_command.rb +5 -23
  17. data/lib/rubygems/commands/cert_command.rb +199 -57
  18. data/lib/rubygems/commands/check_command.rb +14 -39
  19. data/lib/rubygems/commands/cleanup_command.rb +9 -1
  20. data/lib/rubygems/commands/contents_command.rb +30 -12
  21. data/lib/rubygems/commands/dependency_command.rb +3 -8
  22. data/lib/rubygems/commands/environment_command.rb +13 -8
  23. data/lib/rubygems/commands/fetch_command.rb +3 -16
  24. data/lib/rubygems/commands/generate_index_command.rb +7 -47
  25. data/lib/rubygems/commands/help_command.rb +1 -1
  26. data/lib/rubygems/commands/install_command.rb +69 -36
  27. data/lib/rubygems/commands/list_command.rb +6 -4
  28. data/lib/rubygems/commands/lock_command.rb +1 -1
  29. data/lib/rubygems/commands/mirror_command.rb +17 -0
  30. data/lib/rubygems/commands/outdated_command.rb +6 -3
  31. data/lib/rubygems/commands/owner_command.rb +13 -5
  32. data/lib/rubygems/commands/pristine_command.rb +19 -4
  33. data/lib/rubygems/commands/push_command.rb +12 -1
  34. data/lib/rubygems/commands/query_command.rb +43 -27
  35. data/lib/rubygems/commands/rdoc_command.rb +23 -28
  36. data/lib/rubygems/commands/search_command.rb +4 -18
  37. data/lib/rubygems/commands/server_command.rb +1 -1
  38. data/lib/rubygems/commands/setup_command.rb +124 -38
  39. data/lib/rubygems/commands/sources_command.rb +16 -16
  40. data/lib/rubygems/commands/specification_command.rb +11 -13
  41. data/lib/rubygems/commands/uninstall_command.rb +24 -7
  42. data/lib/rubygems/commands/unpack_command.rb +7 -3
  43. data/lib/rubygems/commands/update_command.rb +22 -36
  44. data/lib/rubygems/commands/yank_command.rb +98 -0
  45. data/lib/rubygems/compatibility.rb +51 -0
  46. data/lib/rubygems/config_file.rb +82 -54
  47. data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
  48. data/lib/rubygems/core_ext/kernel_require.rb +119 -0
  49. data/lib/rubygems/defaults.rb +10 -21
  50. data/lib/rubygems/dependency.rb +61 -10
  51. data/lib/rubygems/dependency_installer.rb +157 -69
  52. data/lib/rubygems/dependency_list.rb +11 -19
  53. data/lib/rubygems/dependency_resolver.rb +562 -0
  54. data/lib/rubygems/deprecate.rb +40 -40
  55. data/lib/rubygems/errors.rb +77 -24
  56. data/lib/rubygems/exceptions.rb +25 -7
  57. data/lib/rubygems/ext/builder.rb +20 -23
  58. data/lib/rubygems/ext/configure_builder.rb +2 -2
  59. data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
  60. data/lib/rubygems/ext/rake_builder.rb +2 -2
  61. data/lib/rubygems/gem_runner.rb +3 -16
  62. data/lib/rubygems/gemcutter_utilities.rb +22 -7
  63. data/lib/rubygems/indexer.rb +6 -159
  64. data/lib/rubygems/install_message.rb +12 -0
  65. data/lib/rubygems/install_update_options.rb +56 -18
  66. data/lib/rubygems/installer.rb +244 -134
  67. data/lib/rubygems/installer_test_case.rb +71 -19
  68. data/lib/rubygems/mock_gem_ui.rb +17 -0
  69. data/lib/rubygems/name_tuple.rb +110 -0
  70. data/lib/rubygems/package.rb +514 -43
  71. data/lib/rubygems/package/digest_io.rb +64 -0
  72. data/lib/rubygems/package/old.rb +147 -0
  73. data/lib/rubygems/package/tar_header.rb +18 -55
  74. data/lib/rubygems/package/tar_reader.rb +20 -3
  75. data/lib/rubygems/package/tar_writer.rb +63 -7
  76. data/lib/rubygems/package_task.rb +3 -4
  77. data/lib/rubygems/path_support.rb +14 -7
  78. data/lib/rubygems/platform.rb +19 -26
  79. data/lib/rubygems/rdoc.rb +316 -0
  80. data/lib/rubygems/remote_fetcher.rb +117 -54
  81. data/lib/rubygems/request_set.rb +182 -0
  82. data/lib/rubygems/requirement.rb +63 -26
  83. data/lib/rubygems/security.rb +295 -555
  84. data/lib/rubygems/security/policies.rb +115 -0
  85. data/lib/rubygems/security/policy.rb +227 -0
  86. data/lib/rubygems/security/signer.rb +136 -0
  87. data/lib/rubygems/security/trust_dir.rb +104 -0
  88. data/lib/rubygems/server.rb +45 -55
  89. data/lib/rubygems/source.rb +144 -0
  90. data/lib/rubygems/source_list.rb +87 -0
  91. data/lib/rubygems/source_local.rb +92 -0
  92. data/lib/rubygems/source_specific_file.rb +28 -0
  93. data/lib/rubygems/spec_fetcher.rb +116 -184
  94. data/lib/rubygems/specification.rb +731 -335
  95. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  96. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  97. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  98. data/lib/rubygems/syck_hack.rb +2 -0
  99. data/lib/rubygems/test_case.rb +199 -109
  100. data/lib/rubygems/test_utilities.rb +25 -5
  101. data/lib/rubygems/uninstaller.rb +62 -20
  102. data/lib/rubygems/user_interaction.rb +10 -0
  103. data/lib/rubygems/validator.rb +33 -40
  104. data/lib/rubygems/version.rb +19 -8
  105. data/setup.rb +8 -1
  106. data/test/rubygems/alternate_cert.pem +9 -0
  107. data/test/rubygems/alternate_cert_32.pem +9 -0
  108. data/test/rubygems/alternate_key.pem +9 -0
  109. data/test/rubygems/bad_rake.rb +1 -0
  110. data/test/rubygems/child_cert.pem +9 -0
  111. data/test/rubygems/child_cert_32.pem +9 -0
  112. data/test/rubygems/child_key.pem +9 -0
  113. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  114. data/test/rubygems/expired_cert.pem +9 -0
  115. data/test/rubygems/future_cert.pem +9 -0
  116. data/test/rubygems/future_cert_32.pem +9 -0
  117. data/test/rubygems/good_rake.rb +1 -0
  118. data/test/rubygems/grandchild_cert.pem +9 -0
  119. data/test/rubygems/grandchild_cert_32.pem +9 -0
  120. data/test/rubygems/grandchild_key.pem +9 -0
  121. data/test/rubygems/invalid_issuer_cert.pem +9 -0
  122. data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
  123. data/test/rubygems/invalid_key.pem +9 -0
  124. data/test/rubygems/invalid_signer_cert.pem +9 -0
  125. data/test/rubygems/invalid_signer_cert_32.pem +9 -0
  126. data/test/rubygems/invalidchild_cert.pem +9 -0
  127. data/test/rubygems/invalidchild_cert_32.pem +9 -0
  128. data/test/rubygems/invalidchild_key.pem +9 -0
  129. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  130. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  131. data/test/rubygems/private_key.pem +7 -25
  132. data/test/rubygems/public_cert.pem +8 -18
  133. data/test/rubygems/public_cert_32.pem +10 -0
  134. data/test/rubygems/public_key.pem +4 -0
  135. data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
  136. data/test/rubygems/test_config.rb +4 -6
  137. data/test/rubygems/test_deprecate.rb +76 -0
  138. data/test/rubygems/test_gem.rb +318 -83
  139. data/test/rubygems/test_gem_available_set.rb +106 -0
  140. data/test/rubygems/test_gem_command.rb +10 -0
  141. data/test/rubygems/test_gem_command_manager.rb +55 -9
  142. data/test/rubygems/test_gem_commands_build_command.rb +11 -19
  143. data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
  144. data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
  145. data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
  146. data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
  147. data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
  148. data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
  149. data/test/rubygems/test_gem_commands_help_command.rb +2 -1
  150. data/test/rubygems/test_gem_commands_install_command.rb +647 -48
  151. data/test/rubygems/test_gem_commands_mirror.rb +32 -0
  152. data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
  153. data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
  154. data/test/rubygems/test_gem_commands_push_command.rb +62 -8
  155. data/test/rubygems/test_gem_commands_query_command.rb +51 -0
  156. data/test/rubygems/test_gem_commands_search_command.rb +25 -0
  157. data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
  158. data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
  159. data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
  160. data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
  161. data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
  162. data/test/rubygems/test_gem_commands_update_command.rb +56 -38
  163. data/test/rubygems/test_gem_commands_which_command.rb +4 -4
  164. data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
  165. data/test/rubygems/test_gem_config_file.rb +66 -21
  166. data/test/rubygems/test_gem_dependency.rb +46 -0
  167. data/test/rubygems/test_gem_dependency_installer.rb +228 -18
  168. data/test/rubygems/test_gem_dependency_list.rb +0 -9
  169. data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
  170. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  171. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
  172. data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
  173. data/test/rubygems/test_gem_gem_runner.rb +27 -5
  174. data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
  175. data/test/rubygems/test_gem_indexer.rb +14 -227
  176. data/test/rubygems/test_gem_install_update_options.rb +83 -3
  177. data/test/rubygems/test_gem_installer.rb +211 -236
  178. data/test/rubygems/test_gem_local_remote_options.rb +8 -2
  179. data/test/rubygems/test_gem_name_tuple.rb +15 -0
  180. data/test/rubygems/test_gem_package.rb +547 -0
  181. data/test/rubygems/test_gem_package_old.rb +37 -0
  182. data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
  183. data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
  184. data/test/rubygems/test_gem_path_support.rb +4 -30
  185. data/test/rubygems/test_gem_platform.rb +3 -6
  186. data/test/rubygems/test_gem_rdoc.rb +245 -0
  187. data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
  188. data/test/rubygems/test_gem_request_set.rb +70 -0
  189. data/test/rubygems/test_gem_requirement.rb +53 -24
  190. data/test/rubygems/test_gem_security.rb +189 -43
  191. data/test/rubygems/test_gem_security_policy.rb +376 -0
  192. data/test/rubygems/test_gem_security_signer.rb +184 -0
  193. data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
  194. data/test/rubygems/test_gem_server.rb +31 -36
  195. data/test/rubygems/test_gem_silent_ui.rb +2 -2
  196. data/test/rubygems/test_gem_source.rb +188 -0
  197. data/test/rubygems/test_gem_source_list.rb +87 -0
  198. data/test/rubygems/test_gem_source_local.rb +83 -0
  199. data/test/rubygems/test_gem_source_specific_file.rb +33 -0
  200. data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
  201. data/test/rubygems/test_gem_specification.rb +293 -39
  202. data/test/rubygems/test_gem_uninstaller.rb +136 -13
  203. data/test/rubygems/test_gem_validator.rb +14 -41
  204. data/test/rubygems/test_gem_version.rb +15 -21
  205. data/test/rubygems/test_require.rb +193 -0
  206. data/test/rubygems/wrong_key_cert.pem +9 -0
  207. data/test/rubygems/wrong_key_cert_32.pem +9 -0
  208. metadata +171 -83
  209. metadata.gz.sig +1 -0
  210. data/CVE-2013-4287.txt +0 -36
  211. data/CVE-2013-4363.txt +0 -45
  212. data/ci_build.sh +0 -27
  213. data/cruise_config.rb +0 -32
  214. data/lib/rbconfig/datadir.rb +0 -13
  215. data/lib/rubygems/builder.rb +0 -99
  216. data/lib/rubygems/custom_require.rb +0 -69
  217. data/lib/rubygems/doc_manager.rb +0 -243
  218. data/lib/rubygems/format.rb +0 -82
  219. data/lib/rubygems/gem_openssl.rb +0 -90
  220. data/lib/rubygems/gem_path_searcher.rb +0 -172
  221. data/lib/rubygems/old_format.rb +0 -153
  222. data/lib/rubygems/package/f_sync_dir.rb +0 -23
  223. data/lib/rubygems/package/tar_input.rb +0 -234
  224. data/lib/rubygems/package/tar_output.rb +0 -146
  225. data/lib/rubygems/require_paths_builder.rb +0 -18
  226. data/lib/rubygems/source_index.rb +0 -406
  227. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  228. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  229. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  230. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  231. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  232. data/test/rubygems/test_bundled_ca.rb +0 -59
  233. data/test/rubygems/test_gem_builder.rb +0 -44
  234. data/test/rubygems/test_gem_doc_manager.rb +0 -32
  235. data/test/rubygems/test_gem_ext_builder.rb +0 -58
  236. data/test/rubygems/test_gem_format.rb +0 -88
  237. data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
  238. data/test/rubygems/test_gem_package_tar_input.rb +0 -129
  239. data/test/rubygems/test_gem_package_tar_output.rb +0 -101
  240. data/test/rubygems/test_gem_source_index.rb +0 -250
  241. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -99,6 +99,25 @@ Error fetching http://beta-gems.example.com:
99
99
  assert_equal '', @ui.error
100
100
  end
101
101
 
102
+ def test_execute_add_redundant_source
103
+ @cmd.handle_options %W[--add #{@gem_repo}]
104
+
105
+ util_setup_spec_fetcher
106
+
107
+ use_ui @ui do
108
+ @cmd.execute
109
+ end
110
+
111
+ assert_equal [@gem_repo], Gem.sources
112
+
113
+ expected = <<-EOF
114
+ source #{@gem_repo} already present in the cache
115
+ EOF
116
+
117
+ assert_equal expected, @ui.output
118
+ assert_equal '', @ui.error
119
+ end
120
+
102
121
  def test_execute_add_bad_uri
103
122
  @cmd.handle_options %w[--add beta-gems.example.com]
104
123
 
@@ -125,11 +144,6 @@ beta-gems.example.com is not a URI
125
144
 
126
145
  util_setup_spec_fetcher
127
146
 
128
- fetcher = Gem::SpecFetcher.fetcher
129
-
130
- # HACK figure out how to force directory creation via fetcher
131
- #assert File.directory?(fetcher.dir), 'cache dir exists'
132
-
133
147
  use_ui @ui do
134
148
  @cmd.execute
135
149
  end
@@ -141,7 +155,8 @@ beta-gems.example.com is not a URI
141
155
  assert_equal expected, @ui.output
142
156
  assert_equal '', @ui.error
143
157
 
144
- refute File.exist?(fetcher.dir), 'cache dir removed'
158
+ dir = File.join Gem.user_home, '.gem', 'specs'
159
+ refute File.exist?(dir), 'cache dir removed'
145
160
  end
146
161
 
147
162
  def test_execute_remove
@@ -71,7 +71,21 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
71
71
  end
72
72
 
73
73
  assert_equal '', @ui.output
74
- assert_equal "ERROR: Unknown gem 'foo'\n", @ui.error
74
+ assert_equal "ERROR: No gem matching 'foo (>= 0)' found\n", @ui.error
75
+ end
76
+
77
+ def test_execute_bad_name_with_version
78
+ @cmd.options[:args] = %w[foo]
79
+ @cmd.options[:version] = "1.3.2"
80
+
81
+ assert_raises Gem::MockGemUi::TermError do
82
+ use_ui @ui do
83
+ @cmd.execute
84
+ end
85
+ end
86
+
87
+ assert_equal '', @ui.output
88
+ assert_equal "ERROR: No gem matching 'foo (= 1.3.2)' found\n", @ui.error
75
89
  end
76
90
 
77
91
  def test_execute_exact_match
@@ -103,6 +117,24 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
103
117
  assert_equal "foo", YAML.load(@ui.output)
104
118
  end
105
119
 
120
+ def test_execute_file
121
+ foo = quick_spec 'foo' do |s|
122
+ s.files = %w[lib/code.rb]
123
+ end
124
+
125
+ util_build_gem foo
126
+
127
+ @cmd.options[:args] = [foo.cache_file]
128
+
129
+ use_ui @ui do
130
+ @cmd.execute
131
+ end
132
+
133
+ assert_match %r|Gem::Specification|, @ui.output
134
+ assert_match %r|name: foo|, @ui.output
135
+ assert_equal '', @ui.error
136
+ end
137
+
106
138
  def test_execute_marshal
107
139
  foo = new_spec 'foo', '2'
108
140
 
@@ -13,49 +13,32 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
13
13
  end
14
14
 
15
15
  @cmd = Gem::Commands::UninstallCommand.new
16
- @cmd.options[:executables] = true
17
16
  @executable = File.join(@gemhome, 'bin', 'executable')
18
17
  end
19
18
 
20
- def test_execute_mulitple
21
- @other = quick_gem 'c'
22
- util_make_exec @other
23
- util_build_gem @other
24
-
25
- @other_installer = util_installer @other, @gemhome
26
-
27
- ui = Gem::MockGemUi.new
28
- util_setup_gem ui
29
-
30
- build_rake_in do
31
- use_ui ui do
32
- @other_installer.install
33
- end
34
- end
35
-
36
- @cmd.options[:args] = [@spec.name, @other.name]
37
-
38
- use_ui @ui do
39
- @cmd.execute
19
+ def test_execute_dependency_order
20
+ c = quick_gem 'c' do |spec|
21
+ spec.add_dependency 'a'
40
22
  end
41
23
 
42
- output = @ui.output.split "\n"
24
+ util_build_gem c
25
+ installer = util_installer c, @gemhome
26
+ use_ui @ui do installer.install end
43
27
 
44
- assert_includes output, "Successfully uninstalled #{@spec.full_name}"
45
- assert_includes output, "Successfully uninstalled #{@other.full_name}"
46
- end
28
+ ui = Gem::MockGemUi.new
47
29
 
48
- def test_execute_mulitple_nonexistent
49
- @cmd.options[:args] = %w[x y]
30
+ @cmd.options[:args] = %w[a c]
31
+ @cmd.options[:executables] = true
50
32
 
51
- use_ui @ui do
33
+ use_ui ui do
52
34
  @cmd.execute
53
35
  end
54
36
 
55
- output = @ui.output.split "\n"
37
+ output = ui.output.split "\n"
56
38
 
57
- assert_includes output, 'INFO: gem "x" is not installed'
58
- assert_includes output, 'INFO: gem "y" is not installed'
39
+ assert_equal 'Successfully uninstalled c-2', output.shift
40
+ assert_equal "Removing executable", output.shift
41
+ assert_equal 'Successfully uninstalled a-2', output.shift
59
42
  end
60
43
 
61
44
  def test_execute_removes_executable
@@ -79,6 +62,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
79
62
 
80
63
  open @executable, "wb+" do |f| f.puts "binary" end
81
64
 
65
+ @cmd.options[:executables] = true
82
66
  @cmd.options[:args] = [@spec.name]
83
67
  use_ui @ui do
84
68
  @cmd.execute
@@ -102,6 +86,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
102
86
  formatted_executable = File.join @gemhome, 'bin', 'foo-executable-bar'
103
87
  assert_equal true, File.exist?(formatted_executable)
104
88
 
89
+ @cmd.options[:executables] = true
105
90
  @cmd.options[:format_executable] = true
106
91
  @cmd.execute
107
92
 
@@ -123,6 +108,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
123
108
  end
124
109
  end
125
110
 
111
+ @cmd.options[:executables] = true
126
112
  @cmd.options[:args] = ["pre"]
127
113
 
128
114
  use_ui @ui do
@@ -133,5 +119,79 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
133
119
  assert_match(/Successfully uninstalled/, output)
134
120
  end
135
121
 
122
+ def test_execute_with_force_leaves_executable
123
+ ui = Gem::MockGemUi.new
124
+
125
+ util_make_gems
126
+ util_setup_gem ui
127
+
128
+ @cmd.options[:version] = '1'
129
+ @cmd.options[:force] = true
130
+ @cmd.options[:args] = ['a']
131
+
132
+ use_ui ui do
133
+ @cmd.execute
134
+ end
135
+
136
+ assert !Gem::Specification.all_names.include?('a')
137
+ assert File.exist? File.join(@gemhome, 'bin', 'executable')
138
+ end
139
+
140
+ def test_execute_with_force_uninstalls_all_versions
141
+ ui = Gem::MockGemUi.new "y\n"
142
+
143
+ util_make_gems
144
+ util_setup_gem ui
145
+
146
+ assert Gem::Specification.find_all_by_name('a').length > 1
147
+
148
+ @cmd.options[:force] = true
149
+ @cmd.options[:args] = ['a']
150
+
151
+ use_ui ui do
152
+ @cmd.execute
153
+ end
154
+
155
+ refute_includes Gem::Specification.all_names, 'a'
156
+ end
157
+
158
+ def test_execute_with_force_ignores_dependencies
159
+ ui = Gem::MockGemUi.new
160
+
161
+ util_make_gems
162
+ util_setup_gem ui
163
+
164
+ assert Gem::Specification.find_all_by_name('dep_x').length > 0
165
+ assert Gem::Specification.find_all_by_name('x').length > 0
166
+
167
+ @cmd.options[:force] = true
168
+ @cmd.options[:args] = ['x']
169
+
170
+ use_ui ui do
171
+ @cmd.execute
172
+ end
173
+
174
+ assert Gem::Specification.find_all_by_name('dep_x').length > 0
175
+ assert Gem::Specification.find_all_by_name('x').length == 0
176
+ end
177
+
178
+ def test_execute_default_gem
179
+ default_gem_spec = new_default_spec("default", "2.0.0.0",
180
+ nil, "default/gem.rb")
181
+ install_default_specs(default_gem_spec)
182
+
183
+ ui = Gem::MockGemUi.new
184
+
185
+ @cmd.options[:args] = %w[default]
186
+ @cmd.options[:executables] = true
187
+
188
+ use_ui ui do
189
+ e = assert_raises Gem::InstallError do
190
+ @cmd.execute
191
+ end
192
+ assert_equal "gem \"default\" cannot be uninstalled because it is a default gem",
193
+ e.message
194
+ end
195
+ end
136
196
  end
137
197
 
@@ -191,8 +191,8 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
191
191
 
192
192
  use_ui @ui do
193
193
  Dir.chdir @tempdir do
194
- Gem::Builder.new(foo_spec).build
195
- Gem::Builder.new(foo_bar_spec).build
194
+ Gem::Package.build foo_spec
195
+ Gem::Package.build foo_bar_spec
196
196
  end
197
197
  end
198
198
 
@@ -209,7 +209,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
209
209
  end
210
210
  end
211
211
 
212
- assert File.exist?(File.join(@tempdir, foo_spec.full_name))
212
+ assert_path_exists File.join(@tempdir, foo_spec.full_name)
213
213
  end
214
214
 
215
215
  def test_handle_options_metadata
@@ -14,20 +14,22 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
14
14
 
15
15
  @cmd = Gem::Commands::UpdateCommand.new
16
16
 
17
- @cmd.options[:generate_rdoc] = false
18
- @cmd.options[:generate_ri] = false
17
+ @cmd.options[:document] = []
19
18
 
20
- util_setup_fake_fetcher
19
+ util_setup_fake_fetcher(true)
21
20
  util_clear_gems
22
- util_setup_spec_fetcher @a1, @a2
21
+ util_setup_spec_fetcher @a1, @a2, @a3a
23
22
 
24
23
  @a1_path = @a1.cache_file
25
24
  @a2_path = @a2.cache_file
25
+ @a3a_path = @a3a.cache_file
26
26
 
27
27
  @fetcher.data["#{@gem_repo}gems/#{File.basename @a1_path}"] =
28
28
  read_binary @a1_path
29
29
  @fetcher.data["#{@gem_repo}gems/#{File.basename @a2_path}"] =
30
30
  read_binary @a2_path
31
+ @fetcher.data["#{@gem_repo}gems/#{File.basename @a3a_path}"] =
32
+ read_binary @a3a_path
31
33
  end
32
34
 
33
35
  def test_execute
@@ -36,8 +38,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
36
38
  Gem::Installer.new(@a1_path).install
37
39
 
38
40
  @cmd.options[:args] = []
39
- @cmd.options[:generate_rdoc] = false
40
- @cmd.options[:generate_ri] = false
41
41
 
42
42
  use_ui @ui do
43
43
  @cmd.execute
@@ -46,7 +46,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
46
46
  out = @ui.output.split "\n"
47
47
  assert_equal "Updating installed gems", out.shift
48
48
  assert_equal "Updating #{@a2.name}", out.shift
49
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
50
49
  assert_equal "Gems updated: #{@a2.name}", out.shift
51
50
  assert_empty out
52
51
  end
@@ -91,8 +90,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
91
90
 
92
91
  @cmd.options[:args] = []
93
92
  @cmd.options[:system] = true
94
- @cmd.options[:generate_rdoc] = false
95
- @cmd.options[:generate_ri] = false
96
93
 
97
94
  use_ui @ui do
98
95
  @cmd.execute
@@ -100,7 +97,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
100
97
 
101
98
  out = @ui.output.split "\n"
102
99
  assert_equal "Updating rubygems-update", out.shift
103
- assert_equal "Successfully installed rubygems-update-9", out.shift
104
100
  assert_equal "Installing RubyGems 9", out.shift
105
101
  assert_equal "RubyGems system software updated", out.shift
106
102
 
@@ -115,8 +111,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
115
111
 
116
112
  @cmd.options[:args] = []
117
113
  @cmd.options[:system] = true
118
- @cmd.options[:generate_rdoc] = false
119
- @cmd.options[:generate_ri] = false
120
114
 
121
115
  assert_raises Gem::MockGemUi::SystemExitException do
122
116
  use_ui @ui do
@@ -138,8 +132,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
138
132
 
139
133
  @cmd.options[:args] = []
140
134
  @cmd.options[:system] = true
141
- @cmd.options[:generate_rdoc] = false
142
- @cmd.options[:generate_ri] = false
143
135
 
144
136
  use_ui @ui do
145
137
  @cmd.execute
@@ -147,7 +139,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
147
139
 
148
140
  out = @ui.output.split "\n"
149
141
  assert_equal "Updating rubygems-update", out.shift
150
- assert_equal "Successfully installed rubygems-update-9", out.shift
151
142
  assert_equal "Installing RubyGems 9", out.shift
152
143
  assert_equal "RubyGems system software updated", out.shift
153
144
 
@@ -163,8 +154,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
163
154
 
164
155
  @cmd.options[:args] = []
165
156
  @cmd.options[:system] = "8"
166
- @cmd.options[:generate_rdoc] = false
167
- @cmd.options[:generate_ri] = false
168
157
 
169
158
  use_ui @ui do
170
159
  @cmd.execute
@@ -172,7 +161,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
172
161
 
173
162
  out = @ui.output.split "\n"
174
163
  assert_equal "Updating rubygems-update", out.shift
175
- assert_equal "Successfully installed rubygems-update-8", out.shift
176
164
  assert_equal "Installing RubyGems 8", out.shift
177
165
  assert_equal "RubyGems system software updated", out.shift
178
166
 
@@ -188,8 +176,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
188
176
 
189
177
  @cmd.options[:args] = []
190
178
  @cmd.options[:system] = "9"
191
- @cmd.options[:generate_rdoc] = false
192
- @cmd.options[:generate_ri] = false
193
179
 
194
180
  use_ui @ui do
195
181
  @cmd.execute
@@ -197,7 +183,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
197
183
 
198
184
  out = @ui.output.split "\n"
199
185
  assert_equal "Updating rubygems-update", out.shift
200
- assert_equal "Successfully installed rubygems-update-9", out.shift
201
186
  assert_equal "Installing RubyGems 9", out.shift
202
187
  assert_equal "RubyGems system software updated", out.shift
203
188
 
@@ -207,8 +192,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
207
192
  def test_execute_system_with_gems
208
193
  @cmd.options[:args] = %w[gem]
209
194
  @cmd.options[:system] = true
210
- @cmd.options[:generate_rdoc] = false
211
- @cmd.options[:generate_ri] = false
212
195
 
213
196
  assert_raises Gem::MockGemUi::TermError do
214
197
  use_ui @ui do
@@ -270,15 +253,33 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
270
253
  out = @ui.output.split "\n"
271
254
  assert_equal "Updating installed gems", out.shift
272
255
  assert_equal "Updating #{@a2.name}", out.shift
273
- assert_equal "Successfully installed #{@c2.full_name}", out.shift
274
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
275
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
276
- assert_equal "Gems updated: #{@c2.name}, #{@b2.name}, #{@a2.name}",
256
+ assert_equal "Gems updated: #{@c2.name} #{@b2.name} #{@a2.name}",
277
257
  out.shift
278
258
 
279
259
  assert_empty out
280
260
  end
281
261
 
262
+ def test_execute_rdoc
263
+ Gem.done_installing(&Gem::RDoc.method(:generation_hook))
264
+
265
+ @cmd.options[:document] = %w[rdoc ri]
266
+
267
+ util_clear_gems
268
+
269
+ Gem::Installer.new(@a1_path).install
270
+
271
+ @cmd.options[:args] = [@a1.name]
272
+
273
+ use_ui @ui do
274
+ @cmd.execute
275
+ end
276
+
277
+ wait_for_child_process_to_exit
278
+
279
+ assert_path_exists File.join(@a2.doc_dir, 'ri')
280
+ assert_path_exists File.join(@a2.doc_dir, 'rdoc')
281
+ end
282
+
282
283
  def test_execute_named
283
284
  util_clear_gems
284
285
 
@@ -293,7 +294,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
293
294
  out = @ui.output.split "\n"
294
295
  assert_equal "Updating installed gems", out.shift
295
296
  assert_equal "Updating #{@a2.name}", out.shift
296
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
297
297
  assert_equal "Gems updated: #{@a2.name}", out.shift
298
298
 
299
299
  assert_empty out
@@ -317,6 +317,26 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
317
317
  assert_empty out
318
318
  end
319
319
 
320
+ def test_execute_named_up_to_date_prerelease
321
+ util_clear_gems
322
+
323
+ Gem::Installer.new(@a2_path).install
324
+
325
+ @cmd.options[:args] = [@a2.name]
326
+ @cmd.options[:prerelease] = true
327
+
328
+ use_ui @ui do
329
+ @cmd.execute
330
+ end
331
+
332
+ out = @ui.output.split "\n"
333
+ assert_equal "Updating installed gems", out.shift
334
+ assert_equal "Updating #{@a3a.name}", out.shift
335
+ assert_equal "Gems updated: #{@a3a.name}", out.shift
336
+
337
+ assert_empty out
338
+ end
339
+
320
340
  def test_execute_up_to_date
321
341
  util_clear_gems
322
342
 
@@ -339,11 +359,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
339
359
  @cmd.handle_options %w[--system]
340
360
 
341
361
  expected = {
342
- :generate_ri => true,
343
- :system => true,
344
- :force => false,
345
- :args => [],
346
- :generate_rdoc => true,
362
+ :args => [],
363
+ :document => %w[rdoc ri],
364
+ :force => false,
365
+ :system => true,
347
366
  }
348
367
 
349
368
  assert_equal expected, @cmd.options
@@ -359,11 +378,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
359
378
  @cmd.handle_options %w[--system 1.3.7]
360
379
 
361
380
  expected = {
362
- :generate_ri => true,
363
- :system => "1.3.7",
364
- :force => false,
365
- :args => [],
366
- :generate_rdoc => true,
381
+ :args => [],
382
+ :document => %w[rdoc ri],
383
+ :force => false,
384
+ :system => "1.3.7",
367
385
  }
368
386
 
369
387
  assert_equal expected, @cmd.options