rubygems-update 3.1.0.pre3 → 3.1.4

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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +43 -0
  6. data/History.txt +97 -2
  7. data/Manifest.txt +21 -3
  8. data/README.md +4 -4
  9. data/Rakefile +11 -10
  10. data/bin/update_rubygems +1 -1
  11. data/bundler/CHANGELOG.md +56 -3
  12. data/bundler/lib/bundler.rb +0 -1
  13. data/bundler/lib/bundler/build_metadata.rb +2 -0
  14. data/bundler/lib/bundler/cli.rb +1 -1
  15. data/bundler/lib/bundler/cli/config.rb +1 -1
  16. data/bundler/lib/bundler/cli/install.rb +3 -2
  17. data/bundler/lib/bundler/cli/update.rb +1 -1
  18. data/bundler/lib/bundler/feature_flag.rb +1 -1
  19. data/bundler/lib/bundler/fetcher.rb +2 -2
  20. data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
  21. data/bundler/lib/bundler/fetcher/index.rb +1 -1
  22. data/bundler/lib/bundler/friendly_errors.rb +1 -1
  23. data/bundler/lib/bundler/gem_helper.rb +13 -12
  24. data/bundler/lib/bundler/inline.rb +36 -31
  25. data/bundler/lib/bundler/lazy_specification.rb +0 -1
  26. data/bundler/lib/bundler/mirror.rb +3 -3
  27. data/bundler/lib/bundler/plugin/api/source.rb +2 -4
  28. data/bundler/lib/bundler/remote_specification.rb +0 -2
  29. data/bundler/lib/bundler/rubygems_integration.rb +15 -13
  30. data/bundler/lib/bundler/settings.rb +7 -4
  31. data/bundler/lib/bundler/setup.rb +5 -0
  32. data/bundler/lib/bundler/source/git.rb +5 -5
  33. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -2
  34. data/bundler/lib/bundler/source/rubygems.rb +3 -3
  35. data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
  36. data/bundler/lib/bundler/uri_credentials_filter.rb +7 -3
  37. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +3 -3
  38. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +26 -48
  39. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +7 -0
  40. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +10 -6
  41. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +29 -19
  42. data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  43. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +1 -1
  44. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +13 -2
  45. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +8 -9
  46. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
  47. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +2 -2
  48. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +17 -1
  49. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  50. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  51. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  52. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  53. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  54. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  55. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  56. data/bundler/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  57. data/bundler/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  58. data/bundler/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  59. data/bundler/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  60. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  61. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  62. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  63. data/bundler/lib/bundler/vendored_uri.rb +4 -0
  64. data/bundler/lib/bundler/version.rb +1 -1
  65. data/bundler/man/bundle-add.1 +1 -1
  66. data/bundler/man/bundle-add.1.txt +1 -1
  67. data/bundler/man/bundle-binstubs.1 +1 -1
  68. data/bundler/man/bundle-binstubs.1.txt +1 -1
  69. data/bundler/man/bundle-cache.1 +1 -1
  70. data/bundler/man/bundle-cache.1.txt +1 -1
  71. data/bundler/man/bundle-check.1 +1 -1
  72. data/bundler/man/bundle-check.1.txt +1 -1
  73. data/bundler/man/bundle-clean.1 +1 -1
  74. data/bundler/man/bundle-clean.1.txt +1 -1
  75. data/bundler/man/bundle-config.1 +1 -1
  76. data/bundler/man/bundle-config.1.txt +1 -1
  77. data/bundler/man/bundle-doctor.1 +1 -1
  78. data/bundler/man/bundle-doctor.1.txt +1 -1
  79. data/bundler/man/bundle-exec.1 +1 -1
  80. data/bundler/man/bundle-exec.1.txt +1 -1
  81. data/bundler/man/bundle-gem.1 +1 -1
  82. data/bundler/man/bundle-gem.1.txt +1 -1
  83. data/bundler/man/bundle-info.1 +1 -1
  84. data/bundler/man/bundle-info.1.txt +1 -1
  85. data/bundler/man/bundle-init.1 +1 -1
  86. data/bundler/man/bundle-init.1.txt +1 -1
  87. data/bundler/man/bundle-inject.1 +1 -1
  88. data/bundler/man/bundle-inject.1.txt +1 -1
  89. data/bundler/man/bundle-install.1 +1 -1
  90. data/bundler/man/bundle-install.1.txt +1 -1
  91. data/bundler/man/bundle-list.1 +1 -1
  92. data/bundler/man/bundle-list.1.txt +1 -1
  93. data/bundler/man/bundle-lock.1 +1 -1
  94. data/bundler/man/bundle-lock.1.txt +1 -1
  95. data/bundler/man/bundle-open.1 +1 -1
  96. data/bundler/man/bundle-open.1.txt +1 -1
  97. data/bundler/man/bundle-outdated.1 +1 -1
  98. data/bundler/man/bundle-outdated.1.txt +1 -1
  99. data/bundler/man/bundle-platform.1 +1 -1
  100. data/bundler/man/bundle-platform.1.txt +1 -1
  101. data/bundler/man/bundle-pristine.1 +1 -1
  102. data/bundler/man/bundle-pristine.1.txt +1 -1
  103. data/bundler/man/bundle-remove.1 +1 -1
  104. data/bundler/man/bundle-remove.1.txt +1 -1
  105. data/bundler/man/bundle-show.1 +1 -1
  106. data/bundler/man/bundle-show.1.txt +1 -1
  107. data/bundler/man/bundle-update.1 +1 -1
  108. data/bundler/man/bundle-update.1.txt +1 -1
  109. data/bundler/man/bundle-viz.1 +1 -1
  110. data/bundler/man/bundle-viz.1.txt +1 -1
  111. data/bundler/man/bundle.1 +1 -1
  112. data/bundler/man/bundle.1.txt +1 -1
  113. data/bundler/man/gemfile.5 +1 -1
  114. data/bundler/man/gemfile.5.txt +1 -1
  115. data/lib/rubygems.rb +64 -47
  116. data/lib/rubygems/basic_specification.rb +1 -1
  117. data/lib/rubygems/command.rb +29 -7
  118. data/lib/rubygems/commands/generate_index_command.rb +3 -0
  119. data/lib/rubygems/commands/help_command.rb +1 -1
  120. data/lib/rubygems/commands/setup_command.rb +30 -15
  121. data/lib/rubygems/commands/sources_command.rb +17 -3
  122. data/lib/rubygems/commands/uninstall_command.rb +1 -1
  123. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  124. data/lib/rubygems/core_ext/kernel_warn.rb +8 -4
  125. data/lib/rubygems/ext/builder.rb +4 -2
  126. data/lib/rubygems/remote_fetcher.rb +20 -31
  127. data/lib/rubygems/request.rb +2 -0
  128. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  129. data/lib/rubygems/resolver/api_set.rb +1 -1
  130. data/lib/rubygems/resolver/api_specification.rb +1 -1
  131. data/lib/rubygems/server.rb +1 -1
  132. data/lib/rubygems/source.rb +7 -1
  133. data/lib/rubygems/source_list.rb +2 -0
  134. data/lib/rubygems/specification.rb +12 -8
  135. data/lib/rubygems/specification_policy.rb +53 -30
  136. data/lib/rubygems/test_case.rb +60 -0
  137. data/lib/rubygems/uri_formatter.rb +0 -1
  138. data/lib/rubygems/uri_parser.rb +36 -0
  139. data/lib/rubygems/uri_parsing.rb +23 -0
  140. data/lib/rubygems/util.rb +7 -1
  141. data/lib/rubygems/version.rb +1 -1
  142. data/rubygems-update.gemspec +1 -8
  143. data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +14 -0
  144. data/test/rubygems/test_gem.rb +90 -46
  145. data/test/rubygems/test_gem_command.rb +38 -9
  146. data/test/rubygems/test_gem_commands_build_command.rb +18 -1
  147. data/test/rubygems/test_gem_commands_generate_index_command.rb +37 -1
  148. data/test/rubygems/test_gem_commands_help_command.rb +1 -6
  149. data/test/rubygems/test_gem_commands_server_command.rb +6 -2
  150. data/test/rubygems/test_gem_commands_setup_command.rb +56 -10
  151. data/test/rubygems/test_gem_commands_sources_command.rb +113 -1
  152. data/test/rubygems/test_gem_commands_uninstall_command.rb +1 -0
  153. data/test/rubygems/test_gem_gem_runner.rb +3 -1
  154. data/test/rubygems/test_gem_indexer.rb +1 -1
  155. data/test/rubygems/test_gem_installer.rb +10 -23
  156. data/test/rubygems/test_gem_package.rb +3 -8
  157. data/test/rubygems/test_gem_package_tar_writer.rb +5 -0
  158. data/test/rubygems/test_gem_request_set.rb +52 -0
  159. data/test/rubygems/test_gem_source.rb +14 -0
  160. data/test/rubygems/test_gem_specification.rb +74 -54
  161. data/test/rubygems/test_gem_stub_specification.rb +0 -1
  162. data/test/rubygems/test_project_sanity.rb +0 -43
  163. data/test/rubygems/test_remote_fetch_error.rb +1 -1
  164. data/test/rubygems/test_require.rb +41 -42
  165. data/util/bisect +0 -21
  166. data/util/ci.sh +1 -1
  167. data/util/update_changelog.rb +7 -10
  168. metadata +27 -93
  169. data/bundler/lib/bundler/gem_remote_fetcher.rb +0 -43
  170. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
  171. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
@@ -122,6 +122,23 @@ class TestGemCommandsBuildCommand < Gem::TestCase
122
122
  util_test_build_gem @gem
123
123
  end
124
124
 
125
+ def test_execute_rubyforge_project_warning
126
+ rubyforge_gemspec = File.join SPECIFICATIONS, "rubyforge-0.0.1.gemspec"
127
+
128
+ @cmd.options[:args] = [rubyforge_gemspec]
129
+
130
+ use_ui @ui do
131
+ Dir.chdir @tempdir do
132
+ @cmd.execute
133
+ end
134
+ end
135
+
136
+ error = @ui.error.split("\n")
137
+ assert_equal "WARNING: rubyforge_project= is deprecated and ignored. Please remove this from your gemspec to ensure that your gem continues to build in the future.", error.shift
138
+ assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
139
+ assert_equal [], error
140
+ end
141
+
125
142
  def test_execute_strict_with_warnings
126
143
  bad_gem = util_spec 'some_bad_gem' do |s|
127
144
  s.files = ['README.md']
@@ -147,7 +164,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
147
164
  error = @ui.error.split "\n"
148
165
  assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
149
166
  assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.", error.shift
150
- assert_equal "WARNING: See http://guides.rubygems.org/specification-reference/ for help", error.shift
167
+ assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
151
168
  assert_equal [], error
152
169
 
153
170
  gem_file = File.join @tempdir, File.basename(@gem.cache_file)
@@ -3,6 +3,10 @@ require 'rubygems/test_case'
3
3
  require 'rubygems/indexer'
4
4
  require 'rubygems/commands/generate_index_command'
5
5
 
6
+ unless defined?(Builder::XChar)
7
+ warn "generate_index tests are being skipped. Install builder gem."
8
+ end
9
+
6
10
  class TestGemCommandsGenerateIndexCommand < Gem::TestCase
7
11
 
8
12
  def setup
@@ -22,6 +26,18 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
22
26
  assert File.exist?(specs), specs
23
27
  end
24
28
 
29
+ def test_execute_no_modern
30
+ @cmd.options[:modern] = false
31
+
32
+ use_ui @ui do
33
+ @cmd.execute
34
+ end
35
+
36
+ specs = File.join @gemhome, "specs.4.8.gz"
37
+
38
+ assert File.exist?(specs), specs
39
+ end
40
+
25
41
  def test_handle_options_directory
26
42
  return if win_platform?
27
43
  refute_equal '/nonexistent', @cmd.options[:directory]
@@ -47,4 +63,24 @@ class TestGemCommandsGenerateIndexCommand < Gem::TestCase
47
63
  assert @cmd.options[:update]
48
64
  end
49
65
 
50
- end if ''.respond_to? :to_xs
66
+ def test_handle_options_modern
67
+ use_ui @ui do
68
+ @cmd.handle_options %w[--modern]
69
+ end
70
+
71
+ assert_equal \
72
+ "WARNING: The \"--modern\" option has been deprecated and will be removed in Rubygems 4.0. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated, so this option is not needed.\n",
73
+ @ui.error
74
+ end
75
+
76
+ def test_handle_options_no_modern
77
+ use_ui @ui do
78
+ @cmd.handle_options %w[--no-modern]
79
+ end
80
+
81
+ assert_equal \
82
+ "WARNING: The \"--no-modern\" option has been deprecated and will be removed in Rubygems 4.0. The `--no-modern` option is currently ignored. Modern indexes (specs, latest_specs, and prerelease_specs) are always generated.\n",
83
+ @ui.error
84
+ end
85
+
86
+ end if defined?(Builder::XChar)
@@ -4,20 +4,15 @@ require "rubygems/test_case"
4
4
  require "rubygems/commands/help_command"
5
5
  require "rubygems/package"
6
6
  require "rubygems/command_manager"
7
- require File.expand_path('../rubygems_plugin', __FILE__)
8
7
 
9
8
  class TestGemCommandsHelpCommand < Gem::TestCase
10
9
 
11
- # previously this was calc'd in setup, but 1.8.7 had
12
- # intermittent failures, but no issues with above require
13
- PLUGIN = File.expand_path('../rubygems_plugin.rb', __FILE__)
14
-
15
10
  def setup
16
11
  super
17
12
 
18
13
  @cmd = Gem::Commands::HelpCommand.new
19
14
 
20
- load PLUGIN unless Gem::Commands.const_defined? :InterruptCommand
15
+ load File.expand_path('../rubygems_plugin.rb', __FILE__) unless Gem::Commands.const_defined? :InterruptCommand
21
16
  end
22
17
 
23
18
  def test_gem_help_bad
@@ -38,8 +38,12 @@ class TestGemCommandsServerCommand < Gem::TestCase
38
38
  @cmd.send :handle_options, %w[-p 65535]
39
39
  assert_equal 65535, @cmd.options[:port]
40
40
 
41
- @cmd.send :handle_options, %w[-p discard]
42
- assert_equal 9, @cmd.options[:port]
41
+ begin
42
+ @cmd.send :handle_options, %w[-p discard]
43
+ assert_equal 9, @cmd.options[:port]
44
+ rescue OptionParser::InvalidArgument
45
+ # for container environment on GitHub Actions
46
+ end
43
47
 
44
48
  e = assert_raises OptionParser::InvalidArgument do
45
49
  @cmd.send :handle_options, %w[-p nonexistent]
@@ -123,6 +123,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
123
123
  assert_equal "I changed it!\n", File.read(gem_bin_path)
124
124
  end
125
125
 
126
+ def test_execute_informs_about_installed_executables
127
+ use_ui @ui do
128
+ @cmd.execute
129
+ end
130
+
131
+ out = @ui.output.split "\n"
132
+
133
+ exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
134
+ assert_equal "\t#{default_gem_bin_path}", out.shift
135
+ assert_equal "\t#{default_bundle_bin_path}", out.shift
136
+ end
137
+
126
138
  def test_env_shebang_flag
127
139
  gem_bin_path = gem_install 'a'
128
140
  write_file gem_bin_path do |io|
@@ -133,10 +145,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
133
145
  @cmd.options[:env_shebang] = true
134
146
  @cmd.execute
135
147
 
136
- gem_exec = sprintf Gem.default_exec_format, 'gem'
137
- default_gem_bin_path = File.join @install_dir, 'bin', gem_exec
138
- bundle_exec = sprintf Gem.default_exec_format, 'bundle'
139
- default_bundle_bin_path = File.join @install_dir, 'bin', bundle_exec
140
148
  ruby_exec = sprintf Gem.default_exec_format, 'ruby'
141
149
 
142
150
  if Gem.win_platform?
@@ -212,10 +220,41 @@ class TestGemCommandsSetupCommand < Gem::TestCase
212
220
 
213
221
  # TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
214
222
 
215
- # expect to not remove bundler-* direcotyr.
223
+ # expect to not remove bundler-* directory.
216
224
  assert_path_exists 'default/gems/bundler-audit-1.0.0'
217
225
  end
218
226
 
227
+ def test_install_default_bundler_gem_with_force_flag
228
+ @cmd.extend FileUtils
229
+
230
+ bin_dir = File.join(@gemhome, 'bin')
231
+ bundle_bin = File.join(bin_dir, 'bundle')
232
+
233
+ write_file bundle_bin do |f|
234
+ f.puts '#!/usr/bin/ruby'
235
+ f.puts ''
236
+ f.puts 'echo "hello"'
237
+ end
238
+
239
+ bindir(bin_dir) do
240
+ @cmd.options[:force] = true
241
+
242
+ @cmd.install_default_bundler_gem bin_dir
243
+
244
+ bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
245
+ default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
246
+ spec = Gem::Specification.load(default_spec_path)
247
+
248
+ spec.executables.each do |e|
249
+ if Gem.win_platform?
250
+ assert_path_exists File.join(bin_dir, "#{e}.bat")
251
+ end
252
+
253
+ assert_path_exists File.join bin_dir, Gem.default_exec_format % e
254
+ end
255
+ end
256
+ end
257
+
219
258
  def test_remove_old_lib_files
220
259
  lib = File.join @install_dir, 'lib'
221
260
  lib_rubygems = File.join lib, 'rubygems'
@@ -308,11 +347,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
308
347
  * Fixed release note display for LANG=C when installing rubygems
309
348
  * π is tasty
310
349
 
311
- === 2.0.2 / 2013-03-06
312
-
313
- * Bug fixes:
314
- * Other bugs fixed
315
-
316
350
  EXPECTED
317
351
 
318
352
  output = @ui.output
@@ -323,4 +357,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
323
357
  @ui.outs.set_encoding @default_external if @default_external
324
358
  end
325
359
 
360
+ private
361
+
362
+ def default_gem_bin_path
363
+ gem_exec = sprintf Gem.default_exec_format, 'gem'
364
+ File.join @install_dir, 'bin', gem_exec
365
+ end
366
+
367
+ def default_bundle_bin_path
368
+ bundle_exec = sprintf Gem.default_exec_format, 'bundle'
369
+ File.join @install_dir, 'bin', bundle_exec
370
+ end
371
+
326
372
  end unless Gem.java_platform?
@@ -74,6 +74,80 @@ class TestGemCommandsSourcesCommand < Gem::TestCase
74
74
  assert_equal '', @ui.error
75
75
  end
76
76
 
77
+ def test_execute_add_allow_typo_squatting_source
78
+ rubygems_org = "https://rubyems.org"
79
+
80
+ spec_fetcher do |fetcher|
81
+ fetcher.spec("a", 1)
82
+ end
83
+
84
+ specs = Gem::Specification.map do |spec|
85
+ [spec.name, spec.version, spec.original_platform]
86
+ end
87
+
88
+ specs_dump_gz = StringIO.new
89
+ Zlib::GzipWriter.wrap(specs_dump_gz) do |io|
90
+ Marshal.dump(specs, io)
91
+ end
92
+
93
+ @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] = specs_dump_gz.string
94
+ @cmd.handle_options %W[--add #{rubygems_org}]
95
+ ui = Gem::MockGemUi.new("y")
96
+
97
+ use_ui ui do
98
+ @cmd.execute
99
+ end
100
+
101
+ expected = "https://rubyems.org is too similar to https://rubygems.org\n\nDo you want to add this source? [yn] https://rubyems.org added to sources\n"
102
+
103
+ assert_equal expected, ui.output
104
+
105
+ source = Gem::Source.new(rubygems_org)
106
+ assert Gem.sources.include?(source)
107
+
108
+ assert_empty ui.error
109
+ end
110
+
111
+ def test_execute_add_deny_typo_squatting_source
112
+ rubygems_org = "https://rubyems.org"
113
+
114
+ spec_fetcher do |fetcher|
115
+ fetcher.spec("a", 1)
116
+ end
117
+
118
+ specs = Gem::Specification.map do |spec|
119
+ [spec.name, spec.version, spec.original_platform]
120
+ end
121
+
122
+ specs_dump_gz = StringIO.new
123
+ Zlib::GzipWriter.wrap(specs_dump_gz) do |io|
124
+ Marshal.dump(specs, io)
125
+ end
126
+
127
+ @fetcher.data["#{rubygems_org}/specs.#{@marshal_version}.gz"] =
128
+ specs_dump_gz.string
129
+
130
+ @cmd.handle_options %W[--add #{rubygems_org}]
131
+
132
+ ui = Gem::MockGemUi.new("n")
133
+
134
+ use_ui ui do
135
+
136
+ assert_raises Gem::MockGemUi::TermError do
137
+ @cmd.execute
138
+ end
139
+ end
140
+
141
+ expected = "https://rubyems.org is too similar to https://rubygems.org\n\nDo you want to add this source? [yn] "
142
+
143
+ assert_equal expected, ui.output
144
+
145
+ source = Gem::Source.new(rubygems_org)
146
+ refute Gem.sources.include?(source)
147
+
148
+ assert_empty ui.error
149
+ end
150
+
77
151
  def test_execute_add_nonexistent_source
78
152
  spec_fetcher
79
153
 
@@ -173,7 +247,7 @@ source http://gems.example.com/ already present in the cache
173
247
  end
174
248
 
175
249
  def test_execute_add_http_rubygems_org
176
- http_rubygems_org = 'http://rubygems.org'
250
+ http_rubygems_org = 'http://rubygems.org/'
177
251
 
178
252
  spec_fetcher do |fetcher|
179
253
  fetcher.spec 'a', 1
@@ -210,6 +284,44 @@ source http://gems.example.com/ already present in the cache
210
284
  assert_empty @ui.error
211
285
  end
212
286
 
287
+ def test_execute_add_https_rubygems_org
288
+ https_rubygems_org = 'https://rubygems.org/'
289
+
290
+ spec_fetcher do |fetcher|
291
+ fetcher.spec 'a', 1
292
+ end
293
+
294
+ specs = Gem::Specification.map do |spec|
295
+ [spec.name, spec.version, spec.original_platform]
296
+ end
297
+
298
+ specs_dump_gz = StringIO.new
299
+ Zlib::GzipWriter.wrap specs_dump_gz do |io|
300
+ Marshal.dump specs, io
301
+ end
302
+
303
+ @fetcher.data["#{https_rubygems_org}/specs.#{@marshal_version}.gz"] =
304
+ specs_dump_gz.string
305
+
306
+ @cmd.handle_options %W[--add #{https_rubygems_org}]
307
+
308
+ ui = Gem::MockGemUi.new "n"
309
+
310
+ use_ui ui do
311
+ assert_raises Gem::MockGemUi::TermError do
312
+ @cmd.execute
313
+ end
314
+ end
315
+
316
+ assert_equal [@gem_repo], Gem.sources
317
+
318
+ expected = <<-EXPECTED
319
+ EXPECTED
320
+
321
+ assert_equal expected, @ui.output
322
+ assert_empty @ui.error
323
+ end
324
+
213
325
  def test_execute_add_bad_uri
214
326
  @cmd.handle_options %w[--add beta-gems.example.com]
215
327
 
@@ -361,6 +361,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
361
361
  end
362
362
 
363
363
  assert_equal %w[default-1], Gem::Specification.all_names.sort
364
+ assert_equal "INFO: Uninstalled all gems in #{@gemhome}", @ui.output.split("\n").last
364
365
  end
365
366
 
366
367
  def test_execute_outside_gem_home
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rubygems/test_case'
3
- require 'rubygems/gem_runner'
4
3
 
5
4
  class TestGemGemRunner < Gem::TestCase
6
5
 
7
6
  def setup
8
7
  super
9
8
 
9
+ require 'rubygems/command'
10
10
  @orig_args = Gem::Command.build_args
11
+
12
+ require 'rubygems/gem_runner'
11
13
  @runner = Gem::GemRunner.new
12
14
  end
13
15
 
@@ -3,7 +3,7 @@ require 'rubygems/test_case'
3
3
  require 'rubygems/indexer'
4
4
 
5
5
  unless defined?(Builder::XChar)
6
- warn "Gem::Indexer tests are being skipped. Install builder gem." if $VERBOSE
6
+ warn "Gem::Indexer tests are being skipped. Install builder gem."
7
7
  end
8
8
 
9
9
  class TestGemIndexer < Gem::TestCase
@@ -104,32 +104,19 @@ end
104
104
  def test_check_executable_overwrite_default_bin_dir
105
105
  installer = setup_base_installer
106
106
 
107
- if defined?(RUBY_FRAMEWORK_VERSION)
108
- orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
109
- Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
110
- end
111
- orig_bindir = RbConfig::CONFIG['bindir']
112
- RbConfig::CONFIG['bindir'] = Gem.bindir
107
+ bindir(Gem.bindir) do
108
+ util_conflict_executable false
113
109
 
114
- util_conflict_executable false
110
+ ui = Gem::MockGemUi.new "n\n"
111
+ use_ui ui do
112
+ e = assert_raises Gem::InstallError do
113
+ installer.generate_bin
114
+ end
115
115
 
116
- ui = Gem::MockGemUi.new "n\n"
117
- use_ui ui do
118
- e = assert_raises Gem::InstallError do
119
- installer.generate_bin
116
+ conflicted = File.join @gemhome, 'bin', 'executable'
117
+ assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
118
+ e.message
120
119
  end
121
-
122
- conflicted = File.join @gemhome, 'bin', 'executable'
123
- assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
124
- e.message
125
- end
126
- ensure
127
- Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
128
- orig_RUBY_FRAMEWORK_VERSION
129
- if orig_bindir
130
- RbConfig::CONFIG['bindir'] = orig_bindir
131
- else
132
- RbConfig::CONFIG.delete 'bindir'
133
120
  end
134
121
  end
135
122
 
@@ -106,7 +106,7 @@ class TestGemPackage < Gem::Package::TarTestCase
106
106
  assert_equal expected, YAML.load(checksums)
107
107
  end
108
108
 
109
- def test_build_time_source_date_epoch
109
+ def test_build_time_uses_source_date_epoch
110
110
  epoch = ENV["SOURCE_DATE_EPOCH"]
111
111
  ENV["SOURCE_DATE_EPOCH"] = "123456789"
112
112
 
@@ -124,12 +124,10 @@ class TestGemPackage < Gem::Package::TarTestCase
124
124
  ENV["SOURCE_DATE_EPOCH"] = epoch
125
125
  end
126
126
 
127
- def test_build_time_source_date_epoch_automatically_set
127
+ def test_build_time_without_source_date_epoch
128
128
  epoch = ENV["SOURCE_DATE_EPOCH"]
129
129
  ENV["SOURCE_DATE_EPOCH"] = nil
130
130
 
131
- start_time = Time.now.utc.to_i
132
-
133
131
  spec = Gem::Specification.new 'build', '1'
134
132
  spec.summary = 'build'
135
133
  spec.authors = 'build'
@@ -138,14 +136,11 @@ class TestGemPackage < Gem::Package::TarTestCase
138
136
 
139
137
  package = Gem::Package.new spec.file_name
140
138
 
141
- end_time = Time.now.utc.to_i
142
-
143
139
  assert_kind_of Time, package.build_time
144
140
 
145
141
  build_time = package.build_time.to_i
146
142
 
147
- assert_operator(start_time, :<=, build_time)
148
- assert_operator(build_time, :<=, end_time)
143
+ assert_equal Gem.source_date_epoch.to_i, build_time
149
144
  ensure
150
145
  ENV["SOURCE_DATE_EPOCH"] = epoch
151
146
  end