rubygems-update 3.1.6 → 3.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (703) hide show
  1. checksums.yaml +4 -4
  2. data/{History.txt → CHANGELOG.md} +1452 -514
  3. data/CODE_OF_CONDUCT.md +55 -19
  4. data/CONTRIBUTING.md +74 -27
  5. data/Manifest.txt +154 -117
  6. data/POLICIES.md +27 -19
  7. data/README.md +10 -8
  8. data/UPGRADING.md +5 -81
  9. data/bin/gem +3 -8
  10. data/bin/update_rubygems +5 -5
  11. data/bundler/CHANGELOG.md +2358 -1430
  12. data/bundler/README.md +7 -9
  13. data/bundler/UPGRADING.md +27 -34
  14. data/bundler/bundler.gemspec +8 -11
  15. data/bundler/exe/bundle +10 -8
  16. data/bundler/exe/bundler +1 -1
  17. data/bundler/lib/bundler/.document +1 -0
  18. data/bundler/lib/bundler/build_metadata.rb +4 -12
  19. data/bundler/lib/bundler/cli/add.rb +1 -1
  20. data/bundler/lib/bundler/cli/binstubs.rb +6 -2
  21. data/bundler/lib/bundler/cli/cache.rb +3 -8
  22. data/bundler/lib/bundler/cli/check.rb +4 -2
  23. data/bundler/lib/bundler/cli/clean.rb +1 -1
  24. data/bundler/lib/bundler/cli/common.rb +31 -3
  25. data/bundler/lib/bundler/cli/config.rb +10 -1
  26. data/bundler/lib/bundler/cli/console.rb +1 -1
  27. data/bundler/lib/bundler/cli/doctor.rb +25 -6
  28. data/bundler/lib/bundler/cli/exec.rb +5 -10
  29. data/bundler/lib/bundler/cli/fund.rb +36 -0
  30. data/bundler/lib/bundler/cli/gem.rb +219 -28
  31. data/bundler/lib/bundler/cli/info.rb +38 -6
  32. data/bundler/lib/bundler/cli/init.rb +3 -3
  33. data/bundler/lib/bundler/cli/inject.rb +1 -1
  34. data/bundler/lib/bundler/cli/install.rb +25 -54
  35. data/bundler/lib/bundler/cli/issue.rb +5 -4
  36. data/bundler/lib/bundler/cli/list.rb +19 -11
  37. data/bundler/lib/bundler/cli/lock.rb +5 -1
  38. data/bundler/lib/bundler/cli/open.rb +1 -2
  39. data/bundler/lib/bundler/cli/outdated.rb +105 -76
  40. data/bundler/lib/bundler/cli/platform.rb +2 -2
  41. data/bundler/lib/bundler/cli/plugin.rb +10 -0
  42. data/bundler/lib/bundler/cli/pristine.rb +5 -0
  43. data/bundler/lib/bundler/cli/remove.rb +1 -2
  44. data/bundler/lib/bundler/cli/show.rb +2 -2
  45. data/bundler/lib/bundler/cli/update.rb +20 -9
  46. data/bundler/lib/bundler/cli.rb +106 -83
  47. data/bundler/lib/bundler/compact_index_client/cache.rb +6 -23
  48. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  49. data/bundler/lib/bundler/compact_index_client/updater.rb +29 -25
  50. data/bundler/lib/bundler/compact_index_client.rb +3 -9
  51. data/bundler/lib/bundler/current_ruby.rb +17 -6
  52. data/bundler/lib/bundler/definition.rb +297 -396
  53. data/bundler/lib/bundler/dep_proxy.rb +16 -9
  54. data/bundler/lib/bundler/dependency.rb +22 -77
  55. data/bundler/lib/bundler/digest.rb +71 -0
  56. data/bundler/lib/bundler/dsl.rb +76 -83
  57. data/bundler/lib/bundler/endpoint_specification.rb +16 -14
  58. data/bundler/lib/bundler/env.rb +2 -2
  59. data/bundler/lib/bundler/environment_preserver.rb +29 -2
  60. data/bundler/lib/bundler/errors.rb +30 -3
  61. data/bundler/lib/bundler/feature_flag.rb +0 -9
  62. data/bundler/lib/bundler/fetcher/base.rb +7 -9
  63. data/bundler/lib/bundler/fetcher/compact_index.rb +11 -16
  64. data/bundler/lib/bundler/fetcher/downloader.rb +10 -7
  65. data/bundler/lib/bundler/fetcher/index.rb +2 -30
  66. data/bundler/lib/bundler/fetcher.rb +24 -25
  67. data/bundler/lib/bundler/friendly_errors.rb +46 -47
  68. data/bundler/lib/bundler/gem_helper.rb +53 -31
  69. data/bundler/lib/bundler/gem_helpers.rb +43 -24
  70. data/bundler/lib/bundler/gem_version_promoter.rb +10 -20
  71. data/bundler/lib/bundler/graph.rb +1 -1
  72. data/bundler/lib/bundler/index.rb +19 -25
  73. data/bundler/lib/bundler/injector.rb +38 -6
  74. data/bundler/lib/bundler/inline.rb +4 -13
  75. data/bundler/lib/bundler/installer/gem_installer.rb +19 -24
  76. data/bundler/lib/bundler/installer/parallel_installer.rb +46 -25
  77. data/bundler/lib/bundler/installer/standalone.rb +58 -11
  78. data/bundler/lib/bundler/installer.rb +51 -81
  79. data/bundler/lib/bundler/lazy_specification.rb +79 -36
  80. data/bundler/lib/bundler/lockfile_generator.rb +3 -3
  81. data/bundler/lib/bundler/lockfile_parser.rb +19 -44
  82. data/bundler/lib/bundler/man/.document +1 -0
  83. data/bundler/{man → lib/bundler/man}/bundle-add.1 +21 -5
  84. data/bundler/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +16 -4
  85. data/bundler/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  86. data/bundler/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  87. data/bundler/{man → lib/bundler/man}/bundle-cache.1 +7 -1
  88. data/bundler/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +7 -0
  89. data/bundler/{man → lib/bundler/man}/bundle-check.1 +1 -1
  90. data/bundler/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  91. data/bundler/{man → lib/bundler/man}/bundle-config.1 +65 -47
  92. data/bundler/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +74 -65
  93. data/bundler/lib/bundler/man/bundle-console.1 +53 -0
  94. data/bundler/lib/bundler/man/bundle-console.1.ronn +44 -0
  95. data/bundler/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  96. data/bundler/{man → lib/bundler/man}/bundle-exec.1 +2 -2
  97. data/bundler/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +1 -1
  98. data/bundler/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  99. data/bundler/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  100. data/bundler/lib/bundler/man/bundle-help.1 +13 -0
  101. data/bundler/lib/bundler/man/bundle-help.1.ronn +12 -0
  102. data/bundler/{man → lib/bundler/man}/bundle-info.1 +1 -1
  103. data/bundler/{man → lib/bundler/man}/bundle-init.1 +1 -1
  104. data/bundler/{man → lib/bundler/man}/bundle-inject.1 +5 -2
  105. data/bundler/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +3 -1
  106. data/bundler/{man → lib/bundler/man}/bundle-install.1 +35 -4
  107. data/bundler/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +33 -5
  108. data/bundler/{man → lib/bundler/man}/bundle-list.1 +7 -7
  109. data/bundler/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  110. data/bundler/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  111. data/bundler/{man → lib/bundler/man}/bundle-open.1 +1 -1
  112. data/bundler/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  113. data/bundler/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  114. data/bundler/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  115. data/bundler/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  116. data/bundler/lib/bundler/man/bundle-plugin.1 +81 -0
  117. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  118. data/bundler/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  119. data/bundler/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  120. data/bundler/{man → lib/bundler/man}/bundle-show.1 +1 -1
  121. data/bundler/{man → lib/bundler/man}/bundle-update.1 +5 -5
  122. data/bundler/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +5 -4
  123. data/bundler/lib/bundler/man/bundle-version.1 +35 -0
  124. data/bundler/lib/bundler/man/bundle-version.1.ronn +24 -0
  125. data/bundler/{man → lib/bundler/man}/bundle-viz.1 +4 -1
  126. data/bundler/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +2 -0
  127. data/bundler/{man → lib/bundler/man}/bundle.1 +15 -10
  128. data/bundler/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +12 -7
  129. data/bundler/{man → lib/bundler/man}/gemfile.5 +106 -80
  130. data/bundler/{man → lib/bundler/man}/gemfile.5.ronn +94 -83
  131. data/bundler/{man → lib/bundler/man}/index.txt +4 -0
  132. data/bundler/lib/bundler/match_metadata.rb +13 -0
  133. data/bundler/lib/bundler/match_platform.rb +0 -1
  134. data/bundler/lib/bundler/match_remote_metadata.rb +29 -0
  135. data/bundler/lib/bundler/mirror.rb +2 -2
  136. data/bundler/lib/bundler/plugin/api/source.rb +25 -9
  137. data/bundler/lib/bundler/plugin/dsl.rb +1 -1
  138. data/bundler/lib/bundler/plugin/index.rb +13 -1
  139. data/bundler/lib/bundler/plugin/installer/git.rb +0 -4
  140. data/bundler/lib/bundler/plugin/installer/rubygems.rb +1 -5
  141. data/bundler/lib/bundler/plugin/installer.rb +11 -11
  142. data/bundler/lib/bundler/plugin/source_list.rb +5 -1
  143. data/bundler/lib/bundler/plugin.rb +58 -11
  144. data/bundler/lib/bundler/process_lock.rb +1 -1
  145. data/bundler/lib/bundler/remote_specification.rb +11 -6
  146. data/bundler/lib/bundler/resolver/base.rb +50 -0
  147. data/bundler/lib/bundler/resolver/spec_group.rb +64 -57
  148. data/bundler/lib/bundler/resolver.rb +234 -230
  149. data/bundler/lib/bundler/retry.rb +2 -2
  150. data/bundler/lib/bundler/ruby_dsl.rb +1 -1
  151. data/bundler/lib/bundler/ruby_version.rb +6 -19
  152. data/bundler/lib/bundler/rubygems_ext.rb +194 -33
  153. data/bundler/lib/bundler/rubygems_gem_installer.rb +87 -16
  154. data/bundler/lib/bundler/rubygems_integration.rb +71 -153
  155. data/bundler/lib/bundler/runtime.rb +22 -26
  156. data/bundler/lib/bundler/self_manager.rb +168 -0
  157. data/bundler/lib/bundler/settings.rb +145 -66
  158. data/bundler/lib/bundler/setup.rb +2 -2
  159. data/bundler/lib/bundler/shared_helpers.rb +17 -32
  160. data/bundler/lib/bundler/similarity_detector.rb +1 -1
  161. data/bundler/lib/bundler/source/git/git_proxy.rb +88 -84
  162. data/bundler/lib/bundler/source/git.rb +50 -32
  163. data/bundler/lib/bundler/source/metadata.rb +3 -7
  164. data/bundler/lib/bundler/source/path/installer.rb +10 -10
  165. data/bundler/lib/bundler/source/path.rb +10 -4
  166. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  167. data/bundler/lib/bundler/source/rubygems.rb +201 -179
  168. data/bundler/lib/bundler/source/rubygems_aggregate.rb +68 -0
  169. data/bundler/lib/bundler/source.rb +25 -5
  170. data/bundler/lib/bundler/source_list.rb +105 -63
  171. data/bundler/lib/bundler/source_map.rb +71 -0
  172. data/bundler/lib/bundler/spec_set.rb +62 -57
  173. data/bundler/lib/bundler/stub_specification.rb +30 -10
  174. data/bundler/lib/bundler/templates/Executable +2 -4
  175. data/bundler/lib/bundler/templates/Executable.bundler +8 -8
  176. data/bundler/lib/bundler/templates/Executable.standalone +2 -4
  177. data/bundler/lib/bundler/templates/Gemfile +0 -2
  178. data/bundler/lib/bundler/templates/gems.rb +0 -3
  179. data/bundler/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  180. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  181. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  182. data/bundler/lib/bundler/templates/newgem/README.md.tt +9 -14
  183. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +32 -5
  184. data/bundler/lib/bundler/templates/newgem/bin/console.tt +1 -0
  185. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  186. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  187. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  188. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  189. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  190. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  191. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  192. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  193. data/bundler/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  194. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  195. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  196. data/bundler/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  197. data/bundler/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  198. data/bundler/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  199. data/bundler/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  200. data/bundler/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  201. data/bundler/lib/bundler/ui/shell.rb +6 -6
  202. data/bundler/lib/bundler/uri_credentials_filter.rb +3 -1
  203. data/bundler/lib/bundler/vendor/.document +1 -0
  204. data/bundler/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  205. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  206. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  207. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  208. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  209. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  210. data/bundler/lib/bundler/vendor/molinillo/LICENSE +9 -0
  211. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  212. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  213. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  214. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +37 -5
  215. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +34 -28
  216. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  217. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  218. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  219. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  220. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  221. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  222. data/bundler/lib/bundler/vendor/thor/LICENSE.md +20 -0
  223. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  224. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  225. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  226. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  227. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  228. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  229. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  230. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  231. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  232. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  233. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  234. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  235. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  236. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  237. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  238. data/bundler/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  239. data/bundler/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  240. data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  241. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  242. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  243. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  244. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  245. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  246. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  247. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  248. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  249. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  250. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  251. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  252. data/bundler/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  253. data/bundler/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  254. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  255. data/bundler/lib/bundler/vendored_persistent.rb +0 -7
  256. data/bundler/lib/bundler/vendored_tmpdir.rb +4 -0
  257. data/bundler/lib/bundler/vendored_tsort.rb +4 -0
  258. data/bundler/lib/bundler/version.rb +1 -1
  259. data/bundler/lib/bundler/worker.rb +20 -5
  260. data/bundler/lib/bundler/yaml_serializer.rb +1 -1
  261. data/bundler/lib/bundler.rb +79 -47
  262. data/hide_lib_for_update/note.txt +0 -4
  263. data/lib/rubygems/available_set.rb +7 -9
  264. data/lib/rubygems/basic_specification.rb +23 -21
  265. data/lib/rubygems/bundler_version_finder.rb +26 -53
  266. data/lib/rubygems/command.rb +48 -45
  267. data/lib/rubygems/command_manager.rb +20 -14
  268. data/lib/rubygems/commands/build_command.rb +47 -27
  269. data/lib/rubygems/commands/cert_command.rb +78 -75
  270. data/lib/rubygems/commands/check_command.rb +20 -22
  271. data/lib/rubygems/commands/cleanup_command.rb +30 -26
  272. data/lib/rubygems/commands/contents_command.rb +16 -18
  273. data/lib/rubygems/commands/dependency_command.rb +39 -51
  274. data/lib/rubygems/commands/environment_command.rb +11 -10
  275. data/lib/rubygems/commands/fetch_command.rb +33 -16
  276. data/lib/rubygems/commands/generate_index_command.rb +17 -19
  277. data/lib/rubygems/commands/help_command.rb +6 -6
  278. data/lib/rubygems/commands/info_command.rb +10 -7
  279. data/lib/rubygems/commands/install_command.rb +29 -27
  280. data/lib/rubygems/commands/list_command.rb +9 -8
  281. data/lib/rubygems/commands/lock_command.rb +5 -7
  282. data/lib/rubygems/commands/mirror_command.rb +3 -5
  283. data/lib/rubygems/commands/open_command.rb +10 -14
  284. data/lib/rubygems/commands/outdated_command.rb +5 -7
  285. data/lib/rubygems/commands/owner_command.rb +26 -16
  286. data/lib/rubygems/commands/pristine_command.rb +61 -49
  287. data/lib/rubygems/commands/push_command.rb +22 -59
  288. data/lib/rubygems/commands/query_command.rb +21 -351
  289. data/lib/rubygems/commands/rdoc_command.rb +23 -25
  290. data/lib/rubygems/commands/search_command.rb +8 -8
  291. data/lib/rubygems/commands/server_command.rb +16 -77
  292. data/lib/rubygems/commands/setup_command.rb +255 -229
  293. data/lib/rubygems/commands/signin_command.rb +9 -11
  294. data/lib/rubygems/commands/signout_command.rb +7 -9
  295. data/lib/rubygems/commands/sources_command.rb +27 -25
  296. data/lib/rubygems/commands/specification_command.rb +25 -21
  297. data/lib/rubygems/commands/stale_command.rb +3 -5
  298. data/lib/rubygems/commands/uninstall_command.rb +41 -43
  299. data/lib/rubygems/commands/unpack_command.rb +13 -15
  300. data/lib/rubygems/commands/update_command.rb +132 -74
  301. data/lib/rubygems/commands/which_command.rb +7 -9
  302. data/lib/rubygems/commands/yank_command.rb +16 -19
  303. data/lib/rubygems/compatibility.rb +4 -2
  304. data/lib/rubygems/config_file.rb +42 -26
  305. data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
  306. data/lib/rubygems/core_ext/kernel_require.rb +6 -3
  307. data/lib/rubygems/core_ext/kernel_warn.rb +12 -13
  308. data/lib/rubygems/core_ext/tcpsocket_init.rb +52 -0
  309. data/lib/rubygems/defaults.rb +108 -32
  310. data/lib/rubygems/dependency.rb +21 -22
  311. data/lib/rubygems/dependency_installer.rb +19 -91
  312. data/lib/rubygems/dependency_list.rb +13 -15
  313. data/lib/rubygems/deprecate.rb +102 -8
  314. data/lib/rubygems/doctor.rb +22 -22
  315. data/lib/rubygems/errors.rb +6 -21
  316. data/lib/rubygems/exceptions.rb +33 -34
  317. data/lib/rubygems/ext/build_error.rb +2 -0
  318. data/lib/rubygems/ext/builder.rb +48 -54
  319. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +23 -0
  320. data/lib/rubygems/ext/cargo_builder.rb +321 -0
  321. data/lib/rubygems/ext/cmake_builder.rb +6 -9
  322. data/lib/rubygems/ext/configure_builder.rb +5 -8
  323. data/lib/rubygems/ext/ext_conf_builder.rb +42 -66
  324. data/lib/rubygems/ext/rake_builder.rb +7 -10
  325. data/lib/rubygems/ext.rb +7 -6
  326. data/lib/rubygems/gem_runner.rb +15 -26
  327. data/lib/rubygems/gemcutter_utilities.rb +153 -32
  328. data/lib/rubygems/indexer.rb +30 -49
  329. data/lib/rubygems/install_default_message.rb +2 -2
  330. data/lib/rubygems/install_message.rb +2 -2
  331. data/lib/rubygems/install_update_options.rb +73 -64
  332. data/lib/rubygems/installer.rb +194 -151
  333. data/lib/rubygems/installer_uninstaller_utils.rb +29 -0
  334. data/lib/rubygems/local_remote_options.rb +22 -24
  335. data/lib/rubygems/mock_gem_ui.rb +2 -8
  336. data/lib/rubygems/name_tuple.rb +9 -14
  337. data/lib/rubygems/openssl.rb +7 -0
  338. data/lib/rubygems/optparse/.document +1 -0
  339. data/lib/rubygems/optparse/COPYING +56 -0
  340. data/lib/rubygems/optparse/lib/optionparser.rb +2 -0
  341. data/lib/rubygems/optparse/lib/optparse/ac.rb +54 -0
  342. data/lib/rubygems/optparse/lib/optparse/date.rb +18 -0
  343. data/lib/rubygems/optparse/lib/optparse/kwargs.rb +22 -0
  344. data/lib/rubygems/optparse/lib/optparse/shellwords.rb +7 -0
  345. data/lib/rubygems/optparse/lib/optparse/time.rb +11 -0
  346. data/lib/rubygems/optparse/lib/optparse/uri.rb +7 -0
  347. data/lib/rubygems/optparse/lib/optparse/version.rb +71 -0
  348. data/lib/rubygems/optparse/lib/optparse.rb +2303 -0
  349. data/lib/rubygems/optparse.rb +3 -0
  350. data/lib/rubygems/package/digest_io.rb +0 -2
  351. data/lib/rubygems/package/file_source.rb +2 -4
  352. data/lib/rubygems/package/io_source.rb +4 -2
  353. data/lib/rubygems/package/old.rb +9 -11
  354. data/lib/rubygems/package/tar_header.rb +54 -56
  355. data/lib/rubygems/package/tar_reader/entry.rb +2 -5
  356. data/lib/rubygems/package/tar_reader.rb +1 -4
  357. data/lib/rubygems/package/tar_writer.rb +8 -18
  358. data/lib/rubygems/package.rb +101 -117
  359. data/lib/rubygems/package_task.rb +5 -11
  360. data/lib/rubygems/path_support.rb +2 -9
  361. data/lib/rubygems/platform.rb +101 -76
  362. data/lib/rubygems/psych_tree.rb +1 -3
  363. data/lib/rubygems/query_utils.rb +351 -0
  364. data/lib/rubygems/rdoc.rb +2 -14
  365. data/lib/rubygems/remote_fetcher.rb +48 -74
  366. data/lib/rubygems/request/connection_pools.rb +6 -10
  367. data/lib/rubygems/request/http_pool.rb +2 -4
  368. data/lib/rubygems/request/https_pool.rb +0 -2
  369. data/lib/rubygems/request.rb +26 -31
  370. data/lib/rubygems/request_set/gem_dependency_api.rb +23 -25
  371. data/lib/rubygems/request_set/lockfile/parser.rb +26 -28
  372. data/lib/rubygems/request_set/lockfile/tokenizer.rb +5 -7
  373. data/lib/rubygems/request_set/lockfile.rb +17 -21
  374. data/lib/rubygems/request_set.rb +27 -40
  375. data/lib/rubygems/requirement.rb +28 -48
  376. data/lib/rubygems/resolver/activation_request.rb +12 -6
  377. data/lib/rubygems/resolver/api_set/gem_parser.rb +20 -0
  378. data/lib/rubygems/resolver/api_set.rb +32 -25
  379. data/lib/rubygems/resolver/api_specification.rb +29 -15
  380. data/lib/rubygems/resolver/best_set.rb +7 -9
  381. data/lib/rubygems/resolver/composed_set.rb +3 -5
  382. data/lib/rubygems/resolver/conflict.rb +12 -14
  383. data/lib/rubygems/resolver/current_set.rb +0 -2
  384. data/lib/rubygems/resolver/dependency_request.rb +3 -5
  385. data/lib/rubygems/resolver/git_set.rb +2 -4
  386. data/lib/rubygems/resolver/git_specification.rb +6 -8
  387. data/lib/rubygems/resolver/index_set.rb +4 -6
  388. data/lib/rubygems/resolver/index_specification.rb +38 -7
  389. data/lib/rubygems/resolver/installed_specification.rb +4 -6
  390. data/lib/rubygems/resolver/installer_set.rb +66 -24
  391. data/lib/rubygems/resolver/local_specification.rb +2 -4
  392. data/lib/rubygems/resolver/lock_set.rb +6 -8
  393. data/lib/rubygems/resolver/lock_specification.rb +4 -6
  394. data/lib/rubygems/resolver/molinillo/LICENSE +9 -0
  395. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  396. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb +8 -0
  397. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  398. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -1
  399. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -1
  400. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +2 -1
  401. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +2 -1
  402. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb +7 -6
  403. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -1
  404. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb +4 -3
  405. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb +51 -12
  406. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +41 -8
  407. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +76 -8
  408. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  409. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +13 -1
  410. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +3 -1
  411. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +510 -165
  412. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +3 -2
  413. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +8 -4
  414. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +6 -5
  415. data/lib/rubygems/resolver/molinillo.rb +1 -1
  416. data/lib/rubygems/resolver/requirement_list.rb +0 -2
  417. data/lib/rubygems/resolver/set.rb +0 -3
  418. data/lib/rubygems/resolver/source_set.rb +0 -2
  419. data/lib/rubygems/resolver/spec_specification.rb +14 -2
  420. data/lib/rubygems/resolver/specification.rb +14 -4
  421. data/lib/rubygems/resolver/stats.rb +0 -2
  422. data/lib/rubygems/resolver/vendor_set.rb +1 -3
  423. data/lib/rubygems/resolver/vendor_specification.rb +3 -5
  424. data/lib/rubygems/resolver.rb +53 -51
  425. data/lib/rubygems/s3_uri_signer.rb +7 -15
  426. data/lib/rubygems/safe_yaml.rb +14 -16
  427. data/lib/rubygems/security/policies.rb +11 -11
  428. data/lib/rubygems/security/policy.rb +25 -29
  429. data/lib/rubygems/security/signer.rb +13 -16
  430. data/lib/rubygems/security/trust_dir.rb +4 -5
  431. data/lib/rubygems/security.rb +103 -69
  432. data/lib/rubygems/security_option.rb +7 -7
  433. data/lib/rubygems/source/git.rb +30 -30
  434. data/lib/rubygems/source/installed.rb +1 -3
  435. data/lib/rubygems/source/local.rb +4 -6
  436. data/lib/rubygems/source/lock.rb +0 -2
  437. data/lib/rubygems/source/specific_file.rb +1 -3
  438. data/lib/rubygems/source/vendor.rb +0 -2
  439. data/lib/rubygems/source.rb +44 -38
  440. data/lib/rubygems/source_list.rb +9 -16
  441. data/lib/rubygems/spec_fetcher.rb +49 -48
  442. data/lib/rubygems/specification.rb +338 -295
  443. data/lib/rubygems/specification_policy.rb +112 -61
  444. data/lib/rubygems/stub_specification.rb +21 -28
  445. data/lib/rubygems/text.rb +21 -20
  446. data/lib/rubygems/tsort/.document +1 -0
  447. data/lib/rubygems/tsort/LICENSE.txt +22 -0
  448. data/lib/rubygems/tsort/lib/tsort.rb +454 -0
  449. data/lib/rubygems/tsort.rb +3 -0
  450. data/lib/rubygems/uninstaller.rb +98 -45
  451. data/lib/rubygems/unknown_command_spell_checker.rb +21 -0
  452. data/lib/rubygems/uri.rb +126 -0
  453. data/lib/rubygems/uri_formatter.rb +2 -3
  454. data/lib/rubygems/user_interaction.rb +43 -54
  455. data/lib/rubygems/util/licenses.rb +115 -10
  456. data/lib/rubygems/util/list.rb +0 -2
  457. data/lib/rubygems/util.rb +18 -12
  458. data/lib/rubygems/validator.rb +6 -8
  459. data/lib/rubygems/version.rb +29 -20
  460. data/lib/rubygems/version_option.rb +11 -5
  461. data/lib/rubygems.rb +192 -289
  462. data/rubygems-update.gemspec +4 -4
  463. data/setup.rb +11 -22
  464. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  465. data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
  466. data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
  467. data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
  468. data/test/rubygems/encrypted_private_key.pem +26 -26
  469. data/{lib/rubygems/test_case.rb → test/rubygems/helper.rb} +380 -314
  470. data/{lib → test}/rubygems/installer_test_case.rb +38 -24
  471. data/{lib → test}/rubygems/package/tar_test_case.rb +4 -6
  472. data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
  473. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  474. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  475. data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -2
  476. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  477. data/test/rubygems/private_ec_key.pem +9 -0
  478. data/test/rubygems/rubygems/commands/crash_command.rb +0 -2
  479. data/test/rubygems/rubygems_plugin.rb +2 -4
  480. data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -2
  481. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +4 -6
  482. data/test/rubygems/test_bundled_ca.rb +43 -50
  483. data/test/rubygems/test_config.rb +5 -7
  484. data/test/rubygems/test_deprecate.rb +87 -10
  485. data/test/rubygems/test_exit.rb +11 -0
  486. data/test/rubygems/test_gem.rb +719 -639
  487. data/test/rubygems/test_gem_available_set.rb +24 -26
  488. data/test/rubygems/test_gem_bundler_version_finder.rb +37 -44
  489. data/test/rubygems/test_gem_command.rb +78 -49
  490. data/test/rubygems/test_gem_command_manager.rb +98 -35
  491. data/test/rubygems/test_gem_commands_build_command.rb +275 -57
  492. data/test/rubygems/test_gem_commands_cert_command.rb +180 -125
  493. data/test/rubygems/test_gem_commands_check_command.rb +9 -11
  494. data/test/rubygems/test_gem_commands_cleanup_command.rb +78 -69
  495. data/test/rubygems/test_gem_commands_contents_command.rb +73 -42
  496. data/test/rubygems/test_gem_commands_dependency_command.rb +38 -40
  497. data/test/rubygems/test_gem_commands_environment_command.rb +60 -38
  498. data/test/rubygems/test_gem_commands_fetch_command.rb +163 -32
  499. data/test/rubygems/test_gem_commands_generate_index_command.rb +8 -14
  500. data/test/rubygems/test_gem_commands_help_command.rb +34 -16
  501. data/test/rubygems/test_gem_commands_info_command.rb +33 -9
  502. data/test/rubygems/test_gem_commands_install_command.rb +401 -198
  503. data/test/rubygems/test_gem_commands_list_command.rb +5 -7
  504. data/test/rubygems/test_gem_commands_lock_command.rb +11 -13
  505. data/test/rubygems/test_gem_commands_mirror.rb +3 -5
  506. data/test/rubygems/test_gem_commands_open_command.rb +16 -19
  507. data/test/rubygems/test_gem_commands_outdated_command.rb +23 -7
  508. data/test/rubygems/test_gem_commands_owner_command.rb +100 -46
  509. data/test/rubygems/test_gem_commands_pristine_command.rb +131 -99
  510. data/test/rubygems/test_gem_commands_push_command.rb +134 -66
  511. data/test/rubygems/test_gem_commands_query_command.rb +91 -91
  512. data/test/rubygems/test_gem_commands_search_command.rb +2 -4
  513. data/test/rubygems/test_gem_commands_server_command.rb +6 -50
  514. data/test/rubygems/test_gem_commands_setup_command.rb +288 -179
  515. data/test/rubygems/test_gem_commands_signin_command.rb +162 -28
  516. data/test/rubygems/test_gem_commands_signout_command.rb +3 -10
  517. data/test/rubygems/test_gem_commands_sources_command.rb +139 -32
  518. data/test/rubygems/test_gem_commands_specification_command.rb +81 -55
  519. data/test/rubygems/test_gem_commands_stale_command.rb +4 -6
  520. data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -82
  521. data/test/rubygems/test_gem_commands_unpack_command.rb +32 -34
  522. data/test/rubygems/test_gem_commands_update_command.rb +335 -88
  523. data/test/rubygems/test_gem_commands_which_command.rb +12 -14
  524. data/test/rubygems/test_gem_commands_yank_command.rb +80 -44
  525. data/test/rubygems/test_gem_config_file.rb +114 -97
  526. data/test/rubygems/test_gem_dependency.rb +87 -87
  527. data/test/rubygems/test_gem_dependency_installer.rb +277 -391
  528. data/test/rubygems/test_gem_dependency_list.rb +57 -59
  529. data/test/rubygems/test_gem_dependency_resolution_error.rb +5 -7
  530. data/test/rubygems/test_gem_doctor.rb +73 -47
  531. data/test/rubygems/test_gem_ext_builder.rb +115 -109
  532. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +1 -0
  533. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock +243 -0
  534. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml +10 -0
  535. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/build.rb +21 -0
  536. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +10 -0
  537. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs +27 -0
  538. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +1 -0
  539. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +243 -0
  540. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +10 -0
  541. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb +21 -0
  542. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +8 -0
  543. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +39 -0
  544. data/test/rubygems/test_gem_ext_cargo_builder.rb +178 -0
  545. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  546. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +75 -0
  547. data/test/rubygems/test_gem_ext_cmake_builder.rb +31 -38
  548. data/test/rubygems/test_gem_ext_configure_builder.rb +23 -39
  549. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +66 -82
  550. data/test/rubygems/test_gem_ext_rake_builder.rb +49 -32
  551. data/test/rubygems/test_gem_gem_runner.rb +51 -8
  552. data/test/rubygems/test_gem_gemcutter_utilities.rb +87 -76
  553. data/test/rubygems/test_gem_impossible_dependencies_error.rb +4 -6
  554. data/test/rubygems/test_gem_indexer.rb +62 -64
  555. data/test/rubygems/test_gem_install_update_options.rb +31 -21
  556. data/test/rubygems/test_gem_installer.rb +798 -491
  557. data/test/rubygems/test_gem_local_remote_options.rb +11 -13
  558. data/test/rubygems/test_gem_name_tuple.rb +4 -6
  559. data/test/rubygems/test_gem_package.rb +318 -283
  560. data/test/rubygems/test_gem_package_old.rb +18 -20
  561. data/test/rubygems/test_gem_package_tar_header.rb +64 -47
  562. data/test/rubygems/test_gem_package_tar_reader.rb +8 -10
  563. data/test/rubygems/test_gem_package_tar_reader_entry.rb +18 -20
  564. data/test/rubygems/test_gem_package_tar_writer.rb +96 -100
  565. data/test/rubygems/test_gem_package_task.rb +58 -25
  566. data/test/rubygems/test_gem_path_support.rb +15 -21
  567. data/test/rubygems/test_gem_platform.rb +354 -201
  568. data/test/rubygems/test_gem_rdoc.rb +19 -21
  569. data/test/rubygems/test_gem_remote_fetcher.rb +376 -337
  570. data/test/rubygems/test_gem_request.rb +114 -86
  571. data/test/rubygems/test_gem_request_connection_pools.rb +30 -34
  572. data/test/rubygems/test_gem_request_set.rb +123 -124
  573. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +222 -226
  574. data/test/rubygems/test_gem_request_set_lockfile.rb +93 -95
  575. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +68 -70
  576. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +136 -138
  577. data/test/rubygems/test_gem_requirement.rb +133 -54
  578. data/test/rubygems/test_gem_resolver.rb +149 -117
  579. data/test/rubygems/test_gem_resolver_activation_request.rb +6 -8
  580. data/test/rubygems/test_gem_resolver_api_set.rb +79 -78
  581. data/test/rubygems/test_gem_resolver_api_specification.rb +47 -49
  582. data/test/rubygems/test_gem_resolver_best_set.rb +43 -22
  583. data/test/rubygems/test_gem_resolver_composed_set.rb +1 -3
  584. data/test/rubygems/test_gem_resolver_conflict.rb +12 -14
  585. data/test/rubygems/test_gem_resolver_dependency_request.rb +15 -17
  586. data/test/rubygems/test_gem_resolver_git_set.rb +22 -24
  587. data/test/rubygems/test_gem_resolver_git_specification.rb +22 -23
  588. data/test/rubygems/test_gem_resolver_index_set.rb +14 -16
  589. data/test/rubygems/test_gem_resolver_index_specification.rb +16 -18
  590. data/test/rubygems/test_gem_resolver_installed_specification.rb +5 -7
  591. data/test/rubygems/test_gem_resolver_installer_set.rb +104 -44
  592. data/test/rubygems/test_gem_resolver_local_specification.rb +7 -9
  593. data/test/rubygems/test_gem_resolver_lock_set.rb +15 -17
  594. data/test/rubygems/test_gem_resolver_lock_specification.rb +17 -19
  595. data/test/rubygems/test_gem_resolver_requirement_list.rb +1 -3
  596. data/test/rubygems/test_gem_resolver_specification.rb +8 -12
  597. data/test/rubygems/test_gem_resolver_vendor_set.rb +9 -11
  598. data/test/rubygems/test_gem_resolver_vendor_specification.rb +10 -12
  599. data/test/rubygems/test_gem_security.rb +104 -78
  600. data/test/rubygems/test_gem_security_policy.rb +92 -97
  601. data/test/rubygems/test_gem_security_signer.rb +45 -47
  602. data/test/rubygems/test_gem_security_trust_dir.rb +12 -14
  603. data/test/rubygems/test_gem_silent_ui.rb +46 -42
  604. data/test/rubygems/test_gem_source.rb +53 -52
  605. data/test/rubygems/test_gem_source_fetch_problem.rb +16 -8
  606. data/test/rubygems/test_gem_source_git.rb +69 -69
  607. data/test/rubygems/test_gem_source_installed.rb +16 -18
  608. data/test/rubygems/test_gem_source_list.rb +5 -6
  609. data/test/rubygems/test_gem_source_local.rb +15 -17
  610. data/test/rubygems/test_gem_source_lock.rb +31 -33
  611. data/test/rubygems/test_gem_source_specific_file.rb +18 -20
  612. data/test/rubygems/test_gem_source_subpath_problem.rb +49 -0
  613. data/test/rubygems/test_gem_source_vendor.rb +13 -15
  614. data/test/rubygems/test_gem_spec_fetcher.rb +74 -67
  615. data/test/rubygems/test_gem_specification.rb +888 -1024
  616. data/test/rubygems/test_gem_stream_ui.rb +23 -23
  617. data/test/rubygems/test_gem_stub_specification.rb +39 -57
  618. data/test/rubygems/test_gem_text.rb +8 -4
  619. data/test/rubygems/test_gem_uninstaller.rb +233 -104
  620. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +3 -5
  621. data/test/rubygems/test_gem_uri.rb +39 -0
  622. data/test/rubygems/test_gem_uri_formatter.rb +14 -16
  623. data/test/rubygems/test_gem_util.rb +37 -35
  624. data/test/rubygems/test_gem_validator.rb +10 -12
  625. data/test/rubygems/test_gem_version.rb +31 -31
  626. data/test/rubygems/test_gem_version_option.rb +16 -18
  627. data/test/rubygems/test_kernel.rb +46 -60
  628. data/test/rubygems/test_project_sanity.rb +8 -3
  629. data/test/rubygems/test_remote_fetch_error.rb +7 -9
  630. data/test/rubygems/test_require.rb +240 -167
  631. data/test/rubygems/test_rubygems.rb +74 -0
  632. data/{lib/rubygems/test_utilities.rb → test/rubygems/utilities.rb} +30 -39
  633. data/test/test_changelog_generator.rb +17 -0
  634. metadata +158 -146
  635. data/.bundle/config +0 -2
  636. data/.rubocop.yml +0 -91
  637. data/Gemfile +0 -8
  638. data/Gemfile.lock +0 -43
  639. data/Rakefile +0 -428
  640. data/bundler/CODE_OF_CONDUCT.md +0 -136
  641. data/bundler/lib/bundler/gemdeps.rb +0 -29
  642. data/bundler/lib/bundler/psyched_yaml.rb +0 -37
  643. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  644. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  645. data/bundler/man/bundle-add.1.txt +0 -58
  646. data/bundler/man/bundle-binstubs.1.txt +0 -48
  647. data/bundler/man/bundle-cache.1.txt +0 -78
  648. data/bundler/man/bundle-check.1.txt +0 -33
  649. data/bundler/man/bundle-clean.1.txt +0 -26
  650. data/bundler/man/bundle-config.1.txt +0 -528
  651. data/bundler/man/bundle-doctor.1.txt +0 -44
  652. data/bundler/man/bundle-exec.1.txt +0 -178
  653. data/bundler/man/bundle-gem.1.txt +0 -91
  654. data/bundler/man/bundle-info.1.txt +0 -21
  655. data/bundler/man/bundle-init.1.txt +0 -34
  656. data/bundler/man/bundle-inject.1.txt +0 -32
  657. data/bundler/man/bundle-install.1.txt +0 -401
  658. data/bundler/man/bundle-list.1.txt +0 -43
  659. data/bundler/man/bundle-lock.1.txt +0 -93
  660. data/bundler/man/bundle-open.1.txt +0 -29
  661. data/bundler/man/bundle-outdated.1.txt +0 -131
  662. data/bundler/man/bundle-platform.1.txt +0 -57
  663. data/bundler/man/bundle-pristine.1.txt +0 -44
  664. data/bundler/man/bundle-remove.1.txt +0 -34
  665. data/bundler/man/bundle-show.1.txt +0 -27
  666. data/bundler/man/bundle-update.1.txt +0 -390
  667. data/bundler/man/bundle-viz.1.txt +0 -39
  668. data/bundler/man/bundle.1.txt +0 -116
  669. data/bundler/man/gemfile.5.txt +0 -649
  670. data/lib/rubygems/psych_additions.rb +0 -10
  671. data/lib/rubygems/server.rb +0 -879
  672. data/lib/rubygems/source_local.rb +0 -7
  673. data/lib/rubygems/source_specific_file.rb +0 -6
  674. data/lib/rubygems/syck_hack.rb +0 -79
  675. data/lib/rubygems/uri_parser.rb +0 -36
  676. data/lib/rubygems/uri_parsing.rb +0 -23
  677. data/lib/ubygems.rb +0 -14
  678. data/test/rubygems/bogussources.rb +0 -9
  679. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  680. data/test/rubygems/test_gem_server.rb +0 -612
  681. data/tmp/.keep +0 -0
  682. data/util/CL2notes +0 -55
  683. data/util/bisect +0 -10
  684. data/util/ci.sh +0 -62
  685. data/util/cops/deprecations.rb +0 -52
  686. data/util/create_certs.rb +0 -171
  687. data/util/create_certs.sh +0 -27
  688. data/util/create_encrypted_key.rb +0 -16
  689. data/util/generate_spdx_license_list.rb +0 -63
  690. data/util/patch_with_prs.rb +0 -77
  691. data/util/rubocop +0 -8
  692. data/util/update_bundled_ca_certificates.rb +0 -137
  693. data/util/update_changelog.rb +0 -64
  694. /data/bundler/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  695. /data/bundler/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  696. /data/bundler/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  697. /data/bundler/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  698. /data/bundler/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  699. /data/bundler/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  700. /data/bundler/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  701. /data/bundler/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  702. /data/bundler/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  703. /data/bundler/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
@@ -1,27 +1,16 @@
1
1
  # coding: US-ASCII
2
- require 'rubygems/test_case'
3
- require 'rubygems'
4
- require 'rubygems/command'
5
- require 'rubygems/installer'
6
- require 'pathname'
7
- require 'tmpdir'
8
- require 'rbconfig'
9
-
10
- if File.exist?(File.join(Dir.tmpdir, "Gemfile"))
11
- raise "rubygems/bundler tests do not work correctly if there is #{ File.join(Dir.tmpdir, "Gemfile") }"
12
- end
13
-
14
- # TODO: push this up to test_case.rb once battle tested
15
-
16
- $LOAD_PATH.map! do |path|
17
- path.dup.tap(&Gem::UNTAINT)
18
- end
2
+ require_relative "helper"
3
+ require "rubygems"
4
+ require "rubygems/command"
5
+ require "rubygems/installer"
6
+ require "pathname"
7
+ require "tmpdir"
8
+ require "rbconfig"
19
9
 
20
10
  class TestGem < Gem::TestCase
21
-
22
11
  PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant
23
12
 
24
- PROJECT_DIR = File.expand_path('../../..', __FILE__).tap(&Gem::UNTAINT)
13
+ PROJECT_DIR = File.expand_path("../..", __dir__).tap(&Gem::UNTAINT)
25
14
 
26
15
  def setup
27
16
  super
@@ -30,111 +19,104 @@ class TestGem < Gem::TestCase
30
19
 
31
20
  common_installer_setup
32
21
 
33
- ENV.delete 'RUBYGEMS_GEMDEPS'
34
- @additional = %w[a b].map { |d| File.join @tempdir, d }
22
+ @additional = %w[a b].map {|d| File.join @tempdir, d }
35
23
 
36
24
  util_remove_interrupt_command
37
25
  end
38
26
 
39
27
  def test_self_finish_resolve
40
- save_loaded_features do
41
- a1 = util_spec "a", "1", "b" => "> 0"
42
- b1 = util_spec "b", "1", "c" => ">= 1"
43
- b2 = util_spec "b", "2", "c" => ">= 2"
44
- c1 = util_spec "c", "1"
45
- c2 = util_spec "c", "2"
28
+ a1 = util_spec "a", "1", "b" => "> 0"
29
+ b1 = util_spec "b", "1", "c" => ">= 1"
30
+ b2 = util_spec "b", "2", "c" => ">= 2"
31
+ c1 = util_spec "c", "1"
32
+ c2 = util_spec "c", "2"
46
33
 
47
- install_specs c1, c2, b1, b2, a1
34
+ install_specs c1, c2, b1, b2, a1
48
35
 
49
- a1.activate
36
+ a1.activate
50
37
 
51
- assert_equal %w(a-1), loaded_spec_names
52
- assert_equal ["b (> 0)"], unresolved_names
38
+ assert_equal %w[a-1], loaded_spec_names
39
+ assert_equal ["b (> 0)"], unresolved_names
53
40
 
54
- Gem.finish_resolve
41
+ Gem.finish_resolve
55
42
 
56
- assert_equal %w(a-1 b-2 c-2), loaded_spec_names
57
- assert_equal [], unresolved_names
58
- end
43
+ assert_equal %w[a-1 b-2 c-2], loaded_spec_names
44
+ assert_equal [], unresolved_names
59
45
  end
60
46
 
61
47
  def test_self_finish_resolve_wtf
62
- save_loaded_features do
63
- a1 = util_spec "a", "1", "b" => "> 0", "d" => "> 0" # this
64
- b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb" # this
65
- b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
66
- c1 = util_spec "c", "1" # this
67
- c2 = util_spec "c", "2"
68
- d1 = util_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
69
- d2 = util_spec "d", "2", { "c" => "< 2" }, "lib/d.rb" # this
48
+ a1 = util_spec "a", "1", "b" => "> 0", "d" => "> 0" # this
49
+ b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/b.rb" # this
50
+ b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/b.rb"
51
+ c1 = util_spec "c", "1" # this
52
+ c2 = util_spec "c", "2"
53
+ d1 = util_spec "d", "1", { "c" => "< 2" }, "lib/d.rb"
54
+ d2 = util_spec "d", "2", { "c" => "< 2" }, "lib/d.rb" # this
70
55
 
71
- install_specs c1, c2, b1, b2, d1, d2, a1
56
+ install_specs c1, c2, b1, b2, d1, d2, a1
72
57
 
73
- a1.activate
58
+ a1.activate
74
59
 
75
- assert_equal %w(a-1), loaded_spec_names
76
- assert_equal ["b (> 0)", "d (> 0)"], unresolved_names
60
+ assert_equal %w[a-1], loaded_spec_names
61
+ assert_equal ["b (> 0)", "d (> 0)"], unresolved_names
77
62
 
78
- Gem.finish_resolve
63
+ Gem.finish_resolve
79
64
 
80
- assert_equal %w(a-1 b-1 c-1 d-2), loaded_spec_names
81
- assert_equal [], unresolved_names
82
- end
65
+ assert_equal %w[a-1 b-1 c-1 d-2], loaded_spec_names
66
+ assert_equal [], unresolved_names
83
67
  end
84
68
 
85
69
  def test_self_finish_resolve_respects_loaded_specs
86
- save_loaded_features do
87
- a1 = util_spec "a", "1", "b" => "> 0"
88
- b1 = util_spec "b", "1", "c" => ">= 1"
89
- b2 = util_spec "b", "2", "c" => ">= 2"
90
- c1 = util_spec "c", "1"
91
- c2 = util_spec "c", "2"
70
+ a1 = util_spec "a", "1", "b" => "> 0"
71
+ b1 = util_spec "b", "1", "c" => ">= 1"
72
+ b2 = util_spec "b", "2", "c" => ">= 2"
73
+ c1 = util_spec "c", "1"
74
+ c2 = util_spec "c", "2"
92
75
 
93
- install_specs c1, c2, b1, b2, a1
76
+ install_specs c1, c2, b1, b2, a1
94
77
 
95
- a1.activate
96
- c1.activate
78
+ a1.activate
79
+ c1.activate
97
80
 
98
- assert_equal %w(a-1 c-1), loaded_spec_names
99
- assert_equal ["b (> 0)"], unresolved_names
81
+ assert_equal %w[a-1 c-1], loaded_spec_names
82
+ assert_equal ["b (> 0)"], unresolved_names
100
83
 
101
- Gem.finish_resolve
84
+ Gem.finish_resolve
102
85
 
103
- assert_equal %w(a-1 b-1 c-1), loaded_spec_names
104
- assert_equal [], unresolved_names
105
- end
86
+ assert_equal %w[a-1 b-1 c-1], loaded_spec_names
87
+ assert_equal [], unresolved_names
106
88
  end
107
89
 
108
90
  def test_self_install
109
91
  spec_fetcher do |f|
110
- f.gem 'a', 1
111
- f.spec 'a', 2
92
+ f.gem "a", 1
93
+ f.spec "a", 2
112
94
  end
113
95
 
114
96
  gemhome2 = "#{@gemhome}2"
115
97
 
116
- installed = Gem.install 'a', '= 1', :install_dir => gemhome2
98
+ installed = Gem.install "a", "= 1", :install_dir => gemhome2
117
99
 
118
- assert_equal %w[a-1], installed.map { |spec| spec.full_name }
100
+ assert_equal %w[a-1], installed.map {|spec| spec.full_name }
119
101
 
120
- assert_path_exists File.join(gemhome2, 'gems', 'a-1')
102
+ assert_path_exist File.join(gemhome2, "gems", "a-1")
121
103
  end
122
104
 
123
105
  def test_self_install_in_rescue
124
106
  spec_fetcher do |f|
125
- f.gem 'a', 1
126
- f.spec 'a', 2
107
+ f.gem "a", 1
108
+ f.spec "a", 2
127
109
  end
128
110
 
129
111
  gemhome2 = "#{@gemhome}2"
130
112
 
131
113
  installed =
132
114
  begin
133
- raise 'Error'
115
+ raise "Error"
134
116
  rescue StandardError
135
- Gem.install 'a', '= 1', :install_dir => gemhome2
117
+ Gem.install "a", "= 1", :install_dir => gemhome2
136
118
  end
137
- assert_equal %w[a-1], installed.map { |spec| spec.full_name }
119
+ assert_equal %w[a-1], installed.map {|spec| spec.full_name }
138
120
  end
139
121
 
140
122
  def test_self_install_permissions
@@ -161,7 +143,7 @@ class TestGem < Gem::TestCase
161
143
 
162
144
  def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name
163
145
  Gem::Installer.exec_format = nil
164
- ruby_install_name 'ruby27' do
146
+ ruby_install_name "ruby27" do
165
147
  assert_self_install_permissions(format_executable: true)
166
148
  end
167
149
  ensure
@@ -175,38 +157,38 @@ class TestGem < Gem::TestCase
175
157
  :prog_mode => win_platform? ? 0410 : 0510,
176
158
  :data_mode => 0640,
177
159
  :wrappers => true,
178
- :format_executable => format_executable
160
+ :format_executable => format_executable,
179
161
  }
180
162
  Dir.chdir @tempdir do
181
- Dir.mkdir 'bin'
182
- Dir.mkdir 'data'
163
+ Dir.mkdir "bin"
164
+ Dir.mkdir "data"
183
165
 
184
- File.write 'bin/foo', "#!/usr/bin/env ruby\n"
185
- File.chmod 0755, 'bin/foo'
166
+ File.write "bin/foo", "#!/usr/bin/env ruby\n"
167
+ File.chmod 0755, "bin/foo"
186
168
 
187
- File.write 'data/foo.txt', "blah\n"
169
+ File.write "data/foo.txt", "blah\n"
188
170
 
189
171
  spec_fetcher do |f|
190
- f.gem 'foo', 1 do |s|
191
- s.executables = ['foo']
172
+ f.gem "foo", 1 do |s|
173
+ s.executables = ["foo"]
192
174
  s.files = %w[bin/foo data/foo.txt]
193
175
  end
194
176
  end
195
- Gem.install 'foo', Gem::Requirement.default, options
177
+ Gem.install "foo", Gem::Requirement.default, options
196
178
  end
197
179
 
198
180
  prog_mode = (options[:prog_mode] & mask).to_s(8)
199
181
  dir_mode = (options[:dir_mode] & mask).to_s(8)
200
182
  data_mode = (options[:data_mode] & mask).to_s(8)
201
- prog_name = 'foo'
202
- prog_name = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'foo') if options[:format_executable]
183
+ prog_name = "foo"
184
+ prog_name = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "foo") if options[:format_executable]
203
185
  expected = {
204
186
  "bin/#{prog_name}" => prog_mode,
205
- 'gems/foo-1' => dir_mode,
206
- 'gems/foo-1/bin' => dir_mode,
207
- 'gems/foo-1/data' => dir_mode,
208
- 'gems/foo-1/bin/foo' => prog_mode,
209
- 'gems/foo-1/data/foo.txt' => data_mode,
187
+ "gems/foo-1" => dir_mode,
188
+ "gems/foo-1/bin" => dir_mode,
189
+ "gems/foo-1/data" => dir_mode,
190
+ "gems/foo-1/bin/foo" => prog_mode,
191
+ "gems/foo-1/data/foo.txt" => data_mode,
210
192
  }
211
193
  # add Windows script
212
194
  expected["bin/#{prog_name}.bat"] = mask.to_s(8) if win_platform?
@@ -218,83 +200,79 @@ class TestGem < Gem::TestCase
218
200
  end
219
201
  assert_equal(expected, result)
220
202
  ensure
221
- File.chmod(0755, *Dir.glob(@gemhome + '/gems/**/').map {|path| path.tap(&Gem::UNTAINT)})
203
+ File.chmod(0755, *Dir.glob(@gemhome + "/gems/**/").map {|path| path.tap(&Gem::UNTAINT) })
222
204
  end
223
205
 
224
206
  def test_require_missing
225
- save_loaded_features do
226
- assert_raises ::LoadError do
227
- require "test_require_missing"
228
- end
207
+ assert_raise ::LoadError do
208
+ require "test_require_missing"
229
209
  end
230
210
  end
231
211
 
232
212
  def test_require_does_not_glob
233
- save_loaded_features do
234
- a1 = util_spec "a", "1", nil, "lib/a1.rb"
213
+ a1 = util_spec "a", "1", nil, "lib/a1.rb"
235
214
 
236
- install_specs a1
237
-
238
- assert_raises ::LoadError do
239
- require "a*"
240
- end
215
+ install_specs a1
241
216
 
242
- assert_equal [], loaded_spec_names
217
+ assert_raise ::LoadError do
218
+ require "a*"
243
219
  end
220
+
221
+ assert_equal [], loaded_spec_names
244
222
  end
245
223
 
246
224
  def test_self_bin_path_active
247
- a1 = util_spec 'a', '1' do |s|
248
- s.executables = ['exec']
225
+ a1 = util_spec "a", "1" do |s|
226
+ s.executables = ["exec"]
249
227
  end
250
228
 
251
- util_spec 'a', '2' do |s|
252
- s.executables = ['exec']
229
+ util_spec "a", "2" do |s|
230
+ s.executables = ["exec"]
253
231
  end
254
232
 
255
233
  a1.activate
256
234
 
257
- assert_match 'a-1/bin/exec', Gem.bin_path('a', 'exec', '>= 0')
235
+ assert_match "a-1/bin/exec", Gem.bin_path("a", "exec", ">= 0")
258
236
  end
259
237
 
260
238
  def test_self_bin_path_picking_newest
261
- a1 = util_spec 'a', '1' do |s|
262
- s.executables = ['exec']
239
+ a1 = util_spec "a", "1" do |s|
240
+ s.executables = ["exec"]
263
241
  end
264
242
 
265
- a2 = util_spec 'a', '2' do |s|
266
- s.executables = ['exec']
243
+ a2 = util_spec "a", "2" do |s|
244
+ s.executables = ["exec"]
267
245
  end
268
246
 
269
247
  install_specs a1, a2
270
248
 
271
- assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0')
249
+ assert_match "a-2/bin/exec", Gem.bin_path("a", "exec", ">= 0")
272
250
  end
273
251
 
274
252
  def test_self_activate_bin_path_no_exec_name
275
- e = assert_raises ArgumentError do
276
- Gem.activate_bin_path 'a'
253
+ e = assert_raise ArgumentError do
254
+ Gem.activate_bin_path "a"
277
255
  end
278
256
 
279
- assert_equal 'you must supply exec_name', e.message
257
+ assert_equal "you must supply exec_name", e.message
280
258
  end
281
259
 
282
260
  def test_activate_bin_path_resolves_eagerly
283
- a1 = util_spec 'a', '1' do |s|
284
- s.executables = ['exec']
285
- s.add_dependency 'b'
261
+ a1 = util_spec "a", "1" do |s|
262
+ s.executables = ["exec"]
263
+ s.add_dependency "b"
286
264
  end
287
265
 
288
- b1 = util_spec 'b', '1' do |s|
289
- s.add_dependency 'c', '2'
266
+ b1 = util_spec "b", "1" do |s|
267
+ s.add_dependency "c", "2"
290
268
  end
291
269
 
292
- b2 = util_spec 'b', '2' do |s|
293
- s.add_dependency 'c', '1'
270
+ b2 = util_spec "b", "2" do |s|
271
+ s.add_dependency "c", "1"
294
272
  end
295
273
 
296
- c1 = util_spec 'c', '1'
297
- c2 = util_spec 'c', '2'
274
+ c1 = util_spec "c", "1"
275
+ c2 = util_spec "c", "2"
298
276
 
299
277
  install_specs c1, c2, b1, b2, a1
300
278
 
@@ -302,33 +280,90 @@ class TestGem < Gem::TestCase
302
280
 
303
281
  # If we didn't eagerly resolve, this would activate c-2 and then the
304
282
  # finish_resolve would cause a conflict
305
- gem 'c'
283
+ gem "c"
306
284
  Gem.finish_resolve
307
285
 
308
- assert_equal %w(a-1 b-2 c-1), loaded_spec_names
286
+ assert_equal %w[a-1 b-2 c-1], loaded_spec_names
287
+ end
288
+
289
+ def test_activate_bin_path_does_not_error_if_a_gem_thats_not_finally_activated_has_orphaned_dependencies
290
+ a1 = util_spec "a", "1" do |s|
291
+ s.executables = ["exec"]
292
+ s.add_dependency "b"
293
+ end
294
+
295
+ b1 = util_spec "b", "1" do |s|
296
+ s.add_dependency "c", "1"
297
+ end
298
+
299
+ b2 = util_spec "b", "2" do |s|
300
+ s.add_dependency "c", "2"
301
+ end
302
+
303
+ c2 = util_spec "c", "2"
304
+
305
+ install_specs c2, b1, b2, a1
306
+
307
+ # c1 is missing, but not needed for activation, so we should not get any errors here
308
+
309
+ Gem.activate_bin_path("a", "exec", ">= 0")
310
+
311
+ assert_equal %w[a-1 b-2 c-2], loaded_spec_names
312
+ end
313
+
314
+ def test_activate_bin_path_raises_a_meaningful_error_if_a_gem_thats_finally_activated_has_orphaned_dependencies
315
+ a1 = util_spec "a", "1" do |s|
316
+ s.executables = ["exec"]
317
+ s.add_dependency "b"
318
+ end
319
+
320
+ b1 = util_spec "b", "1" do |s|
321
+ s.add_dependency "c", "1"
322
+ end
323
+
324
+ b2 = util_spec "b", "2" do |s|
325
+ s.add_dependency "c", "2"
326
+ end
327
+
328
+ c1 = util_spec "c", "1"
329
+
330
+ install_specs c1, b1, b2, a1
331
+
332
+ # c2 is missing, and b2 which has it as a dependency will be activated, so we should get an error about the orphaned dependency
333
+
334
+ e = assert_raise Gem::UnsatisfiableDependencyError do
335
+ load Gem.activate_bin_path("a", "exec", ">= 0")
336
+ end
337
+
338
+ assert_equal "Unable to resolve dependency: 'b (>= 0)' requires 'c (= 2)'", e.message
309
339
  end
310
340
 
311
341
  def test_activate_bin_path_in_debug_mode
312
- a1 = util_spec 'a', '1' do |s|
313
- s.executables = ['exec']
342
+ a1 = util_spec "a", "1" do |s|
343
+ s.executables = ["exec"]
314
344
  end
315
345
 
316
346
  install_specs a1
317
347
 
348
+ require "open3"
318
349
  output, status = Open3.capture2e(
319
350
  { "GEM_HOME" => Gem.paths.home, "DEBUG_RESOLVER" => "1" },
320
- Gem.ruby, "-I", File.expand_path("../../lib", __dir__), "-e", "\"Gem.activate_bin_path('a', 'exec', '>= 0')\""
351
+ *ruby_with_rubygems_in_load_path, "-e", "\"Gem.activate_bin_path('a', 'exec', '>= 0')\""
321
352
  )
322
353
 
323
354
  assert status.success?, output
324
355
  end
325
356
 
326
- def test_activate_bin_path_gives_proper_error_for_bundler
327
- bundler = util_spec 'bundler', '2' do |s|
328
- s.executables = ['bundle']
357
+ def test_activate_bin_path_selects_exact_bundler_version_if_present
358
+ bundler_latest = util_spec "bundler", "2.0.1" do |s|
359
+ s.executables = ["bundle"]
360
+ end
361
+
362
+ bundler_previous = util_spec "bundler", "2.0.0" do |s|
363
+ s.executables = ["bundle"]
329
364
  end
330
365
 
331
- install_specs bundler
366
+ install_specs bundler_latest, bundler_previous
332
367
 
333
368
  File.open("Gemfile.lock", "w") do |f|
334
369
  f.write <<-L.gsub(/ {8}/, "")
@@ -342,29 +377,24 @@ class TestGem < Gem::TestCase
342
377
  DEPENDENCIES
343
378
 
344
379
  BUNDLED WITH
345
- 9999
380
+ 2.0.0
346
381
  L
347
382
  end
348
383
 
349
- File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
384
+ File.open("Gemfile", "w") {|f| f.puts('source "https://rubygems.org"') }
350
385
 
351
- e = assert_raises Gem::GemNotFoundException do
352
- load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
353
- end
386
+ load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
354
387
 
355
- assert_includes e.message, "Could not find 'bundler' (9999) required by your #{File.expand_path("Gemfile.lock")}."
356
- assert_includes e.message, "To update to the latest version installed on your system, run `bundle update --bundler`."
357
- assert_includes e.message, "To install the missing version, run `gem install bundler:9999`"
358
- refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle"
388
+ assert_equal %w[bundler-2.0.0], loaded_spec_names
359
389
  end
360
390
 
361
- def test_activate_bin_path_selects_exact_bundler_version_if_present
362
- bundler_latest = util_spec 'bundler', '2.0.1' do |s|
363
- s.executables = ['bundle']
391
+ def test_activate_bin_path_respects_underscore_selection_if_given
392
+ bundler_latest = util_spec "bundler", "2.0.1" do |s|
393
+ s.executables = ["bundle"]
364
394
  end
365
395
 
366
- bundler_previous = util_spec 'bundler', '2.0.0' do |s|
367
- s.executables = ['bundle']
396
+ bundler_previous = util_spec "bundler", "1.17.3" do |s|
397
+ s.executables = ["bundle"]
368
398
  end
369
399
 
370
400
  install_specs bundler_latest, bundler_previous
@@ -381,28 +411,18 @@ class TestGem < Gem::TestCase
381
411
  DEPENDENCIES
382
412
 
383
413
  BUNDLED WITH
384
- 2.0.0
414
+ 2.0.1
385
415
  L
386
416
  end
387
417
 
388
- File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
418
+ File.open("Gemfile", "w") {|f| f.puts('source "https://rubygems.org"') }
389
419
 
390
- load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
420
+ load Gem.activate_bin_path("bundler", "bundle", "= 1.17.3")
391
421
 
392
- assert_equal %w(bundler-2.0.0), loaded_spec_names
422
+ assert_equal %w[bundler-1.17.3], loaded_spec_names
393
423
  end
394
424
 
395
- def test_activate_bin_path_respects_underscore_selection_if_given
396
- bundler_latest = util_spec 'bundler', '2.0.1' do |s|
397
- s.executables = ['bundle']
398
- end
399
-
400
- bundler_previous = util_spec 'bundler', '1.17.3' do |s|
401
- s.executables = ['bundle']
402
- end
403
-
404
- install_specs bundler_latest, bundler_previous
405
-
425
+ def test_activate_bin_path_gives_proper_error_for_bundler_when_underscore_selection_given
406
426
  File.open("Gemfile.lock", "w") do |f|
407
427
  f.write <<-L.gsub(/ {8}/, "")
408
428
  GEM
@@ -415,71 +435,72 @@ class TestGem < Gem::TestCase
415
435
  DEPENDENCIES
416
436
 
417
437
  BUNDLED WITH
418
- 2.0.1
438
+ 2.1.4
419
439
  L
420
440
  end
421
441
 
422
- File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
442
+ File.open("Gemfile", "w") {|f| f.puts('source "https://rubygems.org"') }
423
443
 
424
- load Gem.activate_bin_path("bundler", "bundle", "= 1.17.3")
444
+ e = assert_raise Gem::GemNotFoundException do
445
+ load Gem.activate_bin_path("bundler", "bundle", "= 2.2.8")
446
+ end
425
447
 
426
- assert_equal %w(bundler-1.17.3), loaded_spec_names
448
+ assert_equal "can't find gem bundler (= 2.2.8) with executable bundle", e.message
427
449
  end
428
450
 
429
451
  def test_self_bin_path_no_exec_name
430
- e = assert_raises ArgumentError do
431
- Gem.bin_path 'a'
452
+ e = assert_raise ArgumentError do
453
+ Gem.bin_path "a"
432
454
  end
433
455
 
434
- assert_equal 'you must supply exec_name', e.message
456
+ assert_equal "you must supply exec_name", e.message
435
457
  end
436
458
 
437
459
  def test_self_bin_path_bin_name
438
460
  install_specs util_exec_gem
439
- assert_equal @abin_path, Gem.bin_path('a', 'abin')
461
+ assert_equal @abin_path, Gem.bin_path("a", "abin")
440
462
  end
441
463
 
442
464
  def test_self_bin_path_bin_name_version
443
465
  install_specs util_exec_gem
444
- assert_equal @abin_path, Gem.bin_path('a', 'abin', '4')
466
+ assert_equal @abin_path, Gem.bin_path("a", "abin", "4")
445
467
  end
446
468
 
447
469
  def test_self_bin_path_nonexistent_binfile
448
- util_spec 'a', '2' do |s|
449
- s.executables = ['exec']
470
+ util_spec "a", "2" do |s|
471
+ s.executables = ["exec"]
450
472
  end
451
- assert_raises(Gem::GemNotFoundException) do
452
- Gem.bin_path('a', 'other', '2')
473
+ assert_raise(Gem::GemNotFoundException) do
474
+ Gem.bin_path("a", "other", "2")
453
475
  end
454
476
  end
455
477
 
456
478
  def test_self_bin_path_no_bin_file
457
- util_spec 'a', '1'
458
- assert_raises(ArgumentError) do
459
- Gem.bin_path('a', nil, '1')
479
+ util_spec "a", "1"
480
+ assert_raise(ArgumentError) do
481
+ Gem.bin_path("a", nil, "1")
460
482
  end
461
483
  end
462
484
 
463
485
  def test_self_bin_path_not_found
464
- assert_raises(Gem::GemNotFoundException) do
465
- Gem.bin_path('non-existent', 'blah')
486
+ assert_raise(Gem::GemNotFoundException) do
487
+ Gem.bin_path("non-existent", "blah")
466
488
  end
467
489
  end
468
490
 
469
491
  def test_self_bin_path_bin_file_gone_in_latest
470
492
  install_specs util_exec_gem
471
- spec = util_spec 'a', '10' do |s|
493
+ spec = util_spec "a", "10" do |s|
472
494
  s.executables = []
473
495
  end
474
496
  install_specs spec
475
- # Should not find a-10's non-abin (bug)
476
- assert_equal @abin_path, Gem.bin_path('a', 'abin')
497
+ assert_equal @abin_path, Gem.bin_path("a", "abin")
477
498
  end
478
499
 
479
500
  def test_self_bindir
480
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir
481
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
482
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Pathname.new(Gem.dir))
501
+ assert_equal File.join(@gemhome, "bin"), Gem.bindir
502
+ assert_equal File.join(@gemhome, "bin"), Gem.bindir(Gem.dir)
503
+ assert_equal File.join(@gemhome, "bin"), Gem.bindir(Pathname.new(Gem.dir))
483
504
  end
484
505
 
485
506
  def test_self_bindir_default_dir
@@ -508,51 +529,51 @@ class TestGem < Gem::TestCase
508
529
  foo = nil
509
530
 
510
531
  Dir.chdir @tempdir do
511
- FileUtils.mkdir_p 'data'
512
- File.open File.join('data', 'foo.txt'), 'w' do |fp|
513
- fp.puts 'blah'
532
+ FileUtils.mkdir_p "data"
533
+ File.open File.join("data", "foo.txt"), "w" do |fp|
534
+ fp.puts "blah"
514
535
  end
515
536
 
516
- foo = util_spec 'foo' do |s|
537
+ foo = util_spec "foo" do |s|
517
538
  s.files = %w[data/foo.txt]
518
539
  end
519
540
 
520
541
  install_gem foo
521
542
  end
522
543
 
523
- gem 'foo'
544
+ gem "foo"
524
545
 
525
- expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
546
+ expected = File.join @gemhome, "gems", foo.full_name, "data", "foo"
526
547
 
527
548
  assert_equal expected, Gem::Specification.find_by_name("foo").datadir
528
549
  end
529
550
 
530
551
  def test_self_datadir_nonexistent_package
531
- assert_raises(Gem::MissingSpecError) do
552
+ assert_raise(Gem::MissingSpecError) do
532
553
  Gem::Specification.find_by_name("xyzzy").datadir
533
554
  end
534
555
  end
535
556
 
536
557
  def test_self_default_exec_format
537
- ruby_install_name 'ruby' do
538
- assert_equal '%s', Gem.default_exec_format
558
+ ruby_install_name "ruby" do
559
+ assert_equal "%s", Gem.default_exec_format
539
560
  end
540
561
  end
541
562
 
542
563
  def test_self_default_exec_format_18
543
- ruby_install_name 'ruby18' do
544
- assert_equal '%s18', Gem.default_exec_format
564
+ ruby_install_name "ruby18" do
565
+ assert_equal "%s18", Gem.default_exec_format
545
566
  end
546
567
  end
547
568
 
548
569
  def test_self_default_exec_format_jruby
549
- ruby_install_name 'jruby' do
550
- assert_equal 'j%s', Gem.default_exec_format
570
+ ruby_install_name "jruby" do
571
+ assert_equal "j%s", Gem.default_exec_format
551
572
  end
552
573
  end
553
574
 
554
575
  def test_default_path
555
- vendordir(File.join(@tempdir, 'vendor')) do
576
+ vendordir(File.join(@tempdir, "vendor")) do
556
577
  FileUtils.rm_rf Gem.user_home
557
578
 
558
579
  expected = [Gem.default_dir]
@@ -572,7 +593,7 @@ class TestGem < Gem::TestCase
572
593
  end
573
594
 
574
595
  def test_default_path_user_home
575
- vendordir(File.join(@tempdir, 'vendor')) do
596
+ vendordir(File.join(@tempdir, "vendor")) do
576
597
  expected = [Gem.user_dir, Gem.default_dir]
577
598
 
578
599
  assert_equal expected, Gem.default_path
@@ -580,7 +601,7 @@ class TestGem < Gem::TestCase
580
601
  end
581
602
 
582
603
  def test_default_path_vendor_dir
583
- vendordir(File.join(@tempdir, 'vendor')) do
604
+ vendordir(File.join(@tempdir, "vendor")) do
584
605
  FileUtils.mkdir_p Gem.vendor_dir
585
606
 
586
607
  FileUtils.rm_rf Gem.user_home
@@ -596,22 +617,22 @@ class TestGem < Gem::TestCase
596
617
  end
597
618
 
598
619
  def test_self_use_gemdeps
599
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
620
+ with_rubygems_gemdeps("-") do
621
+ FileUtils.mkdir_p "detect/a/b"
622
+ FileUtils.mkdir_p "detect/a/Isolate"
600
623
 
601
- FileUtils.mkdir_p 'detect/a/b'
602
- FileUtils.mkdir_p 'detect/a/Isolate'
624
+ FileUtils.touch "detect/Isolate"
603
625
 
604
- FileUtils.touch 'detect/Isolate'
626
+ begin
627
+ Dir.chdir "detect/a/b"
605
628
 
606
- begin
607
- Dir.chdir 'detect/a/b'
629
+ Gem.use_gemdeps
608
630
 
609
- assert_equal add_bundler_full_name([]), Gem.use_gemdeps.map(&:full_name)
610
- ensure
611
- Dir.chdir @tempdir
631
+ assert_equal add_bundler_full_name([]), loaded_spec_names
632
+ ensure
633
+ Dir.chdir @tempdir
634
+ end
612
635
  end
613
- ensure
614
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
615
636
  end
616
637
 
617
638
  def test_self_dir
@@ -624,12 +645,12 @@ class TestGem < Gem::TestCase
624
645
 
625
646
  Gem.ensure_gem_subdirectories @gemhome
626
647
 
627
- assert_path_exists File.join @gemhome, 'build_info'
628
- assert_path_exists File.join @gemhome, 'cache'
629
- assert_path_exists File.join @gemhome, 'doc'
630
- assert_path_exists File.join @gemhome, 'extensions'
631
- assert_path_exists File.join @gemhome, 'gems'
632
- assert_path_exists File.join @gemhome, 'specifications'
648
+ assert_path_exist File.join @gemhome, "build_info"
649
+ assert_path_exist File.join @gemhome, "cache"
650
+ assert_path_exist File.join @gemhome, "doc"
651
+ assert_path_exist File.join @gemhome, "extensions"
652
+ assert_path_exist File.join @gemhome, "gems"
653
+ assert_path_exist File.join @gemhome, "specifications"
633
654
  end
634
655
 
635
656
  def test_self_ensure_gem_directories_permissions
@@ -659,9 +680,9 @@ class TestGem < Gem::TestCase
659
680
  end unless win_platform?
660
681
 
661
682
  def test_self_ensure_gem_directories_missing_parents
662
- gemdir = File.join @tempdir, 'a/b/c/gemdir'
663
- FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil
664
- refute File.exist?(File.join(@tempdir, 'a')),
683
+ gemdir = File.join @tempdir, "a/b/c/gemdir"
684
+ FileUtils.rm_rf File.join(@tempdir, "a") rescue nil
685
+ refute File.exist?(File.join(@tempdir, "a")),
665
686
  "manually remove #{File.join @tempdir, 'a'}, tests are broken"
666
687
  Gem.use_paths gemdir
667
688
 
@@ -670,7 +691,7 @@ class TestGem < Gem::TestCase
670
691
  assert_directory_exists util_cache_dir
671
692
  end
672
693
 
673
- unless win_platform? || Process.uid.zero? # only for FS that support write protection
694
+ unless win_platform? || Process.uid.zero? # only for FS that support write protection
674
695
  def test_self_ensure_gem_directories_write_protected
675
696
  gemdir = File.join @tempdir, "egd"
676
697
  FileUtils.rm_r gemdir rescue nil
@@ -702,16 +723,21 @@ class TestGem < Gem::TestCase
702
723
  ensure
703
724
  FileUtils.chmod 0600, parent
704
725
  end
726
+
727
+ def test_self_ensure_gem_directories_non_existent_paths
728
+ Gem.ensure_gem_subdirectories "/proc/0123456789/bogus" # should not raise
729
+ Gem.ensure_gem_subdirectories "classpath:/bogus/x" # JRuby embed scenario
730
+ end
705
731
  end
706
732
 
707
733
  def test_self_extension_dir_shared
708
- enable_shared 'yes' do
734
+ enable_shared "yes" do
709
735
  assert_equal Gem.ruby_api_version, Gem.extension_api_version
710
736
  end
711
737
  end
712
738
 
713
739
  def test_self_extension_dir_static
714
- enable_shared 'no' do
740
+ enable_shared "no" do
715
741
  assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
716
742
  end
717
743
  end
@@ -720,14 +746,14 @@ class TestGem < Gem::TestCase
720
746
  cwd = File.expand_path("test/rubygems", PROJECT_DIR)
721
747
  $LOAD_PATH.unshift cwd
722
748
 
723
- discover_path = File.join 'lib', 'sff', 'discover.rb'
749
+ discover_path = File.join "lib", "sff", "discover.rb"
724
750
 
725
- foo1, foo2 = %w(1 2).map do |version|
726
- spec = quick_gem 'sff', version do |s|
751
+ foo1, foo2 = %w[1 2].map do |version|
752
+ spec = quick_gem "sff", version do |s|
727
753
  s.files << discover_path
728
754
  end
729
755
 
730
- write_file(File.join 'gems', spec.full_name, discover_path) do |fp|
756
+ write_file(File.join "gems", spec.full_name, discover_path) do |fp|
731
757
  fp.puts "# #{spec.full_name}"
732
758
  end
733
759
 
@@ -737,13 +763,13 @@ class TestGem < Gem::TestCase
737
763
  Gem.refresh
738
764
 
739
765
  expected = [
740
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
766
+ File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR),
741
767
  File.join(foo2.full_gem_path, discover_path),
742
768
  File.join(foo1.full_gem_path, discover_path),
743
769
  ]
744
770
 
745
- assert_equal expected, Gem.find_files('sff/discover')
746
- assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
771
+ assert_equal expected, Gem.find_files("sff/discover")
772
+ assert_equal expected, Gem.find_files("sff/**.rb"), "[ruby-core:31730]"
747
773
  ensure
748
774
  assert_equal cwd, $LOAD_PATH.shift
749
775
  end
@@ -752,14 +778,14 @@ class TestGem < Gem::TestCase
752
778
  cwd = File.expand_path("test/rubygems", PROJECT_DIR)
753
779
  actual_load_path = $LOAD_PATH.unshift(cwd).dup
754
780
 
755
- discover_path = File.join 'lib', 'sff', 'discover.rb'
781
+ discover_path = File.join "lib", "sff", "discover.rb"
756
782
 
757
- foo1, _ = %w(1 2).map do |version|
758
- spec = quick_gem 'sff', version do |s|
783
+ foo1, _ = %w[1 2].map do |version|
784
+ spec = quick_gem "sff", version do |s|
759
785
  s.files << discover_path
760
786
  end
761
787
 
762
- write_file(File.join 'gems', spec.full_name, discover_path) do |fp|
788
+ write_file(File.join "gems", spec.full_name, discover_path) do |fp|
763
789
  fp.puts "# #{spec.full_name}"
764
790
  end
765
791
 
@@ -767,19 +793,19 @@ class TestGem < Gem::TestCase
767
793
  end
768
794
  Gem.refresh
769
795
 
770
- write_file(File.join Dir.pwd, 'Gemfile') do |fp|
796
+ write_file(File.join Dir.pwd, "Gemfile") do |fp|
771
797
  fp.puts "source 'https://rubygems.org'"
772
798
  fp.puts "gem '#{foo1.name}', '#{foo1.version}'"
773
799
  end
774
- Gem.use_gemdeps(File.join Dir.pwd, 'Gemfile')
800
+ Gem.use_gemdeps(File.join Dir.pwd, "Gemfile")
775
801
 
776
802
  expected = [
777
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
778
- File.join(foo1.full_gem_path, discover_path)
803
+ File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR),
804
+ File.join(foo1.full_gem_path, discover_path),
779
805
  ].sort
780
806
 
781
- assert_equal expected, Gem.find_files('sff/discover').sort
782
- assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
807
+ assert_equal expected, Gem.find_files("sff/discover").sort
808
+ assert_equal expected, Gem.find_files("sff/**.rb").sort, "[ruby-core:31730]"
783
809
  ensure
784
810
  assert_equal cwd, actual_load_path.shift unless Gem.java_platform?
785
811
  end
@@ -788,14 +814,14 @@ class TestGem < Gem::TestCase
788
814
  cwd = File.expand_path("test/rubygems", PROJECT_DIR)
789
815
  $LOAD_PATH.unshift cwd
790
816
 
791
- discover_path = File.join 'lib', 'sff', 'discover.rb'
817
+ discover_path = File.join "lib", "sff", "discover.rb"
792
818
 
793
- _, foo2 = %w(1 2).map do |version|
794
- spec = quick_gem 'sff', version do |s|
819
+ _, foo2 = %w[1 2].map do |version|
820
+ spec = quick_gem "sff", version do |s|
795
821
  s.files << discover_path
796
822
  end
797
823
 
798
- write_file(File.join 'gems', spec.full_name, discover_path) do |fp|
824
+ write_file(File.join "gems", spec.full_name, discover_path) do |fp|
799
825
  fp.puts "# #{spec.full_name}"
800
826
  end
801
827
 
@@ -805,64 +831,103 @@ class TestGem < Gem::TestCase
805
831
  Gem.refresh
806
832
 
807
833
  expected = [
808
- File.expand_path('test/rubygems/sff/discover.rb', PROJECT_DIR),
834
+ File.expand_path("test/rubygems/sff/discover.rb", PROJECT_DIR),
809
835
  File.join(foo2.full_gem_path, discover_path),
810
836
  ]
811
837
 
812
- assert_equal expected, Gem.find_latest_files('sff/discover')
813
- assert_equal expected, Gem.find_latest_files('sff/**.rb'), '[ruby-core:31730]'
838
+ assert_equal expected, Gem.find_latest_files("sff/discover")
839
+ assert_equal expected, Gem.find_latest_files("sff/**.rb"), "[ruby-core:31730]"
814
840
  ensure
815
841
  assert_equal cwd, $LOAD_PATH.shift
816
842
  end
817
843
 
818
844
  def test_self_latest_spec_for
819
845
  gems = spec_fetcher do |fetcher|
820
- fetcher.spec 'a', 1
821
- fetcher.spec 'a', '3.a'
822
- fetcher.spec 'a', 2
846
+ fetcher.spec "a", 1
847
+ fetcher.spec "a", "3.a"
848
+ fetcher.spec "a", 2
823
849
  end
824
850
 
825
- spec = Gem.latest_spec_for 'a'
851
+ spec = Gem.latest_spec_for "a"
826
852
 
827
- assert_equal gems['a-2'], spec
853
+ assert_equal gems["a-2"], spec
854
+ end
855
+
856
+ def test_self_latest_spec_for_multiple_sources
857
+ uri = "https://example.sample.com/"
858
+ source = Gem::Source.new(uri)
859
+ source_list = Gem::SourceList.new
860
+ source_list << Gem::Source.new(@uri)
861
+ source_list << source
862
+ Gem.sources.replace source_list
863
+
864
+ spec_fetcher(uri) do |fetcher|
865
+ fetcher.spec "a", 1.1
866
+ end
867
+
868
+ gems = spec_fetcher do |fetcher|
869
+ fetcher.spec "a", 1
870
+ fetcher.spec "a", "3.a"
871
+ fetcher.spec "a", 2
872
+ end
873
+ spec = Gem.latest_spec_for "a"
874
+ assert_equal gems["a-2"], spec
828
875
  end
829
876
 
830
877
  def test_self_latest_rubygems_version
831
878
  spec_fetcher do |fetcher|
832
- fetcher.spec 'rubygems-update', '1.8.23'
833
- fetcher.spec 'rubygems-update', '1.8.24'
834
- fetcher.spec 'rubygems-update', '2.0.0.preview3'
879
+ fetcher.spec "rubygems-update", "1.8.23"
880
+ fetcher.spec "rubygems-update", "1.8.24"
881
+ fetcher.spec "rubygems-update", "2.0.0.preview3"
835
882
  end
836
883
 
837
884
  version = Gem.latest_rubygems_version
838
885
 
839
- assert_equal Gem::Version.new('1.8.24'), version
886
+ assert_equal Gem::Version.new("1.8.24"), version
840
887
  end
841
888
 
842
889
  def test_self_latest_version_for
843
890
  spec_fetcher do |fetcher|
844
- fetcher.spec 'a', 1
845
- fetcher.spec 'a', 2
846
- fetcher.spec 'a', '3.a'
891
+ fetcher.spec "a", 1
892
+ fetcher.spec "a", 2
893
+ fetcher.spec "a", "3.a"
894
+ end
895
+
896
+ version = Gem.latest_version_for "a"
897
+
898
+ assert_equal Gem::Version.new(2), version
899
+ end
900
+
901
+ def test_self_latest_version_for_multiple_sources
902
+ uri = "https://example.sample.com/"
903
+ source = Gem::Source.new(uri)
904
+ source_list = Gem::SourceList.new
905
+ source_list << Gem::Source.new(@uri)
906
+ source_list << source
907
+ Gem.sources.replace source_list
908
+
909
+ spec_fetcher(uri) do |fetcher|
910
+ fetcher.spec "a", 1.1
911
+ end
912
+
913
+ spec_fetcher do |fetcher|
914
+ fetcher.spec "a", 1
915
+ fetcher.spec "a", 2
916
+ fetcher.spec "a", "3.a"
847
917
  end
848
918
 
849
- version = Gem.latest_version_for 'a'
919
+ version = Gem.latest_version_for "a"
850
920
 
851
921
  assert_equal Gem::Version.new(2), version
852
922
  end
853
923
 
854
924
  def test_self_loaded_specs
855
- foo = util_spec 'foo'
925
+ foo = util_spec "foo"
856
926
  install_gem foo
857
927
 
858
928
  foo.activate
859
929
 
860
- assert_equal true, Gem.loaded_specs.keys.include?('foo')
861
- end
862
-
863
- def util_path
864
- ENV.delete "GEM_HOME"
865
- ENV.delete "GEM_PATH"
930
+ assert_equal true, Gem.loaded_specs.keys.include?("foo")
866
931
  end
867
932
 
868
933
  def test_self_path
@@ -870,53 +935,19 @@ class TestGem < Gem::TestCase
870
935
  end
871
936
 
872
937
  def test_self_path_default
873
- util_path
874
-
875
- if defined?(APPLE_GEM_HOME)
876
- orig_APPLE_GEM_HOME = APPLE_GEM_HOME
877
- Object.send :remove_const, :APPLE_GEM_HOME
878
- end
938
+ ENV.delete "GEM_HOME"
939
+ ENV.delete "GEM_PATH"
879
940
 
880
941
  Gem.instance_variable_set :@paths, nil
881
942
 
882
943
  assert_equal [Gem.default_path, Gem.dir].flatten.uniq, Gem.path
883
- ensure
884
- Object.const_set :APPLE_GEM_HOME, orig_APPLE_GEM_HOME if orig_APPLE_GEM_HOME
885
- end
886
-
887
- unless win_platform?
888
- def test_self_path_APPLE_GEM_HOME
889
- util_path
890
-
891
- Gem.clear_paths
892
- apple_gem_home = File.join @tempdir, 'apple_gem_home'
893
-
894
- old, $-w = $-w, nil
895
- Object.const_set :APPLE_GEM_HOME, apple_gem_home
896
- $-w = old
897
-
898
- assert_includes Gem.path, apple_gem_home
899
- ensure
900
- Object.send :remove_const, :APPLE_GEM_HOME
901
- end
902
-
903
- def test_self_path_APPLE_GEM_HOME_GEM_PATH
904
- Gem.clear_paths
905
- ENV['GEM_PATH'] = @gemhome
906
- apple_gem_home = File.join @tempdir, 'apple_gem_home'
907
- Gem.const_set :APPLE_GEM_HOME, apple_gem_home
908
-
909
- refute Gem.path.include?(apple_gem_home)
910
- ensure
911
- Gem.send :remove_const, :APPLE_GEM_HOME
912
- end
913
944
  end
914
945
 
915
946
  def test_self_path_ENV_PATH
916
947
  path_count = Gem.path.size
917
948
  Gem.clear_paths
918
949
 
919
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
950
+ ENV["GEM_PATH"] = @additional.join(File::PATH_SEPARATOR)
920
951
 
921
952
  assert_equal @additional, Gem.path[0,2]
922
953
 
@@ -928,10 +959,10 @@ class TestGem < Gem::TestCase
928
959
  def test_self_path_duplicate
929
960
  Gem.clear_paths
930
961
  util_ensure_gem_dirs
931
- dirs = @additional + [@gemhome] + [File.join(@tempdir, 'a')]
962
+ dirs = @additional + [@gemhome] + [File.join(@tempdir, "a")]
932
963
 
933
- ENV['GEM_HOME'] = @gemhome
934
- ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
964
+ ENV["GEM_HOME"] = @gemhome
965
+ ENV["GEM_PATH"] = dirs.join File::PATH_SEPARATOR
935
966
 
936
967
  assert_equal @gemhome, Gem.dir
937
968
 
@@ -943,8 +974,8 @@ class TestGem < Gem::TestCase
943
974
  Gem.clear_paths
944
975
 
945
976
  util_ensure_gem_dirs
946
- ENV['GEM_HOME'] = @gemhome
947
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
977
+ ENV["GEM_HOME"] = @gemhome
978
+ ENV["GEM_PATH"] = @additional.join(File::PATH_SEPARATOR)
948
979
 
949
980
  assert_equal @gemhome, Gem.dir
950
981
 
@@ -961,38 +992,38 @@ class TestGem < Gem::TestCase
961
992
  end
962
993
 
963
994
  def test_self_prefix_libdir
964
- orig_libdir = RbConfig::CONFIG['libdir']
965
- RbConfig::CONFIG['libdir'] = PROJECT_DIR
995
+ orig_libdir = RbConfig::CONFIG["libdir"]
996
+ RbConfig::CONFIG["libdir"] = PROJECT_DIR
966
997
 
967
998
  assert_nil Gem.prefix
968
999
  ensure
969
- RbConfig::CONFIG['libdir'] = orig_libdir
1000
+ RbConfig::CONFIG["libdir"] = orig_libdir
970
1001
  end
971
1002
 
972
1003
  def test_self_prefix_sitelibdir
973
- orig_sitelibdir = RbConfig::CONFIG['sitelibdir']
974
- RbConfig::CONFIG['sitelibdir'] = PROJECT_DIR
1004
+ orig_sitelibdir = RbConfig::CONFIG["sitelibdir"]
1005
+ RbConfig::CONFIG["sitelibdir"] = PROJECT_DIR
975
1006
 
976
1007
  assert_nil Gem.prefix
977
1008
  ensure
978
- RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir
1009
+ RbConfig::CONFIG["sitelibdir"] = orig_sitelibdir
979
1010
  end
980
1011
 
981
1012
  def test_self_read_binary
982
- File.open 'test', 'w' do |io|
1013
+ File.open "test", "w" do |io|
983
1014
  io.write "\xCF\x80"
984
1015
  end
985
1016
 
986
- assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
1017
+ assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a
987
1018
 
988
- skip 'chmod not supported' if Gem.win_platform?
1019
+ pend "chmod not supported" if Gem.win_platform?
989
1020
 
990
1021
  begin
991
- File.chmod 0444, 'test'
1022
+ File.chmod 0444, "test"
992
1023
 
993
- assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
1024
+ assert_equal ["\xCF", "\x80"], Gem.read_binary("test").chars.to_a
994
1025
  ensure
995
- File.chmod 0644, 'test'
1026
+ File.chmod 0644, "test"
996
1027
  end
997
1028
  end
998
1029
 
@@ -1030,111 +1061,95 @@ class TestGem < Gem::TestCase
1030
1061
 
1031
1062
  Gem.refresh
1032
1063
 
1033
- Gem::Specification.each{|spec| assert spec.activated? if spec == s}
1064
+ Gem::Specification.each {|spec| assert spec.activated? if spec == s }
1034
1065
 
1035
1066
  Gem.loaded_specs.delete(s)
1036
1067
  Gem.refresh
1037
1068
  end
1038
1069
 
1039
1070
  def test_self_ruby_escaping_spaces_in_path
1040
- with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do
1041
- ruby_install_name "ruby" do
1071
+ with_clean_path_to_ruby do
1072
+ with_rb_config_ruby("C:/Ruby 1.8/bin/ruby.exe") do
1042
1073
  assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
1043
1074
  end
1044
1075
  end
1045
1076
  end
1046
1077
 
1047
1078
  def test_self_ruby_path_without_spaces
1048
- with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do
1049
- ruby_install_name "ruby" do
1079
+ with_clean_path_to_ruby do
1080
+ with_rb_config_ruby("C:/Ruby18/bin/ruby.exe") do
1050
1081
  assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
1051
1082
  end
1052
1083
  end
1053
1084
  end
1054
1085
 
1055
1086
  def test_self_ruby_api_version
1056
- orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3'
1087
+ orig_ruby_version, RbConfig::CONFIG["ruby_version"] = RbConfig::CONFIG["ruby_version"], "1.2.3"
1057
1088
 
1058
1089
  Gem.instance_variable_set :@ruby_api_version, nil
1059
1090
 
1060
- assert_equal '1.2.3', Gem.ruby_api_version
1091
+ assert_equal "1.2.3", Gem.ruby_api_version
1061
1092
  ensure
1062
1093
  Gem.instance_variable_set :@ruby_api_version, nil
1063
1094
 
1064
- RbConfig::CONFIG['ruby_version'] = orig_ruby_version
1095
+ RbConfig::CONFIG["ruby_version"] = orig_ruby_version
1065
1096
  end
1066
1097
 
1067
1098
  def test_self_env_requirement
1068
- ENV["GEM_REQUIREMENT_FOO"] = '>= 1.2.3'
1069
- ENV["GEM_REQUIREMENT_BAR"] = '1.2.3'
1070
- ENV["GEM_REQUIREMENT_BAZ"] = 'abcd'
1071
-
1072
- assert_equal Gem::Requirement.create('>= 1.2.3'), Gem.env_requirement('foo')
1073
- assert_equal Gem::Requirement.create('1.2.3'), Gem.env_requirement('bAr')
1074
- assert_raises(Gem::Requirement::BadRequirementError) { Gem.env_requirement('baz') }
1075
- assert_equal Gem::Requirement.default, Gem.env_requirement('qux')
1076
- end
1077
-
1078
- def test_self_ruby_version_with_patchlevel_less_ancient_rubies
1079
- util_set_RUBY_VERSION '1.8.5'
1080
-
1081
- assert_equal Gem::Version.new('1.8.5'), Gem.ruby_version
1082
- ensure
1083
- util_restore_RUBY_VERSION
1084
- end
1085
-
1086
- def test_self_ruby_version_with_release
1087
- util_set_RUBY_VERSION '1.8.6', 287
1099
+ ENV["GEM_REQUIREMENT_FOO"] = ">= 1.2.3"
1100
+ ENV["GEM_REQUIREMENT_BAR"] = "1.2.3"
1101
+ ENV["GEM_REQUIREMENT_BAZ"] = "abcd"
1088
1102
 
1089
- assert_equal Gem::Version.new('1.8.6.287'), Gem.ruby_version
1090
- ensure
1091
- util_restore_RUBY_VERSION
1103
+ assert_equal Gem::Requirement.create(">= 1.2.3"), Gem.env_requirement("foo")
1104
+ assert_equal Gem::Requirement.create("1.2.3"), Gem.env_requirement("bAr")
1105
+ assert_raise(Gem::Requirement::BadRequirementError) { Gem.env_requirement("baz") }
1106
+ assert_equal Gem::Requirement.default, Gem.env_requirement("qux")
1092
1107
  end
1093
1108
 
1094
1109
  def test_self_ruby_version_with_non_mri_implementations
1095
- util_set_RUBY_VERSION '2.5.0', 0, 60928, 'jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]'
1110
+ util_set_RUBY_VERSION "2.5.0", 0, 60928, "jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]"
1096
1111
 
1097
- assert_equal Gem::Version.new('2.5.0'), Gem.ruby_version
1112
+ assert_equal Gem::Version.new("2.5.0"), Gem.ruby_version
1098
1113
  ensure
1099
1114
  util_restore_RUBY_VERSION
1100
1115
  end
1101
1116
 
1102
1117
  def test_self_ruby_version_with_svn_prerelease
1103
- util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
1118
+ util_set_RUBY_VERSION "2.6.0", -1, 63539, "ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]"
1104
1119
 
1105
- assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
1120
+ assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version
1106
1121
  ensure
1107
1122
  util_restore_RUBY_VERSION
1108
1123
  end
1109
1124
 
1110
1125
  def test_self_ruby_version_with_git_prerelease
1111
- util_set_RUBY_VERSION '2.7.0', -1, 'b563439274a402e33541f5695b1bfd4ac1085638', 'ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]'
1126
+ util_set_RUBY_VERSION "2.7.0", -1, "b563439274a402e33541f5695b1bfd4ac1085638", "ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]"
1112
1127
 
1113
- assert_equal Gem::Version.new('2.7.0.preview3'), Gem.ruby_version
1128
+ assert_equal Gem::Version.new("2.7.0.preview3"), Gem.ruby_version
1114
1129
  ensure
1115
1130
  util_restore_RUBY_VERSION
1116
1131
  end
1117
1132
 
1118
1133
  def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility
1119
- util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0'
1134
+ util_set_RUBY_VERSION "2.6.0", -1, 63539, "weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]", "weirdjruby", "9.2.0.0"
1120
1135
 
1121
- assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
1136
+ assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version
1122
1137
  ensure
1123
1138
  util_restore_RUBY_VERSION
1124
1139
  end
1125
1140
 
1126
1141
  def test_self_ruby_version_with_svn_trunk
1127
- util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]'
1142
+ util_set_RUBY_VERSION "1.9.2", -1, 23493, "ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]"
1128
1143
 
1129
- assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version
1144
+ assert_equal Gem::Version.new("1.9.2.dev"), Gem.ruby_version
1130
1145
  ensure
1131
1146
  util_restore_RUBY_VERSION
1132
1147
  end
1133
1148
 
1134
1149
  def test_self_ruby_version_with_git_master
1135
- util_set_RUBY_VERSION '2.7.0', -1, '5de284ec78220e75643f89b454ce999da0c1c195', 'ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]'
1150
+ util_set_RUBY_VERSION "2.7.0", -1, "5de284ec78220e75643f89b454ce999da0c1c195", "ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]"
1136
1151
 
1137
- assert_equal Gem::Version.new('2.7.0.dev'), Gem.ruby_version
1152
+ assert_equal Gem::Version.new("2.7.0.dev"), Gem.ruby_version
1138
1153
  ensure
1139
1154
  util_restore_RUBY_VERSION
1140
1155
  end
@@ -1144,7 +1159,7 @@ class TestGem < Gem::TestCase
1144
1159
  end
1145
1160
 
1146
1161
  def test_self_paths_eq
1147
- other = File.join @tempdir, 'other'
1162
+ other = File.join @tempdir, "other"
1148
1163
  path = [@userhome, other].join File::PATH_SEPARATOR
1149
1164
 
1150
1165
  #
@@ -1157,12 +1172,12 @@ class TestGem < Gem::TestCase
1157
1172
  end
1158
1173
 
1159
1174
  def test_self_paths_eq_nonexistent_home
1160
- ENV['GEM_HOME'] = @gemhome
1175
+ ENV["GEM_HOME"] = @gemhome
1161
1176
  Gem.clear_paths
1162
1177
 
1163
- other = File.join @tempdir, 'other'
1178
+ other = File.join @tempdir, "other"
1164
1179
 
1165
- ENV['HOME'] = other
1180
+ ENV["HOME"] = other
1166
1181
 
1167
1182
  Gem.paths = { "GEM_PATH" => other }
1168
1183
 
@@ -1172,7 +1187,7 @@ class TestGem < Gem::TestCase
1172
1187
  def test_self_post_build
1173
1188
  assert_equal 1, Gem.post_build_hooks.length
1174
1189
 
1175
- Gem.post_build { |installer| }
1190
+ Gem.post_build {|installer| }
1176
1191
 
1177
1192
  assert_equal 2, Gem.post_build_hooks.length
1178
1193
  end
@@ -1180,7 +1195,7 @@ class TestGem < Gem::TestCase
1180
1195
  def test_self_post_install
1181
1196
  assert_equal 1, Gem.post_install_hooks.length
1182
1197
 
1183
- Gem.post_install { |installer| }
1198
+ Gem.post_install {|installer| }
1184
1199
 
1185
1200
  assert_equal 2, Gem.post_install_hooks.length
1186
1201
  end
@@ -1188,7 +1203,7 @@ class TestGem < Gem::TestCase
1188
1203
  def test_self_done_installing
1189
1204
  assert_empty Gem.done_installing_hooks
1190
1205
 
1191
- Gem.done_installing { |gems| }
1206
+ Gem.done_installing {|gems| }
1192
1207
 
1193
1208
  assert_equal 1, Gem.done_installing_hooks.length
1194
1209
  end
@@ -1196,7 +1211,7 @@ class TestGem < Gem::TestCase
1196
1211
  def test_self_post_reset
1197
1212
  assert_empty Gem.post_reset_hooks
1198
1213
 
1199
- Gem.post_reset { }
1214
+ Gem.post_reset {}
1200
1215
 
1201
1216
  assert_equal 1, Gem.post_reset_hooks.length
1202
1217
  end
@@ -1204,7 +1219,7 @@ class TestGem < Gem::TestCase
1204
1219
  def test_self_post_uninstall
1205
1220
  assert_equal 1, Gem.post_uninstall_hooks.length
1206
1221
 
1207
- Gem.post_uninstall { |installer| }
1222
+ Gem.post_uninstall {|installer| }
1208
1223
 
1209
1224
  assert_equal 2, Gem.post_uninstall_hooks.length
1210
1225
  end
@@ -1212,7 +1227,7 @@ class TestGem < Gem::TestCase
1212
1227
  def test_self_pre_install
1213
1228
  assert_equal 1, Gem.pre_install_hooks.length
1214
1229
 
1215
- Gem.pre_install { |installer| }
1230
+ Gem.pre_install {|installer| }
1216
1231
 
1217
1232
  assert_equal 2, Gem.pre_install_hooks.length
1218
1233
  end
@@ -1220,7 +1235,7 @@ class TestGem < Gem::TestCase
1220
1235
  def test_self_pre_reset
1221
1236
  assert_empty Gem.pre_reset_hooks
1222
1237
 
1223
- Gem.pre_reset { }
1238
+ Gem.pre_reset {}
1224
1239
 
1225
1240
  assert_equal 1, Gem.pre_reset_hooks.length
1226
1241
  end
@@ -1228,7 +1243,7 @@ class TestGem < Gem::TestCase
1228
1243
  def test_self_pre_uninstall
1229
1244
  assert_equal 1, Gem.pre_uninstall_hooks.length
1230
1245
 
1231
- Gem.pre_uninstall { |installer| }
1246
+ Gem.pre_uninstall {|installer| }
1232
1247
 
1233
1248
  assert_equal 2, Gem.pre_uninstall_hooks.length
1234
1249
  end
@@ -1241,73 +1256,74 @@ class TestGem < Gem::TestCase
1241
1256
  end
1242
1257
 
1243
1258
  def test_try_activate_returns_true_for_activated_specs
1244
- b = util_spec 'b', '1.0' do |spec|
1245
- spec.files << 'lib/b.rb'
1259
+ b = util_spec "b", "1.0" do |spec|
1260
+ spec.files << "lib/b.rb"
1246
1261
  end
1247
1262
  install_specs b
1248
1263
 
1249
- assert Gem.try_activate('b'), 'try_activate should return true'
1250
- assert Gem.try_activate('b'), 'try_activate should still return true'
1264
+ assert Gem.try_activate("b"), "try_activate should return true"
1265
+ assert Gem.try_activate("b"), "try_activate should still return true"
1251
1266
  end
1252
1267
 
1253
1268
  def test_spec_order_is_consistent
1254
- b1 = util_spec 'b', '1.0'
1255
- b2 = util_spec 'b', '2.0'
1256
- b3 = util_spec 'b', '3.0'
1269
+ b1 = util_spec "b", "1.0"
1270
+ b2 = util_spec "b", "2.0"
1271
+ b3 = util_spec "b", "3.0"
1257
1272
 
1258
1273
  install_specs b1, b2, b3
1259
1274
 
1260
- specs1 = Gem::Specification.stubs.find_all { |s| s.name == 'b' }
1275
+ specs1 = Gem::Specification.stubs.find_all {|s| s.name == "b" }
1261
1276
  Gem::Specification.reset
1262
- specs2 = Gem::Specification.stubs_for('b')
1277
+ specs2 = Gem::Specification.stubs_for("b")
1263
1278
  assert_equal specs1.map(&:version), specs2.map(&:version)
1264
1279
  end
1265
1280
 
1266
1281
  def test_self_try_activate_missing_dep
1267
- b = util_spec 'b', '1.0'
1268
- a = util_spec 'a', '1.0', 'b' => '>= 1.0'
1282
+ b = util_spec "b", "1.0"
1283
+ a = util_spec "a", "1.0", "b" => ">= 1.0"
1269
1284
 
1270
1285
  install_specs b, a
1271
1286
  uninstall_gem b
1272
1287
 
1273
- a_file = File.join a.gem_dir, 'lib', 'a_file.rb'
1288
+ a_file = File.join a.gem_dir, "lib", "a_file.rb"
1274
1289
 
1275
1290
  write_file a_file do |io|
1276
- io.puts '# a_file.rb'
1291
+ io.puts "# a_file.rb"
1277
1292
  end
1278
1293
 
1279
- e = assert_raises Gem::MissingSpecError do
1280
- Gem.try_activate 'a_file'
1294
+ e = assert_raise Gem::MissingSpecError do
1295
+ Gem.try_activate "a_file"
1281
1296
  end
1282
1297
 
1283
- assert_match %r%Could not find 'b' %, e.message
1298
+ assert_match %r{Could not find 'b' }, e.message
1299
+ assert_match %r{at: #{a.spec_file}}, e.message
1284
1300
  end
1285
1301
 
1286
1302
  def test_self_try_activate_missing_prerelease
1287
- b = util_spec 'b', '1.0rc1'
1288
- a = util_spec 'a', '1.0rc1', 'b' => '1.0rc1'
1303
+ b = util_spec "b", "1.0rc1"
1304
+ a = util_spec "a", "1.0rc1", "b" => "1.0rc1"
1289
1305
 
1290
1306
  install_specs b, a
1291
1307
  uninstall_gem b
1292
1308
 
1293
- a_file = File.join a.gem_dir, 'lib', 'a_file.rb'
1309
+ a_file = File.join a.gem_dir, "lib", "a_file.rb"
1294
1310
 
1295
1311
  write_file a_file do |io|
1296
- io.puts '# a_file.rb'
1312
+ io.puts "# a_file.rb"
1297
1313
  end
1298
1314
 
1299
- e = assert_raises Gem::MissingSpecError do
1300
- Gem.try_activate 'a_file'
1315
+ e = assert_raise Gem::MissingSpecError do
1316
+ Gem.try_activate "a_file"
1301
1317
  end
1302
1318
 
1303
- assert_match %r%Could not find 'b' \(= 1.0rc1\)%, e.message
1319
+ assert_match %r{Could not find 'b' \(= 1.0rc1\)}, e.message
1304
1320
  end
1305
1321
 
1306
1322
  def test_self_try_activate_missing_extensions
1307
- spec = util_spec 'ext', '1' do |s|
1323
+ spec = util_spec "ext", "1" do |s|
1308
1324
  s.extensions = %w[ext/extconf.rb]
1309
1325
  s.mark_version
1310
- s.installed_by_version = v('2.2')
1326
+ s.installed_by_version = v("2.2")
1311
1327
  end
1312
1328
 
1313
1329
  # write the spec without install to simulate a failed install
@@ -1315,8 +1331,8 @@ class TestGem < Gem::TestCase
1315
1331
  io.write spec.to_ruby_for_cache
1316
1332
  end
1317
1333
 
1318
- _, err = capture_io do
1319
- refute Gem.try_activate 'nonexistent'
1334
+ _, err = capture_output do
1335
+ refute Gem.try_activate "nonexistent"
1320
1336
  end
1321
1337
 
1322
1338
  unless Gem.java_platform?
@@ -1328,43 +1344,43 @@ class TestGem < Gem::TestCase
1328
1344
  end
1329
1345
 
1330
1346
  def test_self_use_paths_with_nils
1331
- orig_home = ENV.delete 'GEM_HOME'
1332
- orig_path = ENV.delete 'GEM_PATH'
1347
+ orig_home = ENV.delete "GEM_HOME"
1348
+ orig_path = ENV.delete "GEM_PATH"
1333
1349
  Gem.use_paths nil, nil
1334
1350
  assert_equal Gem.default_dir, Gem.paths.home
1335
1351
  path = (Gem.default_path + [Gem.paths.home]).uniq
1336
1352
  assert_equal path, Gem.paths.path
1337
1353
  ensure
1338
- ENV['GEM_HOME'] = orig_home
1339
- ENV['GEM_PATH'] = orig_path
1354
+ ENV["GEM_HOME"] = orig_home
1355
+ ENV["GEM_PATH"] = orig_path
1340
1356
  end
1341
1357
 
1342
1358
  def test_setting_paths_does_not_warn_about_unknown_keys
1343
- stdout, stderr = capture_io do
1344
- Gem.paths = { 'foo' => [],
1345
- 'bar' => Object.new,
1346
- 'GEM_HOME' => Gem.paths.home,
1347
- 'GEM_PATH' => 'foo' }
1359
+ stdout, stderr = capture_output do
1360
+ Gem.paths = { "foo" => [],
1361
+ "bar" => Object.new,
1362
+ "GEM_HOME" => Gem.paths.home,
1363
+ "GEM_PATH" => "foo" }
1348
1364
  end
1349
- assert_equal ['foo', Gem.paths.home], Gem.paths.path
1350
- assert_equal '', stderr
1351
- assert_equal '', stdout
1365
+ assert_equal ["foo", Gem.paths.home], Gem.paths.path
1366
+ assert_equal "", stderr
1367
+ assert_equal "", stdout
1352
1368
  end
1353
1369
 
1354
1370
  def test_setting_paths_does_not_mutate_parameter_object
1355
- Gem.paths = { 'GEM_HOME' => Gem.paths.home,
1356
- 'GEM_PATH' => 'foo' }.freeze
1357
- assert_equal ['foo', Gem.paths.home], Gem.paths.path
1371
+ Gem.paths = { "GEM_HOME" => Gem.paths.home,
1372
+ "GEM_PATH" => "foo" }.freeze
1373
+ assert_equal ["foo", Gem.paths.home], Gem.paths.path
1358
1374
  end
1359
1375
 
1360
1376
  def test_deprecated_paths=
1361
- stdout, stderr = capture_io do
1362
- Gem.paths = { 'GEM_HOME' => Gem.paths.home,
1363
- 'GEM_PATH' => [Gem.paths.home, 'foo'] }
1377
+ stdout, stderr = capture_output do
1378
+ Gem.paths = { "GEM_HOME" => Gem.paths.home,
1379
+ "GEM_PATH" => [Gem.paths.home, "foo"] }
1364
1380
  end
1365
- assert_equal [Gem.paths.home, 'foo'], Gem.paths.path
1381
+ assert_equal [Gem.paths.home, "foo"], Gem.paths.path
1366
1382
  assert_match(/Array values in the parameter to `Gem.paths=` are deprecated.\nPlease use a String or nil/m, stderr)
1367
- assert_equal '', stdout
1383
+ assert_equal "", stdout
1368
1384
  end
1369
1385
 
1370
1386
  def test_self_use_paths
@@ -1377,17 +1393,19 @@ class TestGem < Gem::TestCase
1377
1393
  end
1378
1394
 
1379
1395
  def test_self_user_dir
1380
- parts = [@userhome, '.gem', Gem.ruby_engine]
1381
- parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
1396
+ parts = [@userhome, ".gem", Gem.ruby_engine]
1397
+ parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty?
1398
+
1399
+ FileUtils.mkdir_p File.join(parts)
1382
1400
 
1383
1401
  assert_equal File.join(parts), Gem.user_dir
1384
1402
  end
1385
1403
 
1386
1404
  def test_self_user_home
1387
- if ENV['HOME']
1388
- assert_equal ENV['HOME'], Gem.user_home
1405
+ if ENV["HOME"]
1406
+ assert_equal ENV["HOME"], Gem.user_home
1389
1407
  else
1390
- assert true, 'count this test'
1408
+ assert true, "count this test"
1391
1409
  end
1392
1410
  end
1393
1411
 
@@ -1403,30 +1421,28 @@ class TestGem < Gem::TestCase
1403
1421
  r.gem "b", "= 1"
1404
1422
  end
1405
1423
 
1406
- activated = Gem::Specification.map { |x| x.full_name }
1424
+ activated = Gem::Specification.map {|x| x.full_name }
1407
1425
 
1408
- assert_equal %w!a-1 b-1 c-2!, activated.sort
1426
+ assert_equal %w[a-1 b-1 c-2], activated.sort
1409
1427
  end
1410
1428
 
1411
1429
  def test_self_needs_picks_up_unresolved_deps
1412
- save_loaded_features do
1413
- a = util_spec "a", "1"
1414
- b = util_spec "b", "1", "c" => nil
1415
- c = util_spec "c", "2"
1416
- d = util_spec "d", "1", {'e' => '= 1'}, "lib/d#{$$}.rb"
1417
- e = util_spec "e", "1"
1418
-
1419
- install_specs a, c, b, e, d
1430
+ a = util_spec "a", "1"
1431
+ b = util_spec "b", "1", "c" => nil
1432
+ c = util_spec "c", "2"
1433
+ d = util_spec "d", "1", { "e" => "= 1" }, "lib/d#{$$}.rb"
1434
+ e = util_spec "e", "1"
1420
1435
 
1421
- Gem.needs do |r|
1422
- r.gem "a"
1423
- r.gem "b", "= 1"
1436
+ install_specs a, c, b, e, d
1424
1437
 
1425
- require "d#{$$}"
1426
- end
1438
+ Gem.needs do |r|
1439
+ r.gem "a"
1440
+ r.gem "b", "= 1"
1427
1441
 
1428
- assert_equal %w!a-1 b-1 c-2 d-1 e-1!, loaded_spec_names
1442
+ require "d#{$$}"
1429
1443
  end
1444
+
1445
+ assert_equal %w[a-1 b-1 c-2 d-1 e-1], loaded_spec_names
1430
1446
  end
1431
1447
 
1432
1448
  def test_self_gunzip
@@ -1435,35 +1451,35 @@ class TestGem < Gem::TestCase
1435
1451
 
1436
1452
  output = Gem::Util.gunzip input
1437
1453
 
1438
- assert_equal 'hello', output
1454
+ assert_equal "hello", output
1439
1455
  assert_equal Encoding::BINARY, output.encoding
1440
1456
  end
1441
1457
 
1442
1458
  def test_self_gzip
1443
- input = 'hello'
1459
+ input = "hello"
1444
1460
 
1445
1461
  output = Gem::Util.gzip input
1446
1462
 
1447
1463
  zipped = StringIO.new output
1448
1464
 
1449
- assert_equal 'hello', Zlib::GzipReader.new(zipped).read
1465
+ assert_equal "hello", Zlib::GzipReader.new(zipped).read
1450
1466
  assert_equal Encoding::BINARY, output.encoding
1451
1467
  end
1452
1468
 
1453
1469
  def test_self_vendor_dir
1454
- vendordir(File.join(@tempdir, 'vendor')) do
1470
+ vendordir(File.join(@tempdir, "vendor")) do
1455
1471
  expected =
1456
- File.join RbConfig::CONFIG['vendordir'], 'gems',
1457
- RbConfig::CONFIG['ruby_version']
1472
+ File.join RbConfig::CONFIG["vendordir"], "gems",
1473
+ RbConfig::CONFIG["ruby_version"]
1458
1474
 
1459
1475
  assert_equal expected, Gem.vendor_dir
1460
1476
  end
1461
1477
  end
1462
1478
 
1463
1479
  def test_self_vendor_dir_ENV_GEM_VENDOR
1464
- ENV['GEM_VENDOR'] = File.join @tempdir, 'vendor', 'gems'
1480
+ ENV["GEM_VENDOR"] = File.join @tempdir, "vendor", "gems"
1465
1481
 
1466
- assert_equal ENV['GEM_VENDOR'], Gem.vendor_dir
1482
+ assert_equal ENV["GEM_VENDOR"], Gem.vendor_dir
1467
1483
  refute Gem.vendor_dir.frozen?
1468
1484
  end
1469
1485
 
@@ -1477,28 +1493,52 @@ class TestGem < Gem::TestCase
1477
1493
  plugin_path = File.join "lib", "rubygems_plugin.rb"
1478
1494
 
1479
1495
  Dir.chdir @tempdir do
1480
- FileUtils.mkdir_p 'lib'
1496
+ FileUtils.mkdir_p "lib"
1481
1497
  File.open plugin_path, "w" do |fp|
1482
1498
  fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end"
1483
1499
  end
1484
1500
 
1485
- foo1 = util_spec 'foo', '1' do |s|
1501
+ foo1 = util_spec "foo", "1" do |s|
1486
1502
  s.files << plugin_path
1487
1503
  end
1488
1504
 
1489
1505
  install_gem foo1
1490
1506
 
1491
- foo2 = util_spec 'foo', '2' do |s|
1507
+ foo2 = util_spec "foo", "2" do |s|
1492
1508
  s.files << plugin_path
1493
1509
  end
1494
1510
 
1495
1511
  install_gem foo2
1496
1512
  end
1497
1513
 
1498
- Gem.searcher = nil
1499
1514
  Gem::Specification.reset
1500
1515
 
1501
- gem 'foo'
1516
+ gem "foo"
1517
+
1518
+ Gem.load_plugins
1519
+
1520
+ assert_equal %w[plugin], PLUGINS_LOADED
1521
+ end
1522
+
1523
+ def test_load_user_installed_plugins
1524
+ plugin_path = File.join "lib", "rubygems_plugin.rb"
1525
+
1526
+ Dir.chdir @tempdir do
1527
+ FileUtils.mkdir_p "lib"
1528
+ File.open plugin_path, "w" do |fp|
1529
+ fp.puts "class TestGem; PLUGINS_LOADED << 'plugin'; end"
1530
+ end
1531
+
1532
+ foo = util_spec "foo", "1" do |s|
1533
+ s.files << plugin_path
1534
+ end
1535
+
1536
+ install_gem_user foo
1537
+ end
1538
+
1539
+ Gem.paths = { "GEM_PATH" => [Gem.dir, Gem.user_dir].join(File::PATH_SEPARATOR) }
1540
+
1541
+ gem "foo"
1502
1542
 
1503
1543
  Gem.load_plugins
1504
1544
 
@@ -1506,30 +1546,30 @@ class TestGem < Gem::TestCase
1506
1546
  end
1507
1547
 
1508
1548
  def test_load_env_plugins
1509
- with_plugin('load') { Gem.load_env_plugins }
1549
+ with_plugin("load") { Gem.load_env_plugins }
1510
1550
  assert_equal :loaded, TEST_PLUGIN_LOAD rescue nil
1511
1551
 
1512
1552
  util_remove_interrupt_command
1513
1553
 
1514
1554
  # Should attempt to cause a StandardError
1515
- with_plugin('standarderror') { Gem.load_env_plugins }
1555
+ with_plugin("standarderror") { Gem.load_env_plugins }
1516
1556
  assert_equal :loaded, TEST_PLUGIN_STANDARDERROR rescue nil
1517
1557
 
1518
1558
  util_remove_interrupt_command
1519
1559
 
1520
1560
  # Should attempt to cause an Exception
1521
- with_plugin('exception') { Gem.load_env_plugins }
1561
+ with_plugin("exception") { Gem.load_env_plugins }
1522
1562
  assert_equal :loaded, TEST_PLUGIN_EXCEPTION rescue nil
1523
1563
  end
1524
1564
 
1525
1565
  def test_gem_path_ordering
1526
1566
  refute_equal Gem.dir, Gem.user_dir
1527
1567
 
1528
- write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
1529
- write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
1568
+ write_file File.join(@tempdir, "lib", "g.rb") {|fp| fp.puts "" }
1569
+ write_file File.join(@tempdir, "lib", "m.rb") {|fp| fp.puts "" }
1530
1570
 
1531
- g = util_spec 'g', '1', nil, "lib/g.rb"
1532
- m = util_spec 'm', '1', nil, "lib/m.rb"
1571
+ g = util_spec "g", "1", nil, "lib/g.rb"
1572
+ m = util_spec "m", "1", nil, "lib/m.rb"
1533
1573
 
1534
1574
  install_gem g, :install_dir => Gem.dir
1535
1575
  m0 = install_gem m, :install_dir => Gem.dir
@@ -1540,7 +1580,7 @@ class TestGem < Gem::TestCase
1540
1580
 
1541
1581
  tests = [
1542
1582
  [:dir0, [ Gem.dir, Gem.user_dir], m0],
1543
- [:dir1, [ Gem.user_dir, Gem.dir], m1]
1583
+ [:dir1, [ Gem.user_dir, Gem.dir], m1],
1544
1584
  ]
1545
1585
 
1546
1586
  tests.each do |_name, _paths, expected|
@@ -1548,15 +1588,15 @@ class TestGem < Gem::TestCase
1548
1588
  Gem::Specification.reset
1549
1589
  Gem.searcher = nil
1550
1590
 
1551
- assert_equal Gem::Dependency.new('m','1').to_specs,
1552
- Gem::Dependency.new('m','1').to_specs.sort
1591
+ assert_equal Gem::Dependency.new("m","1").to_specs,
1592
+ Gem::Dependency.new("m","1").to_specs.sort
1553
1593
 
1554
1594
  assert_equal \
1555
1595
  [expected.gem_dir],
1556
- Gem::Dependency.new('m','1').to_specs.map(&:gem_dir).sort,
1596
+ Gem::Dependency.new("m","1").to_specs.map(&:gem_dir).sort,
1557
1597
  "Wrong specs for #{_name}"
1558
1598
 
1559
- spec = Gem::Dependency.new('m','1').to_spec
1599
+ spec = Gem::Dependency.new("m","1").to_spec
1560
1600
 
1561
1601
  assert_equal \
1562
1602
  File.join(_paths.first, "gems", "m-1"),
@@ -1566,7 +1606,7 @@ class TestGem < Gem::TestCase
1566
1606
 
1567
1607
  gem "m"
1568
1608
 
1569
- spec = Gem::Dependency.new('m','1').to_spec
1609
+ spec = Gem::Dependency.new("m","1").to_spec
1570
1610
  assert spec.activated?, "dependency not activated for #{_name}"
1571
1611
 
1572
1612
  assert_equal \
@@ -1581,11 +1621,11 @@ class TestGem < Gem::TestCase
1581
1621
  end
1582
1622
 
1583
1623
  def test_gem_path_ordering_short
1584
- write_file File.join(@tempdir, 'lib', "g.rb") { |fp| fp.puts "" }
1585
- write_file File.join(@tempdir, 'lib', 'm.rb') { |fp| fp.puts "" }
1624
+ write_file File.join(@tempdir, "lib", "g.rb") {|fp| fp.puts "" }
1625
+ write_file File.join(@tempdir, "lib", "m.rb") {|fp| fp.puts "" }
1586
1626
 
1587
- g = util_spec 'g', '1', nil, "lib/g.rb"
1588
- m = util_spec 'm', '1', nil, "lib/m.rb"
1627
+ g = util_spec "g", "1", nil, "lib/g.rb"
1628
+ m = util_spec "m", "1", nil, "lib/m.rb"
1589
1629
 
1590
1630
  install_gem g, :install_dir => Gem.dir
1591
1631
  install_gem m, :install_dir => Gem.dir
@@ -1595,7 +1635,7 @@ class TestGem < Gem::TestCase
1595
1635
 
1596
1636
  assert_equal \
1597
1637
  File.join(Gem.dir, "gems", "m-1"),
1598
- Gem::Dependency.new('m','1').to_spec.gem_dir,
1638
+ Gem::Dependency.new("m","1").to_spec.gem_dir,
1599
1639
  "Wrong spec selected"
1600
1640
  end
1601
1641
 
@@ -1614,11 +1654,11 @@ class TestGem < Gem::TestCase
1614
1654
  f.puts "gem 'c'"
1615
1655
  end
1616
1656
 
1617
- ENV['RUBYGEMS_GEMDEPS'] = path
1657
+ with_rubygems_gemdeps(path) do
1658
+ Gem.use_gemdeps
1618
1659
 
1619
- Gem.use_gemdeps
1620
-
1621
- assert_equal add_bundler_full_name(%W(a-1 b-1 c-1)), loaded_spec_names
1660
+ assert_equal add_bundler_full_name(%W[a-1 b-1 c-1]), loaded_spec_names
1661
+ end
1622
1662
  end
1623
1663
 
1624
1664
  def test_auto_activation_of_used_gemdeps_file
@@ -1636,14 +1676,16 @@ class TestGem < Gem::TestCase
1636
1676
  f.puts "gem 'c'"
1637
1677
  end
1638
1678
 
1639
- ENV['RUBYGEMS_GEMDEPS'] = "-"
1679
+ with_rubygems_gemdeps("-") do
1680
+ expected_specs = [a, b, util_spec("bundler", Bundler::VERSION), c].compact.map(&:full_name)
1640
1681
 
1641
- expected_specs = [a, b, util_spec("bundler", Bundler::VERSION), c].compact
1642
- assert_equal expected_specs, Gem.use_gemdeps.sort_by { |s| s.name }
1682
+ Gem.use_gemdeps
1683
+
1684
+ assert_equal expected_specs, loaded_spec_names
1685
+ end
1643
1686
  end
1644
1687
 
1645
- LIB_PATH = File.expand_path "../../../lib".dup.tap(&Gem::UNTAINT), __FILE__.dup.tap(&Gem::UNTAINT)
1646
- BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }.dup.tap(&Gem::UNTAINT)
1688
+ BUNDLER_LIB_PATH = File.expand_path $LOAD_PATH.find {|lp| File.file?(File.join(lp, "bundler.rb")) }
1647
1689
  BUNDLER_FULL_NAME = "bundler-#{Bundler::VERSION}".freeze
1648
1690
 
1649
1691
  def add_bundler_full_name(names)
@@ -1652,10 +1694,18 @@ class TestGem < Gem::TestCase
1652
1694
  names
1653
1695
  end
1654
1696
 
1655
- def test_looks_for_gemdeps_files_automatically_on_start
1656
- skip "Requiring bundler messes things up" if Gem.java_platform?
1697
+ def test_looks_for_gemdeps_files_automatically_from_binstubs
1698
+ pend "Requiring bundler messes things up" if Gem.java_platform?
1699
+
1700
+ a = util_spec "a", "1" do |s|
1701
+ s.executables = %w[foo]
1702
+ s.bindir = "exe"
1703
+ end
1704
+
1705
+ write_file File.join(@tempdir, "exe", "foo") do |fp|
1706
+ fp.puts "puts Gem.loaded_specs.values.map(&:full_name).sort"
1707
+ end
1657
1708
 
1658
- a = util_spec "a", "1", nil, "lib/a.rb"
1659
1709
  b = util_spec "b", "1", nil, "lib/b.rb"
1660
1710
  c = util_spec "c", "1", nil, "lib/c.rb"
1661
1711
 
@@ -1666,32 +1716,45 @@ class TestGem < Gem::TestCase
1666
1716
  install_gem b, :install_dir => path
1667
1717
  install_gem c, :install_dir => path
1668
1718
 
1669
- ENV['GEM_PATH'] = path
1670
- ENV['RUBYGEMS_GEMDEPS'] = "-"
1719
+ ENV["GEM_PATH"] = path
1671
1720
 
1672
- path = File.join @tempdir, "gem.deps.rb"
1673
- cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
1674
- "-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
1675
- cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
1721
+ with_rubygems_gemdeps("-") do
1722
+ new_PATH = [File.join(path, "bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
1723
+ new_RUBYOPT = "-I#{rubygems_path} -I#{BUNDLER_LIB_PATH}"
1676
1724
 
1677
- File.open path, "w" do |f|
1678
- f.puts "gem 'a'"
1679
- end
1680
- out0 = IO.popen(cmd, &:read).split(/\n/)
1725
+ path = File.join @tempdir, "gem.deps.rb"
1681
1726
 
1682
- File.open path, "a" do |f|
1683
- f.puts "gem 'b'"
1684
- f.puts "gem 'c'"
1685
- end
1686
- out = IO.popen(cmd, &:read).split(/\n/)
1727
+ File.open path, "w" do |f|
1728
+ f.puts "gem 'a'"
1729
+ end
1730
+ out0 = with_path_and_rubyopt(new_PATH, new_RUBYOPT) do
1731
+ IO.popen("foo", &:read).split(/\n/)
1732
+ end
1733
+
1734
+ File.open path, "a" do |f|
1735
+ f.puts "gem 'b'"
1736
+ f.puts "gem 'c'"
1737
+ end
1738
+ out = with_path_and_rubyopt(new_PATH, new_RUBYOPT) do
1739
+ IO.popen("foo", &:read).split(/\n/)
1740
+ end
1687
1741
 
1688
- assert_equal ["b-1", "c-1"], out - out0
1742
+ assert_equal ["b-1", "c-1"], out - out0
1743
+ end
1689
1744
  end
1690
1745
 
1691
- def test_looks_for_gemdeps_files_automatically_on_start_in_parent_dir
1692
- skip "Requiring bundler messes things up" if Gem.java_platform?
1746
+ def test_looks_for_gemdeps_files_automatically_from_binstubs_in_parent_dir
1747
+ pend "Requiring bundler messes things up" if Gem.java_platform?
1748
+
1749
+ a = util_spec "a", "1" do |s|
1750
+ s.executables = %w[foo]
1751
+ s.bindir = "exe"
1752
+ end
1753
+
1754
+ write_file File.join(@tempdir, "exe", "foo") do |fp|
1755
+ fp.puts "puts Gem.loaded_specs.values.map(&:full_name).sort"
1756
+ end
1693
1757
 
1694
- a = util_spec "a", "1", nil, "lib/a.rb"
1695
1758
  b = util_spec "b", "1", nil, "lib/b.rb"
1696
1759
  c = util_spec "c", "1", nil, "lib/c.rb"
1697
1760
 
@@ -1702,30 +1765,35 @@ class TestGem < Gem::TestCase
1702
1765
  install_gem b, :install_dir => path
1703
1766
  install_gem c, :install_dir => path
1704
1767
 
1705
- ENV['GEM_PATH'] = path
1706
- ENV['RUBYGEMS_GEMDEPS'] = "-"
1768
+ ENV["GEM_PATH"] = path
1707
1769
 
1708
- Dir.mkdir "sub1"
1770
+ with_rubygems_gemdeps("-") do
1771
+ Dir.mkdir "sub1"
1709
1772
 
1710
- path = File.join @tempdir, "gem.deps.rb"
1711
- cmd = [Gem.ruby.dup.tap(&Gem::UNTAINT), "-Csub1", "-I#{LIB_PATH.tap(&Gem::UNTAINT)}",
1712
- "-I#{BUNDLER_LIB_PATH.tap(&Gem::UNTAINT)}", "-rrubygems"]
1713
- cmd << "-eputs Gem.loaded_specs.values.map(&:full_name).sort"
1773
+ new_PATH = [File.join(path, "bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
1774
+ new_RUBYOPT = "-I#{rubygems_path} -I#{BUNDLER_LIB_PATH}"
1714
1775
 
1715
- File.open path, "w" do |f|
1716
- f.puts "gem 'a'"
1717
- end
1718
- out0 = IO.popen(cmd, &:read).split(/\n/)
1776
+ path = File.join @tempdir, "gem.deps.rb"
1719
1777
 
1720
- File.open path, "a" do |f|
1721
- f.puts "gem 'b'"
1722
- f.puts "gem 'c'"
1723
- end
1724
- out = IO.popen(cmd, &:read).split(/\n/)
1778
+ File.open path, "w" do |f|
1779
+ f.puts "gem 'a'"
1780
+ end
1781
+ out0 = with_path_and_rubyopt(new_PATH, new_RUBYOPT) do
1782
+ IO.popen("foo", :chdir => "sub1", &:read).split(/\n/)
1783
+ end
1784
+
1785
+ File.open path, "a" do |f|
1786
+ f.puts "gem 'b'"
1787
+ f.puts "gem 'c'"
1788
+ end
1789
+ out = with_path_and_rubyopt(new_PATH, new_RUBYOPT) do
1790
+ IO.popen("foo", :chdir => "sub1", &:read).split(/\n/)
1791
+ end
1725
1792
 
1726
- Dir.rmdir "sub1"
1793
+ Dir.rmdir "sub1"
1727
1794
 
1728
- assert_equal ["b-1", "c-1"], out - out0
1795
+ assert_equal ["b-1", "c-1"], out - out0
1796
+ end
1729
1797
  end
1730
1798
 
1731
1799
  def test_register_default_spec
@@ -1769,14 +1837,14 @@ class TestGem < Gem::TestCase
1769
1837
  end
1770
1838
 
1771
1839
  def test_use_gemdeps
1772
- gem_deps_file = 'gem.deps.rb'.tap(&Gem::UNTAINT)
1773
- spec = util_spec 'a', 1
1840
+ gem_deps_file = "gem.deps.rb".tap(&Gem::UNTAINT)
1841
+ spec = util_spec "a", 1
1774
1842
  install_specs spec
1775
1843
 
1776
- spec = Gem::Specification.find { |s| s == spec }
1844
+ spec = Gem::Specification.find {|s| s == spec }
1777
1845
  refute spec.activated?
1778
1846
 
1779
- File.open gem_deps_file, 'w' do |io|
1847
+ File.open gem_deps_file, "w" do |io|
1780
1848
  io.write 'gem "a"'
1781
1849
  end
1782
1850
 
@@ -1784,146 +1852,126 @@ class TestGem < Gem::TestCase
1784
1852
 
1785
1853
  Gem.use_gemdeps gem_deps_file
1786
1854
 
1787
- assert_equal add_bundler_full_name(%W(a-1)), loaded_spec_names
1855
+ assert_equal add_bundler_full_name(%W[a-1]), loaded_spec_names
1788
1856
  refute_nil Gem.gemdeps
1789
1857
  end
1790
1858
 
1791
1859
  def test_use_gemdeps_ENV
1792
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
1793
-
1794
- spec = util_spec 'a', 1
1860
+ with_rubygems_gemdeps(nil) do
1861
+ spec = util_spec "a", 1
1795
1862
 
1796
- refute spec.activated?
1863
+ refute spec.activated?
1797
1864
 
1798
- File.open 'gem.deps.rb', 'w' do |io|
1799
- io.write 'gem "a"'
1800
- end
1865
+ File.open "gem.deps.rb", "w" do |io|
1866
+ io.write 'gem "a"'
1867
+ end
1801
1868
 
1802
- Gem.use_gemdeps
1869
+ Gem.use_gemdeps
1803
1870
 
1804
- refute spec.activated?
1805
- ensure
1806
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1871
+ refute spec.activated?
1872
+ end
1807
1873
  end
1808
1874
 
1809
1875
  def test_use_gemdeps_argument_missing
1810
- e = assert_raises ArgumentError do
1811
- Gem.use_gemdeps 'gem.deps.rb'
1876
+ e = assert_raise ArgumentError do
1877
+ Gem.use_gemdeps "gem.deps.rb"
1812
1878
  end
1813
1879
 
1814
- assert_equal 'Unable to find gem dependencies file at gem.deps.rb',
1880
+ assert_equal "Unable to find gem dependencies file at gem.deps.rb",
1815
1881
  e.message
1816
1882
  end
1817
1883
 
1818
1884
  def test_use_gemdeps_argument_missing_match_ENV
1819
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] =
1820
- ENV['RUBYGEMS_GEMDEPS'], 'gem.deps.rb'
1885
+ with_rubygems_gemdeps("gem.deps.rb") do
1886
+ e = assert_raise ArgumentError do
1887
+ Gem.use_gemdeps "gem.deps.rb"
1888
+ end
1821
1889
 
1822
- e = assert_raises ArgumentError do
1823
- Gem.use_gemdeps 'gem.deps.rb'
1890
+ assert_equal "Unable to find gem dependencies file at gem.deps.rb",
1891
+ e.message
1824
1892
  end
1825
-
1826
- assert_equal 'Unable to find gem dependencies file at gem.deps.rb',
1827
- e.message
1828
- ensure
1829
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1830
1893
  end
1831
1894
 
1832
1895
  def test_use_gemdeps_automatic
1833
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
1896
+ with_rubygems_gemdeps("-") do
1897
+ spec = util_spec "a", 1
1898
+ install_specs spec
1899
+ spec = Gem::Specification.find {|s| s == spec }
1834
1900
 
1835
- spec = util_spec 'a', 1
1836
- install_specs spec
1837
- spec = Gem::Specification.find { |s| s == spec }
1838
-
1839
- refute spec.activated?
1901
+ refute spec.activated?
1840
1902
 
1841
- File.open 'Gemfile', 'w' do |io|
1842
- io.write 'gem "a"'
1843
- end
1903
+ File.open "Gemfile", "w" do |io|
1904
+ io.write 'gem "a"'
1905
+ end
1844
1906
 
1845
- Gem.use_gemdeps
1907
+ Gem.use_gemdeps
1846
1908
 
1847
- assert_equal add_bundler_full_name(%W(a-1)), loaded_spec_names
1848
- ensure
1849
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1909
+ assert_equal add_bundler_full_name(%W[a-1]), loaded_spec_names
1910
+ end
1850
1911
  end
1851
1912
 
1852
1913
  def test_use_gemdeps_automatic_missing
1853
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
1914
+ with_rubygems_gemdeps("-") do
1915
+ Gem.use_gemdeps
1854
1916
 
1855
- Gem.use_gemdeps
1856
-
1857
- assert true # count
1858
- ensure
1859
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1917
+ assert true # count
1918
+ end
1860
1919
  end
1861
1920
 
1862
1921
  def test_use_gemdeps_disabled
1863
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], ''
1864
-
1865
- spec = util_spec 'a', 1
1922
+ with_rubygems_gemdeps("") do
1923
+ spec = util_spec "a", 1
1866
1924
 
1867
- refute spec.activated?
1925
+ refute spec.activated?
1868
1926
 
1869
- File.open 'gem.deps.rb', 'w' do |io|
1870
- io.write 'gem "a"'
1871
- end
1927
+ File.open "gem.deps.rb", "w" do |io|
1928
+ io.write 'gem "a"'
1929
+ end
1872
1930
 
1873
- Gem.use_gemdeps
1931
+ Gem.use_gemdeps
1874
1932
 
1875
- refute spec.activated?
1876
- ensure
1877
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1933
+ refute spec.activated?
1934
+ end
1878
1935
  end
1879
1936
 
1880
1937
  def test_use_gemdeps_missing_gem
1881
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
1882
-
1883
- File.open 'x', 'w' do |io|
1884
- io.write 'gem "a"'
1885
- end
1886
-
1887
- platform = Bundler::GemHelpers.generic_local_platform
1888
- if platform == Gem::Platform::RUBY
1889
- platform = ''
1890
- else
1891
- platform = " #{platform}"
1892
- end
1938
+ with_rubygems_gemdeps("x") do
1939
+ File.open "x", "w" do |io|
1940
+ io.write 'gem "a"'
1941
+ end
1893
1942
 
1894
- expected = <<-EXPECTED
1895
- Could not find gem 'a#{platform}' in any of the gem sources listed in your Gemfile.
1896
- You may need to `gem install -g` to install missing gems
1943
+ expected = <<-EXPECTED
1944
+ Could not find gem 'a' in locally installed gems.
1945
+ You may need to `bundle install` to install missing gems
1897
1946
 
1898
- EXPECTED
1947
+ EXPECTED
1899
1948
 
1900
- Gem::Deprecate.skip_during do
1901
- assert_output nil, expected do
1902
- Gem.use_gemdeps
1949
+ Gem::Deprecate.skip_during do
1950
+ actual_stdout, actual_stderr = capture_output do
1951
+ Gem.use_gemdeps
1952
+ end
1953
+ assert_empty actual_stdout
1954
+ assert_equal(expected, actual_stderr)
1903
1955
  end
1904
1956
  end
1905
- ensure
1906
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1907
1957
  end
1908
1958
 
1909
1959
  def test_use_gemdeps_specific
1910
- rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
1960
+ with_rubygems_gemdeps("x") do
1961
+ spec = util_spec "a", 1
1962
+ install_specs spec
1911
1963
 
1912
- spec = util_spec 'a', 1
1913
- install_specs spec
1914
-
1915
- spec = Gem::Specification.find { |s| s == spec }
1916
- refute spec.activated?
1964
+ spec = Gem::Specification.find {|s| s == spec }
1965
+ refute spec.activated?
1917
1966
 
1918
- File.open 'x', 'w' do |io|
1919
- io.write 'gem "a"'
1920
- end
1967
+ File.open "x", "w" do |io|
1968
+ io.write 'gem "a"'
1969
+ end
1921
1970
 
1922
- Gem.use_gemdeps
1971
+ Gem.use_gemdeps
1923
1972
 
1924
- assert_equal add_bundler_full_name(%W(a-1)), loaded_spec_names
1925
- ensure
1926
- ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1973
+ assert_equal add_bundler_full_name(%W[a-1]), loaded_spec_names
1974
+ end
1927
1975
  end
1928
1976
 
1929
1977
  def test_operating_system_defaults
@@ -1943,8 +1991,8 @@ You may need to `gem install -g` to install missing gems
1943
1991
  # Ensure that `Gem.source_date_epoch` is consistent even if
1944
1992
  # $SOURCE_DATE_EPOCH has not been set.
1945
1993
  def test_default_source_date_epoch_doesnt_change
1946
- old_epoch = ENV['SOURCE_DATE_EPOCH']
1947
- ENV['SOURCE_DATE_EPOCH'] = nil
1994
+ old_epoch = ENV["SOURCE_DATE_EPOCH"]
1995
+ ENV["SOURCE_DATE_EPOCH"] = nil
1948
1996
 
1949
1997
  # Unfortunately, there is no real way to test this aside from waiting
1950
1998
  # enough for `Time.now.to_i` to change -- which is a whole second.
@@ -1955,31 +2003,46 @@ You may need to `gem install -g` to install missing gems
1955
2003
  b = Gem.source_date_epoch
1956
2004
  assert_equal a, b
1957
2005
  ensure
1958
- ENV['SOURCE_DATE_EPOCH'] = old_epoch
2006
+ ENV["SOURCE_DATE_EPOCH"] = old_epoch
1959
2007
  end
1960
2008
 
2009
+ private
2010
+
1961
2011
  def ruby_install_name(name)
1962
2012
  with_clean_path_to_ruby do
1963
- orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
1964
- RbConfig::CONFIG['ruby_install_name'] = name
2013
+ orig_RUBY_INSTALL_NAME = RbConfig::CONFIG["ruby_install_name"]
2014
+ RbConfig::CONFIG["ruby_install_name"] = name
1965
2015
 
1966
2016
  begin
1967
2017
  yield
1968
2018
  ensure
1969
2019
  if orig_RUBY_INSTALL_NAME
1970
- RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
2020
+ RbConfig::CONFIG["ruby_install_name"] = orig_RUBY_INSTALL_NAME
1971
2021
  else
1972
- RbConfig::CONFIG.delete 'ruby_install_name'
2022
+ RbConfig::CONFIG.delete "ruby_install_name"
1973
2023
  end
1974
2024
  end
1975
2025
  end
1976
2026
  end
1977
2027
 
1978
- def with_bindir_and_exeext(bindir, exeext)
1979
- bindir(bindir) do
1980
- exeext(exeext) do
1981
- yield
1982
- end
2028
+ def with_rb_config_ruby(path)
2029
+ rb_config_singleton_class = class << RbConfig; self; end
2030
+ orig_path = RbConfig.ruby
2031
+
2032
+ redefine_method(rb_config_singleton_class, :ruby, path)
2033
+
2034
+ yield
2035
+ ensure
2036
+ redefine_method(rb_config_singleton_class, :ruby, orig_path)
2037
+ end
2038
+
2039
+ def redefine_method(base, method, new_result)
2040
+ if RUBY_VERSION >= "2.5"
2041
+ base.alias_method(method, method)
2042
+ base.define_method(method) { new_result }
2043
+ else
2044
+ base.send(:alias_method, method, method)
2045
+ base.send(:define_method, method) { new_result }
1983
2046
  end
1984
2047
  end
1985
2048
 
@@ -1992,7 +2055,7 @@ You may need to `gem install -g` to install missing gems
1992
2055
  refute_includes $LOAD_PATH, test_plugin_path
1993
2056
  $LOAD_PATH.unshift test_plugin_path
1994
2057
 
1995
- capture_io do
2058
+ capture_output do
1996
2059
  yield
1997
2060
  end
1998
2061
  ensure
@@ -2011,12 +2074,12 @@ You may need to `gem install -g` to install missing gems
2011
2074
  end
2012
2075
 
2013
2076
  def util_exec_gem
2014
- spec, _ = util_spec 'a', '4' do |s|
2015
- s.executables = ['exec', 'abin']
2077
+ spec, _ = util_spec "a", "4" do |s|
2078
+ s.executables = ["exec", "abin"]
2016
2079
  end
2017
2080
 
2018
- @exec_path = File.join spec.full_gem_path, spec.bindir, 'exec'
2019
- @abin_path = File.join spec.full_gem_path, spec.bindir, 'abin'
2081
+ @exec_path = File.join spec.full_gem_path, spec.bindir, "exec"
2082
+ @abin_path = File.join spec.full_gem_path, spec.bindir, "abin"
2020
2083
  spec
2021
2084
  end
2022
2085
 
@@ -2029,4 +2092,21 @@ You may need to `gem install -g` to install missing gems
2029
2092
  File.join Gem.dir, "cache"
2030
2093
  end
2031
2094
 
2095
+ def with_path_and_rubyopt(path_value, rubyopt_value)
2096
+ path, ENV["PATH"] = ENV["PATH"], path_value
2097
+ rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], rubyopt_value
2098
+
2099
+ yield
2100
+ ensure
2101
+ ENV["PATH"] = path
2102
+ ENV["RUBYOPT"] = rubyopt
2103
+ end
2104
+
2105
+ def with_rubygems_gemdeps(value)
2106
+ rubygems_gemdeps, ENV["RUBYGEMS_GEMDEPS"] = ENV["RUBYGEMS_GEMDEPS"], value
2107
+
2108
+ yield
2109
+ ensure
2110
+ ENV["RUBYGEMS_GEMDEPS"] = rubygems_gemdeps
2111
+ end
2032
2112
  end