rubygems-update 2.2.5 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +4 -1
  5. data/CONTRIBUTING +20 -0
  6. data/History.txt +117 -14
  7. data/Manifest.txt +11 -2
  8. data/README.rdoc +1 -1
  9. data/Rakefile +0 -3
  10. data/lib/rubygems.rb +31 -11
  11. data/lib/rubygems/available_set.rb +1 -1
  12. data/lib/rubygems/basic_specification.rb +20 -10
  13. data/lib/rubygems/command.rb +4 -1
  14. data/lib/rubygems/commands/cert_command.rb +11 -13
  15. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  16. data/lib/rubygems/commands/dependency_command.rb +2 -2
  17. data/lib/rubygems/commands/environment_command.rb +5 -2
  18. data/lib/rubygems/commands/help_command.rb +199 -20
  19. data/lib/rubygems/commands/install_command.rb +40 -10
  20. data/lib/rubygems/commands/list_command.rb +2 -2
  21. data/lib/rubygems/commands/open_command.rb +81 -0
  22. data/lib/rubygems/commands/search_command.rb +5 -5
  23. data/lib/rubygems/commands/setup_command.rb +1 -1
  24. data/lib/rubygems/commands/update_command.rb +8 -5
  25. data/lib/rubygems/commands/yank_command.rb +8 -13
  26. data/lib/rubygems/config_file.rb +13 -2
  27. data/lib/rubygems/dependency.rb +29 -16
  28. data/lib/rubygems/dependency_installer.rb +44 -10
  29. data/lib/rubygems/doctor.rb +1 -1
  30. data/lib/rubygems/errors.rb +30 -0
  31. data/lib/rubygems/exceptions.rb +20 -0
  32. data/lib/rubygems/ext/builder.rb +1 -1
  33. data/lib/rubygems/gemcutter_utilities.rb +1 -1
  34. data/lib/rubygems/installer.rb +4 -4
  35. data/lib/rubygems/name_tuple.rb +3 -1
  36. data/lib/rubygems/package.rb +27 -14
  37. data/lib/rubygems/package/file_source.rb +33 -0
  38. data/lib/rubygems/package/io_source.rb +45 -0
  39. data/lib/rubygems/package/old.rb +5 -5
  40. data/lib/rubygems/package/source.rb +3 -0
  41. data/lib/rubygems/platform.rb +2 -1
  42. data/lib/rubygems/rdoc.rb +1 -1
  43. data/lib/rubygems/remote_fetcher.rb +59 -18
  44. data/lib/rubygems/request.rb +71 -101
  45. data/lib/rubygems/request/connection_pools.rb +77 -0
  46. data/lib/rubygems/request/http_pool.rb +38 -0
  47. data/lib/rubygems/request/https_pool.rb +10 -0
  48. data/lib/rubygems/request_set.rb +65 -20
  49. data/lib/rubygems/request_set/gem_dependency_api.rb +234 -14
  50. data/lib/rubygems/request_set/lockfile.rb +65 -22
  51. data/lib/rubygems/requirement.rb +3 -0
  52. data/lib/rubygems/resolver.rb +33 -16
  53. data/lib/rubygems/resolver/activation_request.rb +7 -0
  54. data/lib/rubygems/resolver/api_set.rb +12 -2
  55. data/lib/rubygems/resolver/api_specification.rb +6 -0
  56. data/lib/rubygems/resolver/composed_set.rb +4 -0
  57. data/lib/rubygems/resolver/dependency_request.rb +20 -1
  58. data/lib/rubygems/resolver/git_set.rb +1 -1
  59. data/lib/rubygems/resolver/git_specification.rb +1 -1
  60. data/lib/rubygems/resolver/index_set.rb +3 -1
  61. data/lib/rubygems/resolver/installed_specification.rb +19 -1
  62. data/lib/rubygems/resolver/installer_set.rb +84 -4
  63. data/lib/rubygems/resolver/local_specification.rb +25 -0
  64. data/lib/rubygems/resolver/lock_set.rb +13 -9
  65. data/lib/rubygems/resolver/lock_specification.rb +1 -1
  66. data/lib/rubygems/resolver/set.rb +6 -0
  67. data/lib/rubygems/resolver/spec_specification.rb +0 -2
  68. data/lib/rubygems/resolver/specification.rb +23 -2
  69. data/lib/rubygems/resolver/vendor_set.rb +1 -1
  70. data/lib/rubygems/resolver/vendor_specification.rb +1 -1
  71. data/lib/rubygems/security/policy.rb +1 -0
  72. data/lib/rubygems/server.rb +36 -1
  73. data/lib/rubygems/source.rb +6 -2
  74. data/lib/rubygems/source/git.rb +1 -1
  75. data/lib/rubygems/source/installed.rb +4 -0
  76. data/lib/rubygems/source/specific_file.rb +6 -1
  77. data/lib/rubygems/spec_fetcher.rb +6 -13
  78. data/lib/rubygems/specification.rb +91 -63
  79. data/lib/rubygems/stub_specification.rb +9 -0
  80. data/lib/rubygems/test_case.rb +4 -2
  81. data/lib/rubygems/text.rb +15 -5
  82. data/lib/rubygems/uninstaller.rb +4 -1
  83. data/lib/rubygems/user_interaction.rb +8 -0
  84. data/lib/rubygems/version.rb +5 -1
  85. data/test/rubygems/test_gem.rb +88 -2
  86. data/test/rubygems/test_gem_available_set.rb +11 -8
  87. data/test/rubygems/test_gem_command.rb +55 -0
  88. data/test/rubygems/test_gem_commands_cert_command.rb +1 -0
  89. data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
  90. data/test/rubygems/test_gem_commands_help_command.rb +7 -0
  91. data/test/rubygems/test_gem_commands_install_command.rb +71 -4
  92. data/test/rubygems/test_gem_commands_open_command.rb +46 -0
  93. data/test/rubygems/test_gem_commands_setup_command.rb +9 -0
  94. data/test/rubygems/test_gem_commands_update_command.rb +48 -0
  95. data/test/rubygems/test_gem_commands_yank_command.rb +2 -2
  96. data/test/rubygems/test_gem_config_file.rb +19 -7
  97. data/test/rubygems/test_gem_dependency.rb +86 -2
  98. data/test/rubygems/test_gem_dependency_installer.rb +36 -164
  99. data/test/rubygems/test_gem_gemcutter_utilities.rb +9 -0
  100. data/test/rubygems/test_gem_installer.rb +6 -1
  101. data/test/rubygems/test_gem_name_tuple.rb +7 -0
  102. data/test/rubygems/test_gem_package.rb +17 -0
  103. data/test/rubygems/test_gem_remote_fetcher.rb +65 -46
  104. data/test/rubygems/test_gem_request.rb +75 -61
  105. data/test/rubygems/test_gem_request_connection_pools.rb +83 -0
  106. data/test/rubygems/test_gem_request_set.rb +156 -1
  107. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +72 -27
  108. data/test/rubygems/test_gem_request_set_lockfile.rb +335 -0
  109. data/test/rubygems/test_gem_requirement.rb +5 -0
  110. data/test/rubygems/test_gem_resolver.rb +91 -2
  111. data/test/rubygems/test_gem_resolver_activation_request.rb +10 -0
  112. data/test/rubygems/test_gem_resolver_api_set.rb +2 -2
  113. data/test/rubygems/test_gem_resolver_api_specification.rb +40 -0
  114. data/test/rubygems/test_gem_resolver_composed_set.rb +14 -0
  115. data/test/rubygems/test_gem_resolver_dependency_request.rb +55 -0
  116. data/test/rubygems/test_gem_resolver_git_set.rb +26 -0
  117. data/test/rubygems/test_gem_resolver_index_set.rb +28 -2
  118. data/test/rubygems/test_gem_resolver_installer_set.rb +143 -0
  119. data/test/rubygems/test_gem_resolver_lock_set.rb +12 -6
  120. data/test/rubygems/test_gem_resolver_lock_specification.rb +1 -1
  121. data/test/rubygems/test_gem_resolver_specification.rb +32 -0
  122. data/test/rubygems/test_gem_resolver_vendor_set.rb +14 -0
  123. data/test/rubygems/test_gem_security_policy.rb +2 -2
  124. data/test/rubygems/test_gem_server.rb +69 -4
  125. data/test/rubygems/test_gem_source.rb +4 -1
  126. data/test/rubygems/test_gem_source_git.rb +15 -0
  127. data/test/rubygems/test_gem_source_specific_file.rb +4 -0
  128. data/test/rubygems/test_gem_specification.rb +82 -27
  129. data/test/rubygems/test_gem_stub_specification.rb +61 -23
  130. data/test/rubygems/test_gem_uninstaller.rb +23 -0
  131. data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +32 -0
  132. metadata +187 -33
  133. metadata.gz.sig +0 -0
  134. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  135. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +0 -32
@@ -120,6 +120,13 @@ class Gem::StubSpecification < Gem::BasicSpecification
120
120
  super
121
121
  end
122
122
 
123
+ def missing_extensions?
124
+ return false if default_gem?
125
+ return false if extensions.empty?
126
+
127
+ to_spec.missing_extensions?
128
+ end
129
+
123
130
  ##
124
131
  # Name of the gem
125
132
 
@@ -148,6 +155,8 @@ class Gem::StubSpecification < Gem::BasicSpecification
148
155
 
149
156
  def to_spec
150
157
  @spec ||= Gem::Specification.load(loaded_from)
158
+ @spec.ignored = @ignored if instance_variable_defined? :@ignored
159
+ @spec
151
160
  end
152
161
 
153
162
  ##
@@ -1263,7 +1263,7 @@ Also, a list:
1263
1263
  # The StaticSet is a static set of gem specifications used for testing only.
1264
1264
  # It is available by requiring Gem::TestCase.
1265
1265
 
1266
- class StaticSet
1266
+ class StaticSet < Gem::Resolver::Set
1267
1267
 
1268
1268
  ##
1269
1269
  # A StaticSet ignores remote because it has a fixed set of gems.
@@ -1274,6 +1274,8 @@ Also, a list:
1274
1274
  # Creates a new StaticSet for the given +specs+
1275
1275
 
1276
1276
  def initialize(specs)
1277
+ super()
1278
+
1277
1279
  @specs = specs
1278
1280
 
1279
1281
  @remote = true
@@ -1299,7 +1301,7 @@ Also, a list:
1299
1301
  # Finds all gems matching +dep+ in this set.
1300
1302
 
1301
1303
  def find_all(dep)
1302
- @specs.find_all { |s| dep.matches_spec? s }
1304
+ @specs.find_all { |s| dep.match? s }
1303
1305
  end
1304
1306
 
1305
1307
  ##
@@ -26,6 +26,16 @@ module Gem::Text
26
26
  result.join("\n").gsub(/^/, " " * indent)
27
27
  end
28
28
 
29
+ def min3 a, b, c # :nodoc:
30
+ if a < b && a < c
31
+ a
32
+ elsif b < a && b < c
33
+ b
34
+ else
35
+ c
36
+ end
37
+ end
38
+
29
39
  # This code is based directly on the Text gem implementation
30
40
  # Returns a value representing the "cost" of transforming str1 into str2
31
41
  def levenshtein_distance str1, str2
@@ -42,16 +52,16 @@ module Gem::Text
42
52
  d = (0..m).to_a
43
53
  x = nil
44
54
 
45
- n.times do |i|
55
+ str1.each_char.each_with_index do |char1,i|
46
56
  e = i+1
47
57
 
48
- m.times do |j|
49
- cost = (s[i] == t[j]) ? 0 : 1
50
- x = [
58
+ str2.each_char.each_with_index do |char2,j|
59
+ cost = (char1 == char2) ? 0 : 1
60
+ x = min3(
51
61
  d[j+1] + 1, # insertion
52
62
  e + 1, # deletion
53
63
  d[j] + cost # substitution
54
- ].min
64
+ )
55
65
  d[j] = e
56
66
  e = x
57
67
  end
@@ -96,6 +96,8 @@ class Gem::Uninstaller
96
96
  (@user_install and spec.base_dir == Gem.user_dir)
97
97
  end
98
98
 
99
+ list.sort!
100
+
99
101
  if list.empty? then
100
102
  if other_repo_specs.empty?
101
103
  if default_specs.empty?
@@ -120,7 +122,8 @@ class Gem::Uninstaller
120
122
  remove_all list
121
123
 
122
124
  elsif list.size > 1 then
123
- gem_names = list.collect {|gem| gem.full_name} + ["All versions"]
125
+ gem_names = list.map { |gem| gem.full_name }
126
+ gem_names << "All versions"
124
127
 
125
128
  say
126
129
  _, index = choose_from_list "Select gem to uninstall:", gem_names
@@ -157,6 +157,14 @@ module Gem::UserInteraction
157
157
  def terminate_interaction exit_code = 0
158
158
  ui.terminate_interaction exit_code
159
159
  end
160
+
161
+ ##
162
+ # Calls +say+ with +msg+ or the results of the block if really_verbose
163
+ # is true.
164
+
165
+ def verbose msg = nil
166
+ say(msg || yield) if Gem.configuration.really_verbose
167
+ end
160
168
  end
161
169
 
162
170
  ##
@@ -143,6 +143,10 @@
143
143
  # "~> 3.0.0" 3.0.0 ... 3.1
144
144
  # "~> 3.5" 3.5 ... 4.0
145
145
  # "~> 3.5.0" 3.5.0 ... 3.6
146
+ # "~> 3" 3.0 ... 4.0
147
+ #
148
+ # For the last example, single-digit versions are automatically extended with
149
+ # a zero to give a sensible result.
146
150
 
147
151
  class Gem::Version
148
152
  autoload :Requirement, 'rubygems/requirement'
@@ -189,7 +193,7 @@ class Gem::Version
189
193
  @@all = {}
190
194
 
191
195
  def self.new version # :nodoc:
192
- return super unless Gem::VERSION == self.class
196
+ return super unless Gem::Version == self
193
197
 
194
198
  @@all[version] ||= super
195
199
  end
@@ -816,6 +816,23 @@ class TestGem < Gem::TestCase
816
816
  assert_match %r%Could not find 'b' %, e.message
817
817
  end
818
818
 
819
+ def test_self_try_activate_missing_extensions
820
+ util_spec 'ext', '1' do |s|
821
+ s.extensions = %w[ext/extconf.rb]
822
+ s.mark_version
823
+ s.installed_by_version = v('2.2')
824
+ end
825
+
826
+ _, err = capture_io do
827
+ refute Gem.try_activate 'nonexistent'
828
+ end
829
+
830
+ expected = "Ignoring ext-1 because its extensions are not built. " +
831
+ "Try: gem pristine ext-1\n"
832
+
833
+ assert_equal expected, err
834
+ end
835
+
819
836
  def test_self_use_paths
820
837
  util_ensure_gem_dirs
821
838
 
@@ -1251,13 +1268,27 @@ class TestGem < Gem::TestCase
1251
1268
  end
1252
1269
 
1253
1270
  def test_use_gemdeps
1271
+ spec = util_spec 'a', 1
1272
+
1273
+ refute spec.activated?
1274
+
1275
+ open 'gem.deps.rb', 'w' do |io|
1276
+ io.write 'gem "a"'
1277
+ end
1278
+
1279
+ Gem.use_gemdeps 'gem.deps.rb'
1280
+
1281
+ assert spec.activated?
1282
+ end
1283
+
1284
+ def test_use_gemdeps_ENV
1254
1285
  rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
1255
1286
 
1256
1287
  spec = util_spec 'a', 1
1257
1288
 
1258
1289
  refute spec.activated?
1259
1290
 
1260
- open 'Gemfile', 'w' do |io|
1291
+ open 'gem.deps.rb', 'w' do |io|
1261
1292
  io.write 'gem "a"'
1262
1293
  end
1263
1294
 
@@ -1268,6 +1299,29 @@ class TestGem < Gem::TestCase
1268
1299
  ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1269
1300
  end
1270
1301
 
1302
+ def test_use_gemdeps_argument_missing
1303
+ e = assert_raises ArgumentError do
1304
+ Gem.use_gemdeps 'gem.deps.rb'
1305
+ end
1306
+
1307
+ assert_equal 'Unable to find gem dependencies file at gem.deps.rb',
1308
+ e.message
1309
+ end
1310
+
1311
+ def test_use_gemdeps_argument_missing_match_ENV
1312
+ rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] =
1313
+ ENV['RUBYGEMS_GEMDEPS'], 'gem.deps.rb'
1314
+
1315
+ e = assert_raises ArgumentError do
1316
+ Gem.use_gemdeps 'gem.deps.rb'
1317
+ end
1318
+
1319
+ assert_equal 'Unable to find gem dependencies file at gem.deps.rb',
1320
+ e.message
1321
+ ensure
1322
+ ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1323
+ end
1324
+
1271
1325
  def test_use_gemdeps_automatic
1272
1326
  skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
1273
1327
  rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
@@ -1287,6 +1341,17 @@ class TestGem < Gem::TestCase
1287
1341
  ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1288
1342
  end
1289
1343
 
1344
+ def test_use_gemdeps_automatic_missing
1345
+ skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
1346
+ rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
1347
+
1348
+ Gem.use_gemdeps
1349
+
1350
+ assert true # count
1351
+ ensure
1352
+ ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1353
+ end
1354
+
1290
1355
  def test_use_gemdeps_disabled
1291
1356
  rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], ''
1292
1357
 
@@ -1294,7 +1359,7 @@ class TestGem < Gem::TestCase
1294
1359
 
1295
1360
  refute spec.activated?
1296
1361
 
1297
- open 'Gemfile', 'w' do |io|
1362
+ open 'gem.deps.rb', 'w' do |io|
1298
1363
  io.write 'gem "a"'
1299
1364
  end
1300
1365
 
@@ -1305,6 +1370,27 @@ class TestGem < Gem::TestCase
1305
1370
  ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1306
1371
  end
1307
1372
 
1373
+ def test_use_gemdeps_missing_gem
1374
+ skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
1375
+ rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
1376
+
1377
+ open 'x', 'w' do |io|
1378
+ io.write 'gem "a"'
1379
+ end
1380
+
1381
+ expected = <<-EXPECTED
1382
+ Unable to resolve dependency: user requested 'a (>= 0)'
1383
+ You may need to `gem install -g` to install missing gems
1384
+
1385
+ EXPECTED
1386
+
1387
+ assert_output nil, expected do
1388
+ Gem.use_gemdeps
1389
+ end
1390
+ ensure
1391
+ ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
1392
+ end
1393
+
1308
1394
  def test_use_gemdeps_specific
1309
1395
  skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
1310
1396
  rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
@@ -3,6 +3,7 @@ require 'rubygems/available_set'
3
3
  require 'rubygems/security'
4
4
 
5
5
  class TestGemAvailableSet < Gem::TestCase
6
+
6
7
  def setup
7
8
  super
8
9
 
@@ -23,22 +24,24 @@ class TestGemAvailableSet < Gem::TestCase
23
24
  end
24
25
 
25
26
  def test_find_all
26
- a1, a1_gem = util_gem 'a', 1
27
+ a1, a1_gem = util_gem 'a', 1
28
+ a1a, a1a_gem = util_gem 'a', '1.a'
27
29
 
28
- source = Gem::Source::SpecificFile.new a1_gem
30
+ a1_source = Gem::Source::SpecificFile.new a1_gem
31
+ a1a_source = Gem::Source::SpecificFile.new a1a_gem
29
32
 
30
33
  set = Gem::AvailableSet.new
31
- set.add a1, source
34
+ set.add a1, a1_source
35
+ set.add a1a, a1a_source
32
36
 
33
37
  dep = Gem::Resolver::DependencyRequest.new dep('a'), nil
34
38
 
35
- specs = set.find_all dep
36
-
37
- spec = specs.first
39
+ assert_equal %w[a-1], set.find_all(dep).map { |spec| spec.full_name }
38
40
 
39
- assert_kind_of Gem::Resolver::LocalSpecification, spec
41
+ dep = Gem::Resolver::DependencyRequest.new dep('a', '>= 0.a'), nil
40
42
 
41
- assert_equal 'a-1', spec.full_name
43
+ assert_equal %w[a-1 a-1.a],
44
+ set.find_all(dep).map { |spec| spec.full_name }.sort
42
45
  end
43
46
 
44
47
  def test_match_platform
@@ -184,5 +184,60 @@ class TestGemCommand < Gem::TestCase
184
184
  assert_equal ['-h', 'command'], args
185
185
  end
186
186
 
187
+ def test_show_lookup_failure_suggestions_local
188
+ correct = "non_existent_with_hint"
189
+ misspelled = "nonexistent_with_hint"
190
+
191
+ spec_fetcher do |fetcher|
192
+ fetcher.spec correct, 2
193
+ end
194
+
195
+ use_ui @ui do
196
+ @cmd.show_lookup_failure misspelled, Gem::Requirement.default, [], :local
197
+ end
198
+
199
+ expected = <<-EXPECTED
200
+ ERROR: Could not find a valid gem 'nonexistent_with_hint' (>= 0) in any repository
201
+ EXPECTED
202
+
203
+ assert_equal expected, @ui.error
204
+ end
205
+
206
+ def test_show_lookup_failure_suggestions_none
207
+ spec_fetcher do |fetcher|
208
+ fetcher.spec 'correct', 2
209
+ end
210
+
211
+ use_ui @ui do
212
+ @cmd.show_lookup_failure 'other', Gem::Requirement.default, [], :remote
213
+ end
214
+
215
+ expected = <<-EXPECTED
216
+ ERROR: Could not find a valid gem 'other' (>= 0) in any repository
217
+ EXPECTED
218
+
219
+ assert_equal expected, @ui.error
220
+ end
221
+
222
+ def test_show_lookup_failure_suggestions_remote
223
+ correct = "non_existent_with_hint"
224
+ misspelled = "nonexistent_with_hint"
225
+
226
+ spec_fetcher do |fetcher|
227
+ fetcher.spec correct, 2
228
+ end
229
+
230
+ use_ui @ui do
231
+ @cmd.show_lookup_failure misspelled, Gem::Requirement.default, [], :remote
232
+ end
233
+
234
+ expected = <<-EXPECTED
235
+ ERROR: Could not find a valid gem 'nonexistent_with_hint' (>= 0) in any repository
236
+ ERROR: Possible alternatives: non_existent_with_hint
237
+ EXPECTED
238
+
239
+ assert_equal expected, @ui.error
240
+ end
241
+
187
242
  end
188
243
 
@@ -179,6 +179,7 @@ Added '/CN=alternate/DC=example'
179
179
  assert_empty @ui.error
180
180
 
181
181
  assert_path_exists File.join(@tempdir, 'gem-public_cert.pem')
182
+ refute_path_exists File.join(@tempdir, 'gem-private_key.pem')
182
183
  end
183
184
 
184
185
  def test_execute_build_encrypted_key
@@ -28,6 +28,7 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
28
28
  assert_match %r|RUBYGEMS PREFIX: |, @ui.output
29
29
  assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|,
30
30
  @ui.output
31
+ assert_match %r|SYSTEM CONFIGURATION DIRECTORY:|, @ui.output
31
32
  assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
32
33
  assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
33
34
  assert_match %r|- #{Gem::Platform.local}|, @ui.output
@@ -22,6 +22,13 @@ class TestGemCommandsHelpCommand < Gem::TestCase
22
22
  end
23
23
  end
24
24
 
25
+ def test_gem_help_gem_dependencies
26
+ util_gem 'gem_dependencies' do |out, err|
27
+ assert_match 'gem.deps.rb', out
28
+ assert_equal '', err
29
+ end
30
+ end
31
+
25
32
  def test_gem_help_platforms
26
33
  util_gem 'platforms' do |out, err|
27
34
  assert_match(/x86-freebsd/, out)
@@ -24,6 +24,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
24
24
 
25
25
  Gem::Command.build_args = @orig_args
26
26
  File.unlink @gemdeps if File.file? @gemdeps
27
+ File.unlink "#{@gemdeps}.lock" if File.file? "#{@gemdeps}.lock"
27
28
  end
28
29
 
29
30
  def test_execute_exclude_prerelease
@@ -194,6 +195,32 @@ class TestGemCommandsInstallCommand < Gem::TestCase
194
195
  assert_match(%r!Unable to download data from http://not-there.nothing!, errs.shift)
195
196
  end
196
197
 
198
+ def test_execute_nonexistent_hint_disabled
199
+ misspelled = "nonexistent_with_hint"
200
+ correctly_spelled = "non_existent_with_hint"
201
+
202
+ spec_fetcher do |fetcher|
203
+ fetcher.spec correctly_spelled, 2
204
+ end
205
+
206
+ @cmd.options[:args] = [misspelled]
207
+ @cmd.options[:suggest_alternate] = false
208
+
209
+ use_ui @ui do
210
+ e = assert_raises Gem::MockGemUi::TermError do
211
+ @cmd.execute
212
+ end
213
+
214
+ assert_equal 2, e.exit_code
215
+ end
216
+
217
+ expected = <<-EXPECTED
218
+ ERROR: Could not find a valid gem 'nonexistent_with_hint' (>= 0) in any repository
219
+ EXPECTED
220
+
221
+ assert_equal expected, @ui.error
222
+ end
223
+
197
224
  def test_execute_nonexistent_with_hint
198
225
  misspelled = "nonexistent_with_hint"
199
226
  correctly_spelled = "non_existent_with_hint"
@@ -238,7 +265,10 @@ ERROR: Possible alternatives: non_existent_with_hint
238
265
  assert_equal 2, e.exit_code
239
266
  end
240
267
 
241
- expected = ["ERROR: Could not find a valid gem 'non-existent_with-hint' (>= 0) in any repository", "ERROR: Possible alternatives: nonexistent-with_hint"]
268
+ expected = [
269
+ "ERROR: Could not find a valid gem 'non-existent_with-hint' (>= 0) in any repository",
270
+ "ERROR: Possible alternatives: nonexistent-with_hint"
271
+ ]
242
272
 
243
273
  output = @ui.error.split "\n"
244
274
 
@@ -622,8 +652,8 @@ ERROR: Possible alternatives: non_existent_with_hint
622
652
  end
623
653
 
624
654
  assert_equal 2, e.exit_code
625
- assert_match %r!Could not find a valid gem 'blah' \(>= 0\)!, @ui.error
626
- assert_match %r!Unable to download data from http://not-there\.nothing!, @ui.error
655
+
656
+ assert_match 'Unable to download data', @ui.error
627
657
  end
628
658
 
629
659
  def test_show_source_problems_even_on_success
@@ -648,7 +678,7 @@ ERROR: Possible alternatives: non_existent_with_hint
648
678
 
649
679
  e = @ui.error
650
680
 
651
- x = "WARNING: Unable to pull data from 'http://nonexistent.example': no data for http://nonexistent.example/latest_specs.4.8.gz (http://nonexistent.example/latest_specs.4.8.gz)\n"
681
+ x = "WARNING: Unable to pull data from 'http://nonexistent.example': no data for http://nonexistent.example/specs.4.8.gz (http://nonexistent.example/specs.4.8.gz)\n"
652
682
  assert_equal x, e
653
683
  end
654
684
 
@@ -672,6 +702,31 @@ ERROR: Possible alternatives: non_existent_with_hint
672
702
  assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
673
703
 
674
704
  assert_match "Using a (2)", @ui.output
705
+ assert File.exist?("#{@gemdeps}.lock")
706
+ end
707
+
708
+ def test_execute_uses_from_a_gemdeps_with_no_lock
709
+ spec_fetcher do |fetcher|
710
+ fetcher.gem 'a', 2
711
+ end
712
+
713
+ File.open @gemdeps, "w" do |f|
714
+ f << "gem 'a'"
715
+ end
716
+
717
+ @cmd.handle_options %w[--no-lock]
718
+ @cmd.options[:gemdeps] = @gemdeps
719
+
720
+ use_ui @ui do
721
+ assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
722
+ @cmd.execute
723
+ end
724
+ end
725
+
726
+ assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
727
+
728
+ assert_match "Using a (2)", @ui.output
729
+ assert !File.exist?("#{@gemdeps}.lock")
675
730
  end
676
731
 
677
732
  def test_execute_installs_from_a_gemdeps
@@ -885,6 +940,18 @@ ERROR: Possible alternatives: non_existent_with_hint
885
940
  assert_equal 'gem.deps.rb', @cmd.options[:gemdeps]
886
941
  end
887
942
 
943
+ def test_handle_options_suggest
944
+ assert @cmd.options[:suggest_alternate]
945
+
946
+ @cmd.handle_options %w[--no-suggestions]
947
+
948
+ refute @cmd.options[:suggest_alternate]
949
+
950
+ @cmd.handle_options %w[--suggestions]
951
+
952
+ assert @cmd.options[:suggest_alternate]
953
+ end
954
+
888
955
  def test_handle_options_without
889
956
  @cmd.handle_options %w[--without test]
890
957