rubygems-update 1.5.3 → 1.6.0

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.

Potentially problematic release.


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

Files changed (79) hide show
  1. data.tar.gz.sig +2 -1
  2. data/History.txt +60 -9
  3. data/Manifest.txt +1 -1
  4. data/Rakefile +0 -2
  5. data/lib/rubygems.rb +142 -65
  6. data/lib/rubygems/commands/owner_command.rb +3 -2
  7. data/lib/rubygems/commands/pristine_command.rb +5 -3
  8. data/lib/rubygems/commands/push_command.rb +8 -4
  9. data/lib/rubygems/commands/setup_command.rb +1 -2
  10. data/lib/rubygems/commands/uninstall_command.rb +5 -0
  11. data/lib/rubygems/commands/unpack_command.rb +10 -16
  12. data/lib/rubygems/config_file.rb +12 -5
  13. data/lib/rubygems/custom_require.rb +27 -7
  14. data/lib/rubygems/dependency.rb +33 -8
  15. data/lib/rubygems/dependency_installer.rb +21 -6
  16. data/lib/rubygems/dependency_list.rb +35 -3
  17. data/lib/rubygems/doc_manager.rb +6 -4
  18. data/lib/rubygems/gem_path_searcher.rb +45 -1
  19. data/lib/rubygems/gemcutter_utilities.rb +33 -0
  20. data/lib/rubygems/indexer.rb +1 -0
  21. data/lib/rubygems/installer.rb +11 -7
  22. data/lib/rubygems/installer_test_case.rb +23 -15
  23. data/lib/rubygems/mock_gem_ui.rb +1 -1
  24. data/lib/rubygems/remote_fetcher.rb +29 -10
  25. data/lib/rubygems/requirement.rb +1 -1
  26. data/lib/rubygems/security.rb +1 -0
  27. data/lib/rubygems/source_index.rb +3 -2
  28. data/lib/rubygems/spec_fetcher.rb +3 -1
  29. data/lib/rubygems/specification.rb +54 -12
  30. data/lib/rubygems/test_case.rb +99 -28
  31. data/lib/rubygems/test_utilities.rb +11 -1
  32. data/lib/rubygems/uninstaller.rb +22 -11
  33. data/lib/rubygems/user_interaction.rb +50 -29
  34. data/lib/rubygems/validator.rb +1 -1
  35. data/test/rubygems/fix_openssl_warnings.rb +12 -0
  36. data/test/rubygems/plugin/load/rubygems_plugin.rb +3 -1
  37. data/test/rubygems/test_gem.rb +384 -38
  38. data/test/rubygems/test_gem_builder.rb +1 -1
  39. data/test/rubygems/test_gem_command_manager.rb +2 -2
  40. data/test/rubygems/test_gem_commands_build_command.rb +1 -1
  41. data/test/rubygems/test_gem_commands_cert_command.rb +2 -1
  42. data/test/rubygems/test_gem_commands_dependency_command.rb +6 -5
  43. data/test/rubygems/test_gem_commands_fetch_command.rb +4 -4
  44. data/test/rubygems/test_gem_commands_install_command.rb +21 -18
  45. data/test/rubygems/test_gem_commands_lock_command.rb +1 -1
  46. data/test/rubygems/test_gem_commands_outdated_command.rb +2 -5
  47. data/test/rubygems/test_gem_commands_owner_command.rb +42 -0
  48. data/test/rubygems/test_gem_commands_pristine_command.rb +28 -8
  49. data/test/rubygems/test_gem_commands_push_command.rb +31 -5
  50. data/test/rubygems/test_gem_commands_specification_command.rb +8 -8
  51. data/test/rubygems/test_gem_commands_stale_command.rb +4 -2
  52. data/test/rubygems/test_gem_commands_uninstall_command.rb +23 -4
  53. data/test/rubygems/test_gem_commands_unpack_command.rb +10 -8
  54. data/test/rubygems/test_gem_commands_update_command.rb +16 -13
  55. data/test/rubygems/test_gem_commands_which_command.rb +1 -1
  56. data/test/rubygems/test_gem_config_file.rb +14 -0
  57. data/test/rubygems/test_gem_dependency.rb +39 -0
  58. data/test/rubygems/test_gem_dependency_installer.rb +213 -92
  59. data/test/rubygems/test_gem_dependency_list.rb +37 -17
  60. data/test/rubygems/test_gem_doc_manager.rb +5 -4
  61. data/test/rubygems/test_gem_format.rb +2 -2
  62. data/test/rubygems/test_gem_gemcutter_utilities.rb +48 -0
  63. data/test/rubygems/test_gem_indexer.rb +11 -10
  64. data/test/rubygems/test_gem_install_update_options.rb +0 -2
  65. data/test/rubygems/test_gem_installer.rb +151 -78
  66. data/test/rubygems/test_gem_package_tar_output.rb +3 -0
  67. data/test/rubygems/test_gem_remote_fetcher.rb +23 -14
  68. data/test/rubygems/test_gem_requirement.rb +4 -0
  69. data/test/rubygems/test_gem_security.rb +1 -0
  70. data/test/rubygems/test_gem_source_index.rb +17 -16
  71. data/test/rubygems/test_gem_spec_fetcher.rb +6 -1
  72. data/test/rubygems/test_gem_specification.rb +81 -31
  73. data/test/rubygems/test_gem_stream_ui.rb +11 -1
  74. data/test/rubygems/test_gem_uninstaller.rb +70 -10
  75. data/test/rubygems/test_gem_validator.rb +1 -1
  76. data/test/rubygems/test_kernel.rb +1 -1
  77. metadata +7 -7
  78. metadata.gz.sig +0 -0
  79. data/ChangeLog +0 -5811
@@ -4,7 +4,7 @@ require 'rubygems/builder'
4
4
  class TestGemBuilder < Gem::TestCase
5
5
 
6
6
  def test_build
7
- builder = Gem::Builder.new quick_gem('a')
7
+ builder = Gem::Builder.new quick_spec('a')
8
8
 
9
9
  use_ui @ui do
10
10
  Dir.chdir @tempdir do
@@ -11,7 +11,7 @@ class TestGemCommandManager < Gem::TestCase
11
11
 
12
12
  def test_run_interrupt
13
13
  old_load_path = $:.dup
14
- $: << "test/rubygems"
14
+ $: << File.expand_path("test/rubygems", @@project_dir)
15
15
  Gem.load_env_plugins
16
16
 
17
17
  use_ui @ui do
@@ -27,7 +27,7 @@ class TestGemCommandManager < Gem::TestCase
27
27
 
28
28
  def test_run_crash_command
29
29
  old_load_path = $:.dup
30
- $: << "test/rubygems"
30
+ $: << File.expand_path("test/rubygems", @@project_dir)
31
31
 
32
32
  @command_manager.register_command :crash
33
33
  use_ui @ui do
@@ -7,7 +7,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
7
7
  def setup
8
8
  super
9
9
 
10
- @gem = quick_gem 'some_gem' do |s|
10
+ @gem = quick_spec 'some_gem' do |s|
11
11
  s.rubyforge_project = 'example'
12
12
  end
13
13
 
@@ -1,5 +1,6 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/cert_command'
3
+ require 'rubygems/fix_openssl_warnings' if RUBY_VERSION < "1.9"
3
4
 
4
5
  unless defined? OpenSSL then
5
6
  warn "`gem cert` tests are being skipped, module OpenSSL not found"
@@ -15,7 +16,7 @@ class TestGemCommandsCertCommand < Gem::TestCase
15
16
 
16
17
  @cmd = Gem::Commands::CertCommand.new
17
18
 
18
- root = File.expand_path(File.dirname(__FILE__))
19
+ root = File.expand_path(File.dirname(__FILE__), @@project_dir)
19
20
 
20
21
  FileUtils.cp File.join(root, 'data', 'gem-private_key.pem'), @tempdir
21
22
  FileUtils.cp File.join(root, 'data', 'gem-public_cert.pem'), @tempdir
@@ -26,7 +26,7 @@ class TestGemCommandsDependencyCommand < Gem::TestCase
26
26
  @cmd.execute
27
27
  end
28
28
 
29
- assert_equal "Gem foo-2\n bar (> 1, runtime)\n baz (> 1, runtime)\n\n",
29
+ assert_equal "Gem foo-2\n bar (> 1)\n baz (> 1)\n\n",
30
30
  @ui.output
31
31
  assert_equal '', @ui.error
32
32
  end
@@ -77,7 +77,7 @@ Gem pl-1-x86-linux
77
77
  end
78
78
 
79
79
  def test_execute_pipe_format
80
- quick_gem 'foo' do |gem|
80
+ quick_spec 'foo' do |gem|
81
81
  gem.add_dependency 'bar', '> 1'
82
82
  end
83
83
 
@@ -121,6 +121,7 @@ Gem b-2
121
121
  end
122
122
 
123
123
  def test_execute_reverse
124
+ # FIX: this shouldn't need to write out, but fails if you switch it
124
125
  quick_gem 'foo' do |gem|
125
126
  gem.add_dependency 'bar', '> 1'
126
127
  end
@@ -140,9 +141,9 @@ Gem b-2
140
141
 
141
142
  expected = <<-EOF
142
143
  Gem foo-2
143
- bar (> 1, runtime)
144
+ bar (> 1)
144
145
  Used by
145
- baz-2 (foo (>= 0, runtime))
146
+ baz-2 (foo (>= 0))
146
147
 
147
148
  EOF
148
149
 
@@ -188,7 +189,7 @@ ERROR: Only reverse dependencies for local gems are supported.
188
189
  @cmd.execute
189
190
  end
190
191
 
191
- assert_equal "Gem foo-2\n bar (> 1, runtime)\n\n", @ui.output
192
+ assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
192
193
  assert_equal '', @ui.error
193
194
  end
194
195
 
@@ -16,7 +16,7 @@ class TestGemCommandsFetchCommand < Gem::TestCase
16
16
  util_setup_spec_fetcher @a2
17
17
 
18
18
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
19
- File.read(File.join(@gemhome, 'cache', @a2.file_name))
19
+ File.read(Gem.cache_gem(@a2.file_name, @gemhome))
20
20
 
21
21
  @cmd.options[:args] = [@a2.name]
22
22
 
@@ -35,9 +35,9 @@ class TestGemCommandsFetchCommand < Gem::TestCase
35
35
  util_setup_spec_fetcher @a2, @a2_pre
36
36
 
37
37
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
38
- File.read(File.join(@gemhome, 'cache', @a2.file_name))
38
+ File.read(Gem.cache_gem(@a2.file_name, @gemhome))
39
39
  @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
40
- File.read(File.join(@gemhome, 'cache', @a2_pre.file_name))
40
+ File.read(Gem.cache_gem(@a2_pre.file_name, @gemhome))
41
41
 
42
42
  @cmd.options[:args] = [@a2.name]
43
43
  @cmd.options[:prerelease] = true
@@ -57,7 +57,7 @@ class TestGemCommandsFetchCommand < Gem::TestCase
57
57
  util_setup_spec_fetcher @a1, @a2
58
58
 
59
59
  @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
60
- File.read(File.join(@gemhome, 'cache', @a1.file_name))
60
+ File.read(Gem.cache_gem(@a1.file_name, @gemhome))
61
61
 
62
62
  @cmd.options[:args] = [@a2.name]
63
63
  @cmd.options[:version] = Gem::Requirement.new '1'
@@ -1,6 +1,12 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/install_command'
3
3
 
4
+ begin
5
+ gem "rdoc"
6
+ rescue Gem::LoadError
7
+ # ignore
8
+ end
9
+
4
10
  class TestGemCommandsInstallCommand < Gem::TestCase
5
11
 
6
12
  def setup
@@ -16,9 +22,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
16
22
  util_setup_spec_fetcher @a2, @a2_pre
17
23
 
18
24
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
19
- read_binary(File.join(@gemhome, 'cache', @a2.file_name))
25
+ read_binary(Gem.cache_gem(@a2.file_name, @gemhome))
20
26
  @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
21
- read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
27
+ read_binary(Gem.cache_gem(@a2_pre.file_name, @gemhome))
22
28
 
23
29
  @cmd.options[:args] = [@a2.name]
24
30
 
@@ -38,11 +44,12 @@ class TestGemCommandsInstallCommand < Gem::TestCase
38
44
  util_setup_spec_fetcher @a2, @a2_pre
39
45
 
40
46
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
41
- read_binary(File.join(@gemhome, 'cache', @a2.file_name))
47
+ read_binary(Gem.cache_gem(@a2.file_name, @gemhome))
42
48
  @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
43
- read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
49
+ read_binary(Gem.cache_gem(@a2_pre.file_name, @gemhome))
44
50
 
45
- @cmd.handle_options [@a2_pre.name, '--version', @a2_pre.version.to_s]
51
+ @cmd.handle_options [@a2_pre.name, '--version', @a2_pre.version.to_s,
52
+ "--no-ri", "--no-rdoc"]
46
53
  assert @cmd.options[:prerelease]
47
54
  assert @cmd.options[:version].satisfied_by?(@a2_pre.version)
48
55
 
@@ -79,8 +86,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
79
86
  util_setup_fake_fetcher
80
87
  @cmd.options[:domain] = :local
81
88
 
82
- FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
83
- File.join(@tempdir)
89
+ FileUtils.mv Gem.cache_gem(@a2.file_name, @gemhome), @tempdir
84
90
 
85
91
  @cmd.options[:args] = [@a2.name]
86
92
 
@@ -109,8 +115,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
109
115
  util_setup_fake_fetcher
110
116
  @cmd.options[:user_install] = false
111
117
 
112
- FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
113
- File.join(@tempdir)
118
+ FileUtils.mv Gem.cache_gem(@a2.file_name, @gemhome), @tempdir
114
119
 
115
120
  @cmd.options[:args] = [@a2.name]
116
121
 
@@ -177,7 +182,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
177
182
  correctly_spelled = "non_existent_with_hint"
178
183
 
179
184
  util_setup_fake_fetcher
180
- util_setup_spec_fetcher quick_gem(correctly_spelled, '2')
185
+ util_setup_spec_fetcher quick_spec(correctly_spelled, '2')
181
186
 
182
187
  @cmd.options[:args] = [misspelled]
183
188
 
@@ -201,9 +206,9 @@ ERROR: Possible alternatives: non_existent_with_hint
201
206
  util_setup_spec_fetcher @a2, @a2_pre
202
207
 
203
208
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
204
- read_binary(File.join(@gemhome, 'cache', @a2.file_name))
209
+ read_binary(Gem.cache_gem(@a2.file_name, @gemhome))
205
210
  @fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
206
- read_binary(File.join(@gemhome, 'cache', @a2_pre.file_name))
211
+ read_binary(Gem.cache_gem(@a2_pre.file_name, @gemhome))
207
212
 
208
213
  @cmd.options[:prerelease] = true
209
214
  @cmd.options[:args] = [@a2_pre.name]
@@ -227,7 +232,7 @@ ERROR: Possible alternatives: non_existent_with_hint
227
232
  util_setup_spec_fetcher @a2
228
233
 
229
234
  @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
230
- read_binary(File.join(@gemhome, 'cache', @a2.file_name))
235
+ read_binary(Gem.cache_gem(@a2.file_name, @gemhome))
231
236
 
232
237
  @cmd.options[:args] = [@a2.name]
233
238
 
@@ -254,11 +259,9 @@ ERROR: Possible alternatives: non_existent_with_hint
254
259
  util_setup_fake_fetcher
255
260
  @cmd.options[:domain] = :local
256
261
 
257
- FileUtils.mv File.join(@gemhome, 'cache', @a2.file_name),
258
- File.join(@tempdir)
262
+ FileUtils.mv Gem.cache_gem(@a2.file_name, @gemhome), @tempdir
259
263
 
260
- FileUtils.mv File.join(@gemhome, 'cache', @b2.file_name),
261
- File.join(@tempdir)
264
+ FileUtils.mv Gem.cache_gem(@b2.file_name, @gemhome), @tempdir
262
265
 
263
266
  @cmd.options[:args] = [@a2.name, @b2.name]
264
267
 
@@ -287,7 +290,7 @@ ERROR: Possible alternatives: non_existent_with_hint
287
290
  util_setup_spec_fetcher @b2
288
291
 
289
292
  @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] =
290
- read_binary(File.join(@gemhome, 'cache', @b2.file_name))
293
+ read_binary(Gem.cache_gem(@b2.file_name, @gemhome))
291
294
 
292
295
  uninstall_gem(@b2)
293
296
 
@@ -45,7 +45,7 @@ gem 'a', '= 1'
45
45
  expected = <<-EXPECTED
46
46
  require 'rubygems'
47
47
  gem 'd', '= 1'
48
- # Unable to satisfy 'z (>= 0, runtime)' from currently installed gems
48
+ # Unable to satisfy 'z (>= 0)' from currently installed gems
49
49
  EXPECTED
50
50
 
51
51
  assert_equal expected, @ui.output
@@ -16,14 +16,11 @@ class TestGemCommandsOutdatedCommand < Gem::TestCase
16
16
  def test_execute
17
17
  quick_gem 'foo', '0.1'
18
18
  quick_gem 'foo', '0.2'
19
- remote_10 = quick_gem 'foo', '1.0'
20
- remote_20 = quick_gem 'foo', '2.0'
19
+ remote_10 = quick_spec 'foo', '1.0'
20
+ remote_20 = quick_spec 'foo', '2.0'
21
21
 
22
22
  remote_spec_file = File.join @gemhome, 'specifications', remote_10.spec_name
23
- FileUtils.rm remote_spec_file
24
-
25
23
  remote_spec_file = File.join @gemhome, 'specifications', remote_20.spec_name
26
- FileUtils.rm remote_spec_file
27
24
 
28
25
  @fetcher = Gem::FakeFetcher.new
29
26
  Gem::RemoteFetcher.fetcher = @fetcher
@@ -47,6 +47,20 @@ EOF
47
47
  assert_match response, @ui.output
48
48
  end
49
49
 
50
+ def test_show_owners_key
51
+ response = "- email: user1@example.com\n"
52
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
53
+ File.open Gem.configuration.credentials_path, 'a' do |f|
54
+ f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
55
+ end
56
+ Gem.configuration.load_api_keys
57
+
58
+ @cmd.handle_options %w(-k other)
59
+ @cmd.show_owners('freewill')
60
+
61
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
62
+ end
63
+
50
64
  def test_add_owners
51
65
  response = "Owner added successfully."
52
66
  @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
@@ -75,6 +89,20 @@ EOF
75
89
  assert_match response, @ui.output
76
90
  end
77
91
 
92
+ def test_add_owners_key
93
+ response = "Owner added successfully."
94
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
95
+ File.open Gem.configuration.credentials_path, 'a' do |f|
96
+ f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
97
+ end
98
+ Gem.configuration.load_api_keys
99
+
100
+ @cmd.handle_options %w(-k other)
101
+ @cmd.add_owners('freewill', ['user-new1@example.com'])
102
+
103
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
104
+ end
105
+
78
106
  def test_remove_owners
79
107
  response = "Owner removed successfully."
80
108
  @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
@@ -102,4 +130,18 @@ EOF
102
130
 
103
131
  assert_match response, @ui.output
104
132
  end
133
+
134
+ def test_remove_owners_key
135
+ response = "Owner removed successfully."
136
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
137
+ File.open Gem.configuration.credentials_path, 'a' do |f|
138
+ f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
139
+ end
140
+ Gem.configuration.load_api_keys
141
+
142
+ @cmd.handle_options %w(-k other)
143
+ @cmd.remove_owners('freewill', ['user-remove1@example.com'])
144
+
145
+ assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
146
+ end
105
147
  end
@@ -9,7 +9,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
9
9
  end
10
10
 
11
11
  def test_execute
12
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
12
+ a = quick_spec 'a' do |s| s.executables = %w[foo] end
13
13
  FileUtils.mkdir_p File.join(@tempdir, 'bin')
14
14
  File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
15
15
  fp.puts "#!/usr/bin/ruby"
@@ -39,7 +39,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
39
39
  end
40
40
 
41
41
  def test_execute_all
42
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
42
+ a = quick_spec 'a' do |s| s.executables = %w[foo] end
43
43
  FileUtils.mkdir_p File.join(@tempdir, 'bin')
44
44
  File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
45
45
  fp.puts "#!/usr/bin/ruby"
@@ -67,15 +67,29 @@ class TestGemCommandsPristineCommand < Gem::TestCase
67
67
  end
68
68
 
69
69
  def test_execute_missing_cache_gem
70
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
70
+ a = quick_spec 'a' do |s|
71
+ s.executables = %w[foo]
72
+ end
73
+
71
74
  FileUtils.mkdir_p File.join(@tempdir, 'bin')
75
+
72
76
  File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
73
77
  fp.puts "#!/usr/bin/ruby"
74
78
  end
75
79
 
76
80
  install_gem a
77
81
 
78
- FileUtils.rm File.join(@gemhome, 'cache', a.file_name)
82
+ a_data = nil
83
+ open File.join(@gemhome, 'cache', a.file_name), 'rb' do |fp|
84
+ a_data = fp.read
85
+ end
86
+
87
+ util_setup_fake_fetcher
88
+ util_setup_spec_fetcher a
89
+
90
+ Gem::RemoteFetcher.fetcher.data["http://gems.example.com/gems/#{a.file_name}"] = a_data
91
+
92
+ FileUtils.rm Gem.cache_gem(a.file_name, @gemhome)
79
93
 
80
94
  @cmd.options[:args] = %w[a]
81
95
 
@@ -85,11 +99,17 @@ class TestGemCommandsPristineCommand < Gem::TestCase
85
99
 
86
100
  out = @ui.output.split "\n"
87
101
 
88
- assert_equal "Restoring gem\(s\) to pristine condition...", out.shift
89
- assert_empty out, out.inspect
102
+ [
103
+ "Restoring gem\(s\) to pristine condition...",
104
+ "Restored a-1",
105
+ "Cached gem for a-2 not found, attempting to fetch...",
106
+ "Restored a-2",
107
+ "Restored a-3.a"
108
+ ].each do |line|
109
+ assert_equal line, out.shift
110
+ end
90
111
 
91
- assert_equal "ERROR: Cached gem for #{a.full_name} not found, use `gem install` to restore\n",
92
- @ui.error
112
+ assert_empty out, out.inspect
93
113
  end
94
114
 
95
115
  def test_execute_no_gem
@@ -1,16 +1,28 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/commands/push_command'
3
3
 
4
+ module Gem
5
+ class << self; remove_method :latest_rubygems_version; end
6
+
7
+ def self.latest_rubygems_version
8
+ Gem::Version.new Gem::VERSION
9
+ end
10
+ end
11
+
4
12
  class TestGemCommandsPushCommand < Gem::TestCase
5
13
 
6
14
  def setup
7
15
  super
8
16
 
9
- @gems_dir = File.join @tempdir, 'gems'
10
- @cache_dir = File.join @gemhome, 'cache'
17
+ @gems_dir = File.join @tempdir, 'gems'
18
+ @cache_dir = Gem.cache_dir @gemhome
19
+
11
20
  FileUtils.mkdir @gems_dir
12
- Gem.configuration.rubygems_api_key = "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
13
- @spec, @path = util_gem("freewill", "1.0.0")
21
+
22
+ Gem.configuration.rubygems_api_key =
23
+ "ed244fbf2b1a52e012da8616c512fa47f9aa5250"
24
+
25
+ @spec, @path = util_gem "freewill", "1.0.0"
14
26
 
15
27
  @fetcher = Gem::FakeFetcher.new
16
28
  Gem::RemoteFetcher.fetcher = @fetcher
@@ -77,5 +89,19 @@ class TestGemCommandsPushCommand < Gem::TestCase
77
89
  assert_match response, @ui.output
78
90
  end
79
91
 
80
- end
92
+ def test_sending_gem_key
93
+ @response = "Successfully registered gem: freewill (1.0.0)"
94
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, "OK"]
95
+ File.open Gem.configuration.credentials_path, 'a' do |f|
96
+ f.write ':other: 701229f217cdf23b1344c7b4b54ca97'
97
+ end
98
+ Gem.configuration.load_api_keys
99
+
100
+ @cmd.handle_options %w(-k other)
101
+ @cmd.send_gem(@path)
81
102
 
103
+ assert_equal Gem.configuration.api_keys[:other],
104
+ @fetcher.last_request["Authorization"]
105
+ end
106
+
107
+ end