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
@@ -2,7 +2,7 @@ require 'rubygems/test_case'
2
2
  require 'rubygems/commands/cleanup_command'
3
3
 
4
4
  class TestGemCommandsCleanupCommand < Gem::TestCase
5
-
5
+
6
6
  def setup
7
7
  super
8
8
 
@@ -24,6 +24,12 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
24
24
  end
25
25
 
26
26
  def test_execute_all
27
+ gemhome2 = File.join @tempdir, 'gemhome2'
28
+
29
+ Gem.ensure_gem_subdirectories gemhome2
30
+
31
+ Gem.use_paths @gemhome, gemhome2
32
+
27
33
  @b_1 = quick_spec 'b', 1
28
34
  @b_2 = quick_spec 'b', 2
29
35
 
@@ -34,6 +40,9 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
34
40
 
35
41
  @cmd.execute
36
42
 
43
+ assert_equal @gemhome, Gem.dir, 'GEM_HOME'
44
+ assert_equal [@gemhome, gemhome2], Gem.path.sort, 'GEM_PATH'
45
+
37
46
  refute_path_exists @a_1.gem_dir
38
47
  refute_path_exists @b_1.gem_dir
39
48
  end
@@ -85,5 +94,24 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
85
94
  assert_path_exists @a_1.gem_dir
86
95
  end
87
96
 
97
+ def test_execute_keeps_older_versions_with_deps
98
+ @b_1 = quick_spec 'b', 1
99
+ @b_2 = quick_spec 'b', 2
100
+
101
+ @c = quick_spec 'c', 1 do |s|
102
+ s.add_dependency 'b', '1'
103
+ end
104
+
105
+ install_gem @c
106
+ install_gem @b_1
107
+ install_gem @b_2
108
+
109
+ @cmd.options[:args] = []
110
+
111
+ @cmd.execute
112
+
113
+ assert_path_exists @b_1.gem_dir
114
+ end
115
+
88
116
  end
89
117
 
@@ -127,6 +127,29 @@ lib/foo.rb
127
127
  assert_equal "", @ui.error
128
128
  end
129
129
 
130
+ def test_execute_default_gem
131
+ default_gem_spec = new_default_spec("default", "2.0.0.0",
132
+ nil, "default/gem.rb")
133
+ default_gem_spec.executables = ["default_command"]
134
+ default_gem_spec.files += ["default_gem.so"]
135
+ install_default_specs(default_gem_spec)
136
+
137
+ @cmd.options[:args] = %w[default]
138
+
139
+ use_ui @ui do
140
+ @cmd.execute
141
+ end
142
+
143
+ expected = %W[
144
+ #{Gem::ConfigMap[:bindir]}/default_command
145
+ #{Gem::ConfigMap[:rubylibdir]}/default/gem.rb
146
+ #{Gem::ConfigMap[:archdir]}/default_gem.so
147
+ ].sort.join "\n"
148
+
149
+ assert_equal expected, @ui.output.chomp
150
+ assert_equal "", @ui.error
151
+ end
152
+
130
153
  def test_handle_options
131
154
  refute @cmd.options[:lib_only]
132
155
  assert @cmd.options[:prefix]
@@ -51,8 +51,13 @@ Gem b-2
51
51
 
52
52
  Gem c-1.2
53
53
 
54
+ Gem dep_x-1
55
+ x (>= 1)
56
+
54
57
  Gem pl-1-x86-linux
55
58
 
59
+ Gem x-1
60
+
56
61
  EOF
57
62
 
58
63
  assert_equal expected, @ui.output
@@ -26,8 +26,8 @@ class TestGemCommandsFetchCommand < Gem::TestCase
26
26
  end
27
27
  end
28
28
 
29
- assert File.exist?(File.join(@tempdir, @a2.file_name)),
30
- "#{@a2.full_name} not fetched"
29
+ assert_path_exists(File.join(@tempdir, @a2.file_name),
30
+ "#{@a2.full_name} not fetched")
31
31
  end
32
32
 
33
33
  def test_execute_prerelease
@@ -49,19 +49,23 @@ class TestGemCommandsFetchCommand < Gem::TestCase
49
49
  end
50
50
  end
51
51
 
52
- assert File.exist?(File.join(@tempdir, @a2_pre.file_name)),
53
- "#{@a2_pre.full_name} not fetched"
52
+ assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
53
+ "#{@a2_pre.full_name} not fetched")
54
54
  end
55
55
 
56
- def test_execute_version
57
- util_setup_fake_fetcher
58
- util_setup_spec_fetcher @a1, @a2
56
+ def test_execute_specific_prerelease
57
+ util_setup_fake_fetcher true
58
+ util_clear_gems
59
+ util_setup_spec_fetcher @a2, @a2_pre
59
60
 
60
- @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
61
- File.read(@a1.cache_file)
61
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
62
+ File.read(@a2.cache_file)
63
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
64
+ File.read(@a2_pre.cache_file)
62
65
 
63
66
  @cmd.options[:args] = [@a2.name]
64
- @cmd.options[:version] = Gem::Requirement.new '1'
67
+ @cmd.options[:prerelease] = true
68
+ @cmd.options[:version] = "2.a"
65
69
 
66
70
  use_ui @ui do
67
71
  Dir.chdir @tempdir do
@@ -69,16 +73,11 @@ class TestGemCommandsFetchCommand < Gem::TestCase
69
73
  end
70
74
  end
71
75
 
72
- assert File.exist?(File.join(@tempdir, @a1.file_name)),
73
- "#{@a1.full_name} not fetched"
76
+ assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
77
+ "#{@a2_pre.full_name} not fetched")
74
78
  end
75
79
 
76
- def test_execute_handles_sources_properly
77
- repo = "http://gems.example.com"
78
- @uri = URI.parse repo
79
-
80
- Gem.sources.replace [repo]
81
-
80
+ def test_execute_version
82
81
  util_setup_fake_fetcher
83
82
  util_setup_spec_fetcher @a1, @a2
84
83
 
@@ -94,8 +93,8 @@ class TestGemCommandsFetchCommand < Gem::TestCase
94
93
  end
95
94
  end
96
95
 
97
- assert File.exist?(File.join(@tempdir, @a1.file_name)),
98
- "#{@a1.full_name} not fetched"
96
+ assert_path_exists(File.join(@tempdir, @a1.file_name),
97
+ "#{@a1.full_name} not fetched")
99
98
  end
100
99
 
101
100
  end
@@ -16,27 +16,9 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
16
16
  @cmd.execute
17
17
  end
18
18
 
19
- marshal = File.join @gemhome, 'Marshal.4.8'
20
- marshal_z = File.join @gemhome, 'Marshal.4.8.Z'
19
+ specs = File.join @gemhome, "specs.4.8.gz"
21
20
 
22
- assert File.exist?(marshal), marshal
23
- assert File.exist?(marshal_z), marshal_z
24
- end
25
-
26
- def test_execute_rss_update
27
- @cmd.options[:update] = true
28
- @cmd.options[:rss_host] = 'example.com'
29
- @cmd.options[:rss_gems_host] = 'gems.example.com'
30
-
31
- use_ui @ui do
32
- assert_raises Gem::MockGemUi::TermError do
33
- @cmd.execute
34
- end
35
- end
36
-
37
- assert_equal "ERROR: --update not compatible with RSS generation\n",
38
- @ui.error
39
- assert_empty @ui.output
21
+ assert File.exist?(specs), specs
40
22
  end
41
23
 
42
24
  def test_handle_options_directory
@@ -58,69 +40,6 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
58
40
  assert_equal 'C:/nonexistent', @cmd.options[:directory]
59
41
  end
60
42
 
61
- def test_handle_options_invalid
62
- e = assert_raises OptionParser::InvalidOption do
63
- @cmd.handle_options %w[--no-modern --no-legacy]
64
- end
65
-
66
- assert_equal 'invalid option: --no-legacy no indicies will be built',
67
- e.message
68
-
69
- @cmd = Gem::Commands::GenerateIndexCommand.new
70
- e = assert_raises OptionParser::InvalidOption do
71
- @cmd.handle_options %w[--no-legacy --no-modern]
72
- end
73
-
74
- assert_equal 'invalid option: --no-modern no indicies will be built',
75
- e.message
76
- end
77
-
78
- def test_handle_options_legacy
79
- @cmd.handle_options %w[--legacy]
80
-
81
- assert @cmd.options[:build_legacy]
82
- assert @cmd.options[:build_modern], ':build_modern not set'
83
- end
84
-
85
- def test_handle_options_modern
86
- @cmd.handle_options %w[--modern]
87
-
88
- assert @cmd.options[:build_legacy]
89
- assert @cmd.options[:build_modern], ':build_modern not set'
90
- end
91
-
92
- def test_handle_options_no_legacy
93
- @cmd.handle_options %w[--no-legacy]
94
-
95
- refute @cmd.options[:build_legacy]
96
- assert @cmd.options[:build_modern]
97
- end
98
-
99
- def test_handle_options_no_modern
100
- @cmd.handle_options %w[--no-modern]
101
-
102
- assert @cmd.options[:build_legacy]
103
- refute @cmd.options[:build_modern]
104
- end
105
-
106
- def test_handle_options_rss_gems_host
107
- @cmd.handle_options %w[--rss-gems-host gems.example.com]
108
-
109
- assert_equal 'gems.example.com', @cmd.options[:rss_gems_host]
110
- end
111
-
112
- def test_handle_options_rss_host
113
- @cmd.handle_options %w[--rss-host example.com]
114
-
115
- assert_equal 'example.com', @cmd.options[:rss_host]
116
- end
117
-
118
- def test_handle_options_rss_title
119
- @cmd.handle_options %w[--rss-title Example\ Gems]
120
-
121
- assert_equal 'Example Gems', @cmd.options[:rss_title]
122
- end
123
-
124
43
  def test_handle_options_update
125
44
  @cmd.handle_options %w[--update]
126
45
 
@@ -1,8 +1,9 @@
1
1
  require "rubygems"
2
2
  require "rubygems/test_case"
3
3
  require "rubygems/commands/help_command"
4
- require "rubygems/format"
4
+ require "rubygems/package"
5
5
  require "rubygems/command_manager"
6
+ require File.expand_path('../rubygems_plugin', __FILE__)
6
7
 
7
8
  class TestGemCommandsHelpCommand < Gem::TestCase
8
9
  def setup
@@ -1,21 +1,23 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/install_command'
3
3
 
4
- begin
5
- gem "rdoc"
6
- gem "json"
7
- rescue Gem::LoadError
8
- # ignore
9
- end
10
-
11
4
  class TestGemCommandsInstallCommand < Gem::TestCase
12
5
 
13
6
  def setup
14
7
  super
15
8
 
16
9
  @cmd = Gem::Commands::InstallCommand.new
17
- @cmd.options[:generate_rdoc] = false
18
- @cmd.options[:generate_ri] = false
10
+ @cmd.options[:document] = []
11
+
12
+ @gemdeps = "tmp_install_gemdeps"
13
+ @orig_args = Gem::Command.build_args
14
+ end
15
+
16
+ def teardown
17
+ super
18
+
19
+ Gem::Command.build_args = @orig_args
20
+ File.unlink @gemdeps if File.file? @gemdeps
19
21
  end
20
22
 
21
23
  def test_execute_exclude_prerelease
@@ -36,8 +38,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
36
38
  assert_equal 0, e.exit_code, @ui.error
37
39
  end
38
40
 
39
- assert_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
40
- refute_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
41
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
41
42
  end
42
43
 
43
44
  def test_execute_explicit_version_includes_prerelease
@@ -61,26 +62,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
61
62
  assert_equal 0, e.exit_code, @ui.error
62
63
  end
63
64
 
64
- refute_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
65
- assert_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
66
- end
67
-
68
- def test_execute_include_dependencies
69
- @cmd.options[:include_dependencies] = true
70
- @cmd.options[:args] = []
71
-
72
- assert_raises Gem::CommandLineError do
73
- use_ui @ui do
74
- @cmd.execute
75
- end
76
- end
77
-
78
- output = @ui.output.split "\n"
79
- assert_equal "INFO: `gem install -y` is now default and will be removed",
80
- output.shift
81
- assert_equal "INFO: use --ignore-dependencies to install only the gems you list",
82
- output.shift
83
- assert output.empty?, output.inspect
65
+ assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
84
66
  end
85
67
 
86
68
  def test_execute_local
@@ -104,13 +86,14 @@ class TestGemCommandsInstallCommand < Gem::TestCase
104
86
  end
105
87
  end
106
88
 
89
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
90
+
107
91
  out = @ui.output.split "\n"
108
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
109
92
  assert_equal "1 gem installed", out.shift
110
93
  assert out.empty?, out.inspect
111
94
  end
112
95
 
113
- def test_no_user_install
96
+ def test_execute_no_user_install
114
97
  skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
115
98
 
116
99
  util_setup_fake_fetcher
@@ -206,8 +189,8 @@ class TestGemCommandsInstallCommand < Gem::TestCase
206
189
 
207
190
  errs = @ui.error.split("\n")
208
191
 
209
- assert_match(/WARNING: Error fetching data/, errs.shift)
210
192
  assert_match(/ould not find a valid gem 'nonexistent'/, errs.shift)
193
+ assert_match(%r!Unable to download data from http://not-there.nothing!, errs.shift)
211
194
  end
212
195
 
213
196
  def test_execute_nonexistent_with_hint
@@ -234,7 +217,92 @@ ERROR: Possible alternatives: non_existent_with_hint
234
217
  assert_equal expected, @ui.error
235
218
  end
236
219
 
237
- def test_execute_prerelease
220
+ def test_execute_nonexistent_with_dashes
221
+ misspelled = "non-existent_with-hint"
222
+ correctly_spelled = "nonexistent-with_hint"
223
+
224
+ util_setup_fake_fetcher
225
+ util_setup_spec_fetcher quick_spec(correctly_spelled, '2')
226
+
227
+ @cmd.options[:args] = [misspelled]
228
+
229
+ use_ui @ui do
230
+ e = assert_raises Gem::SystemExitException do
231
+ @cmd.execute
232
+ end
233
+
234
+ assert_equal 2, e.exit_code
235
+ end
236
+
237
+ expected = ["ERROR: Could not find a valid gem 'non-existent_with-hint' (>= 0) in any repository", "ERROR: Possible alternatives: nonexistent-with_hint"]
238
+
239
+ output = @ui.error.split "\n"
240
+
241
+ assert_equal expected, output
242
+ end
243
+
244
+ def test_execute_conflicting_install_options
245
+ @cmd.options[:user_install] = true
246
+ @cmd.options[:install_dir] = "whatever"
247
+
248
+ use_ui @ui do
249
+ assert_raises Gem::MockGemUi::TermError do
250
+ @cmd.execute
251
+ end
252
+ end
253
+
254
+ expected = "ERROR: Use --install-dir or --user-install but not both\n"
255
+
256
+ assert_equal expected, @ui.error
257
+ end
258
+
259
+ def test_execute_prerelease_skipped_when_no_flag_set
260
+ util_setup_fake_fetcher :prerelease
261
+ util_clear_gems
262
+ util_setup_spec_fetcher @a1, @a2_pre
263
+
264
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
265
+ read_binary(@a1.cache_file)
266
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
267
+ read_binary(@a2_pre.cache_file)
268
+
269
+ @cmd.options[:prerelease] = false
270
+ @cmd.options[:args] = [@a2_pre.name]
271
+
272
+ use_ui @ui do
273
+ e = assert_raises Gem::SystemExitException do
274
+ @cmd.execute
275
+ end
276
+ assert_equal 0, e.exit_code, @ui.error
277
+ end
278
+
279
+ assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
280
+ end
281
+
282
+ def test_execute_prerelease_wins_over_previous_ver
283
+ util_setup_fake_fetcher :prerelease
284
+ util_clear_gems
285
+ util_setup_spec_fetcher @a1, @a2_pre
286
+
287
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
288
+ read_binary(@a1.cache_file)
289
+ @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
290
+ read_binary(@a2_pre.cache_file)
291
+
292
+ @cmd.options[:prerelease] = true
293
+ @cmd.options[:args] = [@a2_pre.name]
294
+
295
+ use_ui @ui do
296
+ e = assert_raises Gem::SystemExitException do
297
+ @cmd.execute
298
+ end
299
+ assert_equal 0, e.exit_code, @ui.error
300
+ end
301
+
302
+ assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
303
+ end
304
+
305
+ def test_execute_prerelease_skipped_when_non_pre_available
238
306
  util_setup_fake_fetcher :prerelease
239
307
  util_clear_gems
240
308
  util_setup_spec_fetcher @a2, @a2_pre
@@ -254,14 +322,82 @@ ERROR: Possible alternatives: non_existent_with_hint
254
322
  assert_equal 0, e.exit_code, @ui.error
255
323
  end
256
324
 
257
- refute_match(/Successfully installed #{@a2.full_name}$/, @ui.output)
258
- assert_match(/Successfully installed #{@a2_pre.full_name}$/, @ui.output)
325
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
259
326
  end
260
327
 
261
- def test_execute_remote
262
- @cmd.options[:generate_rdoc] = true
263
- @cmd.options[:generate_ri] = true
328
+ def test_execute_rdoc
329
+ util_setup_fake_fetcher
330
+
331
+ Gem.done_installing(&Gem::RDoc.method(:generation_hook))
332
+
333
+ @cmd.options[:document] = %w[rdoc ri]
334
+ @cmd.options[:domain] = :local
335
+
336
+ FileUtils.mv @a2.cache_file, @tempdir
264
337
 
338
+ @cmd.options[:args] = [@a2.name]
339
+
340
+ use_ui @ui do
341
+ # Don't use Dir.chdir with a block, it warnings a lot because
342
+ # of a downstream Dir.chdir with a block
343
+ old = Dir.getwd
344
+
345
+ begin
346
+ Dir.chdir @tempdir
347
+ e = assert_raises Gem::SystemExitException do
348
+ @cmd.execute
349
+ end
350
+ ensure
351
+ Dir.chdir old
352
+ end
353
+
354
+ assert_equal 0, e.exit_code
355
+ end
356
+
357
+ wait_for_child_process_to_exit
358
+
359
+ assert_path_exists File.join(@a2.doc_dir, 'ri')
360
+ assert_path_exists File.join(@a2.doc_dir, 'rdoc')
361
+ end
362
+
363
+ def test_execute_saves_build_args
364
+ util_setup_fake_fetcher
365
+
366
+ args = %w!--with-awesome=true --more-awesome=yes!
367
+
368
+ Gem::Command.build_args = args
369
+
370
+ @cmd.options[:domain] = :local
371
+
372
+ FileUtils.mv @a2.cache_file, @tempdir
373
+
374
+ @cmd.options[:args] = [@a2.name]
375
+
376
+ use_ui @ui do
377
+ # Don't use Dir.chdir with a block, it warnings a lot because
378
+ # of a downstream Dir.chdir with a block
379
+ old = Dir.getwd
380
+
381
+ begin
382
+ Dir.chdir @tempdir
383
+ e = assert_raises Gem::SystemExitException do
384
+ @cmd.execute
385
+ end
386
+ ensure
387
+ Dir.chdir old
388
+ end
389
+
390
+ assert_equal 0, e.exit_code
391
+ end
392
+
393
+ path = @a2.build_info_file
394
+ assert_path_exists path
395
+
396
+ assert_equal args, @a2.build_args
397
+ end
398
+
399
+
400
+ def test_execute_remote
265
401
  util_setup_fake_fetcher
266
402
  util_setup_spec_fetcher
267
403
 
@@ -279,16 +415,56 @@ ERROR: Possible alternatives: non_existent_with_hint
279
415
  assert_equal 0, e.exit_code
280
416
  end
281
417
 
418
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
419
+
282
420
  out = @ui.output.split "\n"
283
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
284
421
  assert_equal "1 gem installed", out.shift
285
- assert_equal "Installing ri documentation for #{@a2.full_name}...",
286
- out.shift
287
- assert_equal "Installing RDoc documentation for #{@a2.full_name}...",
288
- out.shift
289
422
  assert out.empty?, out.inspect
290
423
  end
291
424
 
425
+ def test_execute_remote_ignores_files
426
+ util_setup_fake_fetcher
427
+ util_setup_spec_fetcher
428
+
429
+ @cmd.options[:domain] = :remote
430
+
431
+ FileUtils.mv @a2.cache_file, @tempdir
432
+
433
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
434
+ read_binary(@a1.cache_file)
435
+
436
+ @cmd.options[:args] = [@a2.name]
437
+
438
+ gemdir = File.join @gemhome, 'specifications'
439
+
440
+ a2_gemspec = File.join(gemdir, "a-2.gemspec")
441
+ a1_gemspec = File.join(gemdir, "a-1.gemspec")
442
+
443
+ FileUtils.rm_rf a1_gemspec
444
+ FileUtils.rm_rf a2_gemspec
445
+
446
+ start = Dir["#{gemdir}/*"]
447
+
448
+ use_ui @ui do
449
+ Dir.chdir @tempdir do
450
+ e = assert_raises Gem::SystemExitException do
451
+ @cmd.execute
452
+ end
453
+ assert_equal 0, e.exit_code
454
+ end
455
+ end
456
+
457
+ assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
458
+
459
+ out = @ui.output.split "\n"
460
+ assert_equal "1 gem installed", out.shift
461
+ assert out.empty?, out.inspect
462
+
463
+ fin = Dir["#{gemdir}/*"]
464
+
465
+ assert_equal [a1_gemspec], fin - start
466
+ end
467
+
292
468
  def test_execute_two
293
469
  util_setup_fake_fetcher
294
470
  @cmd.options[:domain] = :local
@@ -312,13 +488,33 @@ ERROR: Possible alternatives: non_existent_with_hint
312
488
  end
313
489
  end
314
490
 
491
+ assert_equal %w[a-2 b-2], @cmd.installed_specs.map { |spec| spec.full_name }
492
+
315
493
  out = @ui.output.split "\n"
316
- assert_equal "Successfully installed #{@a2.full_name}", out.shift
317
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
318
494
  assert_equal "2 gems installed", out.shift
319
495
  assert out.empty?, out.inspect
320
496
  end
321
497
 
498
+ def test_execute_two_version
499
+ @cmd.options[:args] = %w[a b]
500
+ @cmd.options[:version] = Gem::Requirement.new("> 1")
501
+
502
+ use_ui @ui do
503
+ e = assert_raises Gem::MockGemUi::TermError do
504
+ @cmd.execute
505
+ end
506
+
507
+ assert_equal 1, e.exit_code
508
+ end
509
+
510
+ assert_empty @cmd.installed_specs
511
+
512
+ msg = "ERROR: Can't use --version w/ multiple gems. Use name:ver instead."
513
+
514
+ assert_empty @ui.output
515
+ assert_equal msg, @ui.error.chomp
516
+ end
517
+
322
518
  def test_execute_conservative
323
519
  util_setup_fake_fetcher
324
520
  util_setup_spec_fetcher
@@ -344,11 +540,414 @@ ERROR: Possible alternatives: non_existent_with_hint
344
540
  end
345
541
  end
346
542
 
543
+ assert_equal %w[b-2], @cmd.installed_specs.map { |spec| spec.full_name }
544
+
347
545
  out = @ui.output.split "\n"
348
546
  assert_equal "", @ui.error
349
- assert_equal "Successfully installed #{@b2.full_name}", out.shift
350
547
  assert_equal "1 gem installed", out.shift
351
548
  assert out.empty?, out.inspect
352
549
  end
550
+
551
+ def test_parses_requirement_from_gemname
552
+ util_setup_fake_fetcher
553
+ @cmd.options[:domain] = :local
554
+
555
+ FileUtils.mv @a2.cache_file, @tempdir
556
+
557
+ FileUtils.mv @b2.cache_file, @tempdir
558
+
559
+ req = "#{@a2.name}:10.0"
560
+
561
+ @cmd.options[:args] = [req]
562
+
563
+ e = nil
564
+ use_ui @ui do
565
+ orig_dir = Dir.pwd
566
+ begin
567
+ Dir.chdir @tempdir
568
+ e = assert_raises Gem::SystemExitException do
569
+ @cmd.execute
570
+ end
571
+ ensure
572
+ Dir.chdir orig_dir
573
+ end
574
+ end
575
+
576
+ assert_equal 2, e.exit_code
577
+ assert_match %r!Could not find a valid gem 'a' \(= 10.0\)!, @ui.error
578
+ end
579
+
580
+ def test_show_errors_on_failure
581
+ Gem.sources.replace ["http://not-there.nothing"]
582
+
583
+ @cmd.options[:args] = ["blah"]
584
+
585
+ e = nil
586
+ use_ui @ui do
587
+ orig_dir = Dir.pwd
588
+ begin
589
+ Dir.chdir @tempdir
590
+ e = assert_raises Gem::SystemExitException do
591
+ @cmd.execute
592
+ end
593
+ ensure
594
+ Dir.chdir orig_dir
595
+ end
596
+ end
597
+
598
+ assert_equal 2, e.exit_code
599
+ assert_match %r!Could not find a valid gem 'blah' \(>= 0\)!, @ui.error
600
+ assert_match %r!Unable to download data from http://not-there\.nothing!, @ui.error
601
+ end
602
+
603
+ def test_show_source_problems_even_on_success
604
+ util_setup_fake_fetcher
605
+ util_setup_spec_fetcher
606
+
607
+ Gem.sources << "http://nonexistent.example"
608
+
609
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
610
+ read_binary(@a2.cache_file)
611
+
612
+ @cmd.options[:args] = [@a2.name]
613
+
614
+ use_ui @ui do
615
+ e = assert_raises Gem::SystemExitException do
616
+ capture_io do
617
+ @cmd.execute
618
+ end
619
+ end
620
+ assert_equal 0, e.exit_code
621
+ end
622
+
623
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
624
+
625
+ out = @ui.output.split "\n"
626
+ assert_equal "1 gem installed", out.shift
627
+ assert out.empty?, out.inspect
628
+
629
+ e = @ui.error
630
+
631
+ x = "WARNING: Unable to pull data from 'http://nonexistent.example': no data for http://nonexistent.example/latest_specs.4.8.gz (http://nonexistent.example/latest_specs.4.8.gz)\n"
632
+ assert_equal x, e
633
+ end
634
+
635
+ def test_execute_installs_dependencies
636
+ r, r_gem = util_gem 'r', '1', 'q' => '= 1'
637
+ q, q_gem = util_gem 'q', '1'
638
+
639
+ util_setup_fake_fetcher
640
+ util_setup_spec_fetcher r, q
641
+
642
+ Gem::Specification.reset
643
+
644
+ @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem)
645
+ @fetcher.data["#{@gem_repo}gems/#{r.file_name}"] = read_binary(r_gem)
646
+
647
+ @cmd.options[:args] = ["r"]
648
+
649
+ e = nil
650
+ use_ui @ui do
651
+ e = assert_raises Gem::SystemExitException do
652
+ capture_io do
653
+ @cmd.execute
654
+ end
655
+ end
656
+ end
657
+
658
+ out = @ui.output.split "\n"
659
+ assert_equal "2 gems installed", out.shift
660
+ assert out.empty?, out.inspect
661
+
662
+ assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name }
663
+
664
+ assert_equal 0, e.exit_code
665
+ end
666
+
667
+ def test_execute_satisfy_deps_of_local_from_sources
668
+ r, r_gem = util_gem 'r', '1', 'q' => '= 1'
669
+ q, q_gem = util_gem 'q', '1'
670
+
671
+ util_setup_fake_fetcher
672
+ util_setup_spec_fetcher r, q
673
+
674
+ Gem::Specification.reset
675
+
676
+ @fetcher.data["#{@gem_repo}gems/#{q.file_name}"] = read_binary(q_gem)
677
+
678
+ @cmd.options[:args] = [r_gem]
679
+
680
+ use_ui @ui do
681
+ e = assert_raises Gem::SystemExitException do
682
+ capture_io do
683
+ @cmd.execute
684
+ end
685
+ end
686
+ assert_equal 0, e.exit_code
687
+ end
688
+
689
+ assert_equal %w[q-1 r-1], @cmd.installed_specs.map { |spec| spec.full_name }
690
+
691
+ out = @ui.output.split "\n"
692
+ assert_equal "2 gems installed", out.shift
693
+ assert out.empty?, out.inspect
694
+ end
695
+
696
+ def test_execute_uses_from_a_gemdeps
697
+ util_setup_fake_fetcher
698
+ util_setup_spec_fetcher
699
+
700
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
701
+ read_binary(@a2.cache_file)
702
+
703
+ File.open @gemdeps, "w" do |f|
704
+ f << "gem 'a'"
705
+ end
706
+
707
+ @cmd.options[:gemdeps] = @gemdeps
708
+
709
+ use_ui @ui do
710
+ e = assert_raises Gem::SystemExitException do
711
+ capture_io do
712
+ @cmd.execute
713
+ end
714
+ end
715
+ assert_equal 0, e.exit_code
716
+ end
717
+
718
+ assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
719
+
720
+ out = @ui.output.split "\n"
721
+ assert_equal "Using a (2)", out.shift
722
+ assert out.empty?, out.inspect
723
+ end
724
+
725
+ def test_execute_installs_from_a_gemdeps
726
+ util_setup_fake_fetcher
727
+ util_setup_spec_fetcher @a2
728
+ util_clear_gems
729
+
730
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
731
+ read_binary(@a2.cache_file)
732
+
733
+ File.open @gemdeps, "w" do |f|
734
+ f << "gem 'a'"
735
+ end
736
+
737
+ @cmd.options[:gemdeps] = @gemdeps
738
+
739
+ use_ui @ui do
740
+ e = assert_raises Gem::SystemExitException do
741
+ capture_io do
742
+ @cmd.execute
743
+ end
744
+ end
745
+ assert_equal 0, e.exit_code
746
+ end
747
+
748
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
749
+
750
+ out = @ui.output.split "\n"
751
+ assert_equal "Installing a (2)", out.shift
752
+ assert out.empty?, out.inspect
753
+ end
754
+
755
+ def test_execute_installs_deps_a_gemdeps
756
+ q, q_gem = util_gem 'q', '1.0'
757
+ r, r_gem = util_gem 'r', '2.0', 'q' => nil
758
+
759
+ util_setup_fake_fetcher
760
+ util_setup_spec_fetcher q, r
761
+ util_clear_gems
762
+
763
+ add_to_fetcher q, q_gem
764
+ add_to_fetcher r, r_gem
765
+
766
+ File.open @gemdeps, "w" do |f|
767
+ f << "gem 'r'"
768
+ end
769
+
770
+ @cmd.options[:gemdeps] = @gemdeps
771
+
772
+ use_ui @ui do
773
+ e = assert_raises Gem::SystemExitException do
774
+ capture_io do
775
+ @cmd.execute
776
+ end
777
+ end
778
+ assert_equal 0, e.exit_code
779
+ end
780
+
781
+ names = @cmd.installed_specs.map { |spec| spec.full_name }
782
+
783
+ assert_equal %w[q-1.0 r-2.0], names
784
+
785
+ out = @ui.output.split "\n"
786
+ assert_equal "Installing q (1.0)", out.shift
787
+ assert_equal "Installing r (2.0)", out.shift
788
+ assert out.empty?, out.inspect
789
+ end
790
+
791
+ def test_execute_uses_deps_a_gemdeps
792
+ q, _ = util_gem 'q', '1.0'
793
+ r, r_gem = util_gem 'r', '2.0', 'q' => nil
794
+
795
+ util_setup_fake_fetcher
796
+ util_setup_spec_fetcher q, r
797
+ util_clear_gems
798
+
799
+ add_to_fetcher r, r_gem
800
+
801
+ Gem::Specification.add_specs q
802
+
803
+ File.open @gemdeps, "w" do |f|
804
+ f << "gem 'r'"
805
+ end
806
+
807
+ @cmd.options[:gemdeps] = @gemdeps
808
+
809
+ use_ui @ui do
810
+ e = assert_raises Gem::SystemExitException do
811
+ capture_io do
812
+ @cmd.execute
813
+ end
814
+ end
815
+ assert_equal 0, e.exit_code
816
+ end
817
+
818
+ names = @cmd.installed_specs.map { |spec| spec.full_name }
819
+
820
+ assert_equal %w[r-2.0], names
821
+
822
+ out = @ui.output.split "\n"
823
+ assert_equal "Using q (1.0)", out.shift
824
+ assert_equal "Installing r (2.0)", out.shift
825
+ assert out.empty?, out.inspect
826
+ end
827
+
828
+ def test_execute_installs_deps_a_gemdeps_into_a_path
829
+ q, q_gem = util_gem 'q', '1.0'
830
+ r, r_gem = util_gem 'r', '2.0', 'q' => nil
831
+
832
+ util_setup_fake_fetcher
833
+ util_setup_spec_fetcher q, r
834
+ util_clear_gems
835
+
836
+ add_to_fetcher q, q_gem
837
+ add_to_fetcher r, r_gem
838
+
839
+ File.open @gemdeps, "w" do |f|
840
+ f << "gem 'r'"
841
+ end
842
+
843
+ @cmd.options[:install_dir] = "gf-path"
844
+ @cmd.options[:gemdeps] = @gemdeps
845
+
846
+ use_ui @ui do
847
+ e = assert_raises Gem::SystemExitException do
848
+ capture_io do
849
+ @cmd.execute
850
+ end
851
+ end
852
+ assert_equal 0, e.exit_code
853
+ end
854
+
855
+ names = @cmd.installed_specs.map { |spec| spec.full_name }
856
+
857
+ assert_equal %w[q-1.0 r-2.0], names
858
+
859
+ out = @ui.output.split "\n"
860
+ assert_equal "Installing q (1.0)", out.shift
861
+ assert_equal "Installing r (2.0)", out.shift
862
+ assert out.empty?, out.inspect
863
+
864
+ assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed"
865
+ assert File.file?("gf-path/specifications/r-2.0.gemspec"), "not installed"
866
+ end
867
+
868
+ def test_execute_with_gemdeps_path_ignores_system
869
+ q, q_gem = util_gem 'q', '1.0'
870
+ r, r_gem = util_gem 'r', '2.0', 'q' => nil
871
+
872
+ util_setup_fake_fetcher
873
+ util_setup_spec_fetcher q, r
874
+ util_clear_gems
875
+
876
+ add_to_fetcher q, q_gem
877
+ add_to_fetcher r, r_gem
878
+
879
+ Gem::Specification.add_specs q
880
+
881
+ File.open @gemdeps, "w" do |f|
882
+ f << "gem 'r'"
883
+ end
884
+
885
+ @cmd.options[:install_dir] = "gf-path"
886
+ @cmd.options[:gemdeps] = @gemdeps
887
+
888
+ use_ui @ui do
889
+ e = assert_raises Gem::SystemExitException do
890
+ capture_io do
891
+ @cmd.execute
892
+ end
893
+ end
894
+ assert_equal 0, e.exit_code
895
+ end
896
+
897
+ names = @cmd.installed_specs.map { |spec| spec.full_name }
898
+
899
+ assert_equal %w[q-1.0 r-2.0], names
900
+
901
+ out = @ui.output.split "\n"
902
+ assert_equal "Installing q (1.0)", out.shift
903
+ assert_equal "Installing r (2.0)", out.shift
904
+ assert out.empty?, out.inspect
905
+
906
+ assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed"
907
+ assert File.file?("gf-path/specifications/r-2.0.gemspec"), "not installed"
908
+ end
909
+
910
+ def test_execute_uses_deps_a_gemdeps_with_a_path
911
+ q, q_gem = util_gem 'q', '1.0'
912
+ r, r_gem = util_gem 'r', '2.0', 'q' => nil
913
+
914
+ util_setup_fake_fetcher
915
+ util_setup_spec_fetcher q, r
916
+ util_clear_gems
917
+
918
+ add_to_fetcher r, r_gem
919
+
920
+ i = Gem::Installer.new q_gem, :install_dir => "gf-path"
921
+ i.install
922
+
923
+ assert File.file?("gf-path/specifications/q-1.0.gemspec"), "not installed"
924
+
925
+ File.open @gemdeps, "w" do |f|
926
+ f << "gem 'r'"
927
+ end
928
+
929
+ @cmd.options[:install_dir] = "gf-path"
930
+ @cmd.options[:gemdeps] = @gemdeps
931
+
932
+ use_ui @ui do
933
+ e = assert_raises Gem::SystemExitException do
934
+ capture_io do
935
+ @cmd.execute
936
+ end
937
+ end
938
+ assert_equal 0, e.exit_code
939
+ end
940
+
941
+ names = @cmd.installed_specs.map { |spec| spec.full_name }
942
+
943
+ assert_equal %w[r-2.0], names
944
+
945
+ out = @ui.output.split "\n"
946
+ assert_equal "Using q (1.0)", out.shift
947
+ assert_equal "Installing r (2.0)", out.shift
948
+ assert out.empty?, out.inspect
949
+ end
950
+
951
+
353
952
  end
354
953