rubygems-update 1.1.1 → 1.2.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 (152) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +267 -1
  3. data/Rakefile +13 -7
  4. data/doc/release_notes/rel_1_2_0.rdoc +105 -0
  5. data/lib/rubygems.rb +82 -14
  6. data/lib/rubygems/command.rb +1 -1
  7. data/lib/rubygems/command_manager.rb +3 -2
  8. data/lib/rubygems/commands/cert_command.rb +1 -1
  9. data/lib/rubygems/commands/dependency_command.rb +57 -19
  10. data/lib/rubygems/commands/environment_command.rb +2 -0
  11. data/lib/rubygems/commands/fetch_command.rb +3 -1
  12. data/lib/rubygems/commands/install_command.rb +3 -3
  13. data/lib/rubygems/commands/list_command.rb +30 -28
  14. data/lib/rubygems/commands/lock_command.rb +1 -1
  15. data/lib/rubygems/commands/outdated_command.rb +5 -2
  16. data/lib/rubygems/commands/pristine_command.rb +3 -44
  17. data/lib/rubygems/commands/query_command.rb +80 -21
  18. data/lib/rubygems/commands/sources_command.rb +56 -28
  19. data/lib/rubygems/commands/specification_command.rb +4 -3
  20. data/lib/rubygems/commands/stale_command.rb +27 -0
  21. data/lib/rubygems/commands/update_command.rb +35 -22
  22. data/lib/rubygems/config_file.rb +29 -12
  23. data/lib/rubygems/custom_require.rb +1 -1
  24. data/lib/rubygems/defaults.rb +1 -1
  25. data/lib/rubygems/dependency.rb +63 -9
  26. data/lib/rubygems/dependency_installer.rb +60 -23
  27. data/lib/rubygems/dependency_list.rb +1 -1
  28. data/lib/rubygems/doc_manager.rb +5 -5
  29. data/lib/rubygems/gem_openssl.rb +1 -1
  30. data/lib/rubygems/indexer.rb +269 -84
  31. data/lib/rubygems/install_update_options.rb +6 -0
  32. data/lib/rubygems/installer.rb +35 -12
  33. data/lib/rubygems/local_remote_options.rb +26 -5
  34. data/lib/rubygems/platform.rb +15 -1
  35. data/lib/rubygems/remote_fetcher.rb +158 -90
  36. data/lib/rubygems/requirement.rb +16 -12
  37. data/lib/rubygems/rubygems_version.rb +1 -1
  38. data/lib/rubygems/security.rb +2 -2
  39. data/lib/rubygems/server.rb +239 -110
  40. data/lib/rubygems/source_index.rb +44 -18
  41. data/lib/rubygems/source_info_cache.rb +1 -1
  42. data/lib/rubygems/spec_fetcher.rb +251 -0
  43. data/lib/rubygems/specification.rb +120 -38
  44. data/lib/rubygems/test_utilities.rb +120 -0
  45. data/lib/rubygems/uninstaller.rb +11 -10
  46. data/lib/rubygems/user_interaction.rb +149 -74
  47. data/lib/rubygems/validator.rb +3 -3
  48. data/lib/rubygems/version.rb +23 -21
  49. data/setup.rb +105 -100
  50. data/test/gemutilities.rb +63 -86
  51. data/test/test_config.rb +0 -5
  52. data/test/test_gem.rb +22 -2
  53. data/test/test_gem_command_manager.rb +1 -1
  54. data/test/test_gem_commands_dependency_command.rb +125 -6
  55. data/test/test_gem_commands_environment_command.rb +1 -0
  56. data/test/test_gem_commands_fetch_command.rb +24 -4
  57. data/test/test_gem_commands_install_command.rb +6 -8
  58. data/test/{test_gem_outdated_command.rb → test_gem_commands_outdated_command.rb} +5 -2
  59. data/test/test_gem_commands_pristine_command.rb +13 -4
  60. data/test/test_gem_commands_query_command.rb +113 -37
  61. data/test/test_gem_commands_sources_command.rb +101 -31
  62. data/test/test_gem_commands_specification_command.rb +4 -1
  63. data/test/test_gem_commands_stale_command.rb +39 -0
  64. data/test/test_gem_commands_update_command.rb +17 -27
  65. data/test/test_gem_config_file.rb +38 -1
  66. data/test/test_gem_dependency.rb +51 -0
  67. data/test/test_gem_dependency_installer.rb +133 -25
  68. data/test/test_gem_gem_path_searcher.rb +4 -1
  69. data/test/test_gem_indexer.rb +124 -19
  70. data/test/test_gem_installer.rb +32 -2
  71. data/test/test_gem_local_remote_options.rb +6 -5
  72. data/test/test_gem_remote_fetcher.rb +14 -9
  73. data/test/test_gem_server.rb +207 -21
  74. data/test/test_gem_source_index.rb +203 -63
  75. data/test/test_gem_source_info_cache.rb +8 -6
  76. data/test/test_gem_source_info_cache_entry.rb +11 -9
  77. data/test/test_gem_spec_fetcher.rb +303 -0
  78. data/test/test_gem_specification.rb +91 -7
  79. data/test/test_gem_uninstaller.rb +21 -0
  80. data/test/test_gem_version.rb +14 -5
  81. data/test/test_kernel.rb +1 -1
  82. metadata +10 -73
  83. metadata.gz.sig +0 -0
  84. data/lib/rubygems/indexer/abstract_index_builder.rb +0 -88
  85. data/lib/rubygems/indexer/latest_index_builder.rb +0 -35
  86. data/lib/rubygems/indexer/marshal_index_builder.rb +0 -17
  87. data/lib/rubygems/indexer/master_index_builder.rb +0 -54
  88. data/lib/rubygems/indexer/quick_index_builder.rb +0 -50
  89. data/test/gem_installer_test_case.rbc +0 -0
  90. data/test/gem_package_tar_test_case.rbc +0 -0
  91. data/test/gemutilities.rbc +0 -0
  92. data/test/mockgemui.rbc +0 -0
  93. data/test/simple_gem.rbc +0 -0
  94. data/test/test_config.rbc +0 -0
  95. data/test/test_gem.rbc +0 -0
  96. data/test/test_gem_builder.rbc +0 -0
  97. data/test/test_gem_command.rbc +0 -0
  98. data/test/test_gem_command_manager.rbc +0 -0
  99. data/test/test_gem_commands_build_command.rbc +0 -0
  100. data/test/test_gem_commands_cert_command.rbc +0 -0
  101. data/test/test_gem_commands_check_command.rbc +0 -0
  102. data/test/test_gem_commands_contents_command.rbc +0 -0
  103. data/test/test_gem_commands_dependency_command.rbc +0 -0
  104. data/test/test_gem_commands_environment_command.rbc +0 -0
  105. data/test/test_gem_commands_fetch_command.rbc +0 -0
  106. data/test/test_gem_commands_generate_index_command.rbc +0 -0
  107. data/test/test_gem_commands_install_command.rbc +0 -0
  108. data/test/test_gem_commands_mirror_command.rbc +0 -0
  109. data/test/test_gem_commands_pristine_command.rbc +0 -0
  110. data/test/test_gem_commands_query_command.rbc +0 -0
  111. data/test/test_gem_commands_server_command.rbc +0 -0
  112. data/test/test_gem_commands_sources_command.rbc +0 -0
  113. data/test/test_gem_commands_specification_command.rbc +0 -0
  114. data/test/test_gem_commands_unpack_command.rbc +0 -0
  115. data/test/test_gem_commands_update_command.rbc +0 -0
  116. data/test/test_gem_config_file.rbc +0 -0
  117. data/test/test_gem_dependency.rbc +0 -0
  118. data/test/test_gem_dependency_installer.rbc +0 -0
  119. data/test/test_gem_dependency_list.rbc +0 -0
  120. data/test/test_gem_digest.rbc +0 -0
  121. data/test/test_gem_doc_manager.rbc +0 -0
  122. data/test/test_gem_ext_configure_builder.rbc +0 -0
  123. data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
  124. data/test/test_gem_ext_rake_builder.rbc +0 -0
  125. data/test/test_gem_format.rbc +0 -0
  126. data/test/test_gem_gem_path_searcher.rbc +0 -0
  127. data/test/test_gem_gem_runner.rbc +0 -0
  128. data/test/test_gem_indexer.rbc +0 -0
  129. data/test/test_gem_install_update_options.rbc +0 -0
  130. data/test/test_gem_installer.rbc +0 -0
  131. data/test/test_gem_local_remote_options.rbc +0 -0
  132. data/test/test_gem_outdated_command.rbc +0 -0
  133. data/test/test_gem_package_tar_header.rbc +0 -0
  134. data/test/test_gem_package_tar_input.rbc +0 -0
  135. data/test/test_gem_package_tar_output.rbc +0 -0
  136. data/test/test_gem_package_tar_reader.rbc +0 -0
  137. data/test/test_gem_package_tar_reader_entry.rbc +0 -0
  138. data/test/test_gem_package_tar_writer.rbc +0 -0
  139. data/test/test_gem_platform.rbc +0 -0
  140. data/test/test_gem_remote_fetcher.rbc +0 -0
  141. data/test/test_gem_requirement.rbc +0 -0
  142. data/test/test_gem_server.rbc +0 -0
  143. data/test/test_gem_source_index.rbc +0 -0
  144. data/test/test_gem_source_info_cache.rbc +0 -0
  145. data/test/test_gem_source_info_cache_entry.rbc +0 -0
  146. data/test/test_gem_specification.rbc +0 -0
  147. data/test/test_gem_stream_ui.rbc +0 -0
  148. data/test/test_gem_uninstaller.rbc +0 -0
  149. data/test/test_gem_validator.rbc +0 -0
  150. data/test/test_gem_version.rbc +0 -0
  151. data/test/test_gem_version_option.rbc +0 -0
  152. data/test/test_kernel.rbc +0 -0
@@ -12,11 +12,6 @@ require 'rubygems'
12
12
 
13
13
  class TestConfig < RubyGemTestCase
14
14
 
15
- def test_gem_original_datadir
16
- datadir = Config::CONFIG['datadir']
17
- assert_equal "#{datadir}/xyz", Config.gem_original_datadir('xyz')
18
- end
19
-
20
15
  def test_datadir
21
16
  datadir = Config::CONFIG['datadir']
22
17
  assert_equal "#{datadir}/xyz", Config.datadir('xyz')
@@ -28,6 +28,14 @@ class TestGem < RubyGemTestCase
28
28
  assert_equal expected, Gem.all_load_paths.sort
29
29
  end
30
30
 
31
+ def test_self_available?
32
+ util_make_gems
33
+ assert(Gem.available?("a"))
34
+ assert(Gem.available?("a", "1"))
35
+ assert(Gem.available?("a", ">1"))
36
+ assert(!Gem.available?("monkeys"))
37
+ end
38
+
31
39
  def test_self_bindir
32
40
  assert_equal File.join(@gemhome, 'bin'), Gem.bindir
33
41
  assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
@@ -129,7 +137,7 @@ class TestGem < RubyGemTestCase
129
137
  end
130
138
 
131
139
  def test_self_default_sources
132
- assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
140
+ assert_equal %w[http://gems.rubyforge.org/], Gem.default_sources
133
141
  end
134
142
 
135
143
  def test_self_dir
@@ -237,6 +245,18 @@ class TestGem < RubyGemTestCase
237
245
  assert_equal [Gem.dir], Gem.path
238
246
  end
239
247
 
248
+ def test_self_path_default
249
+ if defined? APPLE_GEM_HOME
250
+ orig_APPLE_GEM_HOME = APPLE_GEM_HOME
251
+ Object.send :remove_const, :APPLE_GEM_HOME
252
+ end
253
+ Gem.instance_variable_set :@gem_path, nil
254
+
255
+ assert_equal [Gem.default_path, Gem.dir].flatten, Gem.path
256
+ ensure
257
+ Object.const_set :APPLE_GEM_HOME, orig_APPLE_GEM_HOME
258
+ end
259
+
240
260
  unless win_platform?
241
261
  def test_self_path_APPLE_GEM_HOME
242
262
  Gem.clear_paths
@@ -382,7 +402,7 @@ class TestGem < RubyGemTestCase
382
402
  end
383
403
 
384
404
  def test_self_sources
385
- assert_equal %w[http://gems.example.com], Gem.sources
405
+ assert_equal %w[http://gems.example.com/], Gem.sources
386
406
  end
387
407
 
388
408
  def test_ssl_available_eh
@@ -66,7 +66,7 @@ class TestGemCommandManager < RubyGemTestCase
66
66
  assert_equal :both, check_options[:domain]
67
67
  assert_equal true, check_options[:wrappers]
68
68
  assert_equal Gem::Requirement.default, check_options[:version]
69
- assert_equal Gem.dir, check_options[:install_dir]
69
+ assert_equal nil, check_options[:install_dir]
70
70
  assert_equal nil, check_options[:bin_dir]
71
71
 
72
72
  #check settings
@@ -9,6 +9,8 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
9
9
 
10
10
  @cmd = Gem::Commands::DependencyCommand.new
11
11
  @cmd.options[:domain] = :local
12
+
13
+ util_setup_fake_fetcher
12
14
  end
13
15
 
14
16
  def test_execute
@@ -16,13 +18,43 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
16
18
  gem.add_dependency 'bar', '> 1'
17
19
  end
18
20
 
21
+ Gem.source_index = nil
22
+
19
23
  @cmd.options[:args] = %w[foo]
20
24
 
21
25
  use_ui @ui do
22
26
  @cmd.execute
23
27
  end
24
28
 
25
- assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
29
+ assert_equal "Gem foo-2\n bar (> 1, runtime)\n\n", @ui.output
30
+ assert_equal '', @ui.error
31
+ end
32
+
33
+ def test_execute_no_args
34
+ Gem.source_index = nil
35
+
36
+ @cmd.options[:args] = []
37
+
38
+ use_ui @ui do
39
+ @cmd.execute
40
+ end
41
+
42
+ expected = <<-EOF
43
+ Gem a-1
44
+
45
+ Gem a-2
46
+
47
+ Gem a_evil-9
48
+
49
+ Gem b-2
50
+
51
+ Gem c-1.2
52
+
53
+ Gem pl-1-x86-linux
54
+
55
+ EOF
56
+
57
+ assert_equal expected, @ui.output
26
58
  assert_equal '', @ui.error
27
59
  end
28
60
 
@@ -35,7 +67,7 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
35
67
  end
36
68
  end
37
69
 
38
- assert_equal "No match found for foo (>= 0)\n", @ui.output
70
+ assert_equal "No gems found matching foo (>= 0)\n", @ui.output
39
71
  assert_equal '', @ui.error
40
72
  end
41
73
 
@@ -55,6 +87,30 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
55
87
  assert_equal '', @ui.error
56
88
  end
57
89
 
90
+ def test_execute_regexp
91
+ Gem.source_index = nil
92
+
93
+ @cmd.options[:args] = %w[/[ab]/]
94
+
95
+ use_ui @ui do
96
+ @cmd.execute
97
+ end
98
+
99
+ expected = <<-EOF
100
+ Gem a-1
101
+
102
+ Gem a-2
103
+
104
+ Gem a_evil-9
105
+
106
+ Gem b-2
107
+
108
+ EOF
109
+
110
+ assert_equal expected, @ui.output
111
+ assert_equal '', @ui.error
112
+ end
113
+
58
114
  def test_execute_reverse
59
115
  quick_gem 'foo' do |gem|
60
116
  gem.add_dependency 'bar', '> 1'
@@ -64,6 +120,8 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
64
120
  gem.add_dependency 'foo'
65
121
  end
66
122
 
123
+ Gem.source_index = nil
124
+
67
125
  @cmd.options[:args] = %w[foo]
68
126
  @cmd.options[:reverse_dependencies] = true
69
127
 
@@ -73,9 +131,9 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
73
131
 
74
132
  expected = <<-EOF
75
133
  Gem foo-2
76
- bar (> 1)
134
+ bar (> 1, runtime)
77
135
  Used by
78
- baz-2 (foo (>= 0))
136
+ baz-2 (foo (>= 0, runtime))
79
137
 
80
138
  EOF
81
139
 
@@ -83,12 +141,34 @@ Gem foo-2
83
141
  assert_equal '', @ui.error
84
142
  end
85
143
 
144
+ def test_execute_reverse_remote
145
+ @cmd.options[:args] = %w[foo]
146
+ @cmd.options[:reverse_dependencies] = true
147
+ @cmd.options[:domain] = :remote
148
+
149
+ assert_raise MockGemUi::TermError do
150
+ use_ui @ui do
151
+ @cmd.execute
152
+ end
153
+ end
154
+
155
+ expected = <<-EOF
156
+ ERROR: Only reverse dependencies for local gems are supported.
157
+ EOF
158
+
159
+ assert_equal '', @ui.output
160
+ assert_equal expected, @ui.error
161
+ end
162
+
86
163
  def test_execute_remote
87
164
  foo = quick_gem 'foo' do |gem|
88
165
  gem.add_dependency 'bar', '> 1'
89
166
  end
90
167
 
91
- util_setup_source_info_cache foo
168
+ @fetcher = Gem::FakeFetcher.new
169
+ Gem::RemoteFetcher.fetcher = @fetcher
170
+
171
+ util_setup_spec_fetcher foo
92
172
 
93
173
  FileUtils.rm File.join(@gemhome, 'specifications',
94
174
  "#{foo.full_name}.gemspec")
@@ -100,9 +180,48 @@ Gem foo-2
100
180
  @cmd.execute
101
181
  end
102
182
 
103
- assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
183
+ assert_equal "Gem foo-2\n bar (> 1, runtime)\n\n", @ui.output
104
184
  assert_equal '', @ui.error
105
185
  end
106
186
 
187
+ def test_execute_remote_legacy
188
+ foo = quick_gem 'foo' do |gem|
189
+ gem.add_dependency 'bar', '> 1'
190
+ end
191
+
192
+ @fetcher = Gem::FakeFetcher.new
193
+ Gem::RemoteFetcher.fetcher = @fetcher
194
+
195
+ Gem::SpecFetcher.fetcher = nil
196
+ si = util_setup_source_info_cache foo
197
+
198
+ @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
199
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
200
+ si.dump
201
+
202
+ @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
203
+
204
+ FileUtils.rm File.join(@gemhome, 'specifications',
205
+ "#{foo.full_name}.gemspec")
206
+
207
+ @cmd.options[:args] = %w[foo]
208
+ @cmd.options[:domain] = :remote
209
+
210
+ use_ui @ui do
211
+ @cmd.execute
212
+ end
213
+
214
+ assert_equal "Gem foo-2\n bar (> 1, runtime)\n\n", @ui.output
215
+
216
+ expected = <<-EOF
217
+ WARNING: RubyGems 1.2+ index not found for:
218
+ \t#{@gem_repo}
219
+
220
+ RubyGems will revert to legacy indexes degrading performance.
221
+ EOF
222
+
223
+ assert_equal expected, @ui.error
224
+ end
225
+
107
226
  end
108
227
 
@@ -27,6 +27,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
27
27
  assert_match %r|RUBYGEMS PREFIX: |, @ui.output
28
28
  assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:RUBY_INSTALL_NAME]}|,
29
29
  @ui.output
30
+ assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
30
31
  assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
31
32
  assert_match %r|- #{Gem::Platform.local}|, @ui.output
32
33
  assert_match %r|GEM PATHS:|, @ui.output
@@ -14,10 +14,9 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
14
14
 
15
15
  def test_execute
16
16
  util_setup_fake_fetcher
17
+ util_setup_spec_fetcher @a2
17
18
 
18
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
19
- @source_index.dump
20
- @fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] =
19
+ @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
21
20
  File.read(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
22
21
 
23
22
  @cmd.options[:args] = [@a2.name]
@@ -28,7 +27,28 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
28
27
  end
29
28
  end
30
29
 
31
- assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem"))
30
+ assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem")),
31
+ "#{@a2.full_name} fetched"
32
+ end
33
+
34
+ def test_execute_legacy
35
+ util_setup_fake_fetcher
36
+ util_setup_source_info_cache @a2
37
+
38
+ @fetcher.data["#{@gem_repo}yaml"] = ''
39
+ @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
40
+ File.read(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
41
+
42
+ @cmd.options[:args] = [@a2.name]
43
+
44
+ use_ui @ui do
45
+ Dir.chdir @tempdir do
46
+ @cmd.execute
47
+ end
48
+ end
49
+
50
+ assert File.exist?(File.join(@tempdir, "#{@a2.full_name}.gem")),
51
+ "#{@a2.full_name} fetched"
32
52
  end
33
53
 
34
54
  end
@@ -72,7 +72,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
72
72
  end
73
73
 
74
74
  # HACK no repository was checked
75
- assert_equal "ERROR: could not find no_such_gem locally or in a repository\n",
75
+ assert_equal "ERROR: could not find gem no_such_gem locally or in a repository\n",
76
76
  @ui.error
77
77
  end
78
78
 
@@ -86,8 +86,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
86
86
 
87
87
  def test_execute_nonexistent
88
88
  util_setup_fake_fetcher
89
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
90
- @source_index.dump
89
+ util_setup_spec_fetcher
91
90
 
92
91
  @cmd.options[:args] = %w[nonexistent]
93
92
 
@@ -98,18 +97,18 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
98
97
  assert_equal 2, e.exit_code
99
98
  end
100
99
 
101
- assert_equal "ERROR: could not find nonexistent locally or in a repository\n",
100
+ assert_equal "ERROR: could not find gem nonexistent locally or in a repository\n",
102
101
  @ui.error
103
102
  end
104
103
 
105
104
  def test_execute_remote
106
105
  @cmd.options[:generate_rdoc] = true
107
106
  @cmd.options[:generate_ri] = true
107
+
108
108
  util_setup_fake_fetcher
109
+ util_setup_spec_fetcher @a2
109
110
 
110
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
111
- @source_index.dump
112
- @fetcher.data["#{@gem_repo}/gems/#{@a2.full_name}.gem"] =
111
+ @fetcher.data["#{@gem_repo}gems/#{@a2.full_name}.gem"] =
113
112
  read_binary(File.join(@gemhome, 'cache', "#{@a2.full_name}.gem"))
114
113
 
115
114
  @cmd.options[:args] = [@a2.name]
@@ -122,7 +121,6 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
122
121
  end
123
122
 
124
123
  out = @ui.output.split "\n"
125
- assert_match %r|Bulk updating|, out.shift
126
124
  assert_equal "Successfully installed #{@a2.full_name}", out.shift
127
125
  assert_equal "1 gem installed", out.shift
128
126
  assert_equal "Installing ri documentation for #{@a2.full_name}...",
@@ -2,7 +2,7 @@ require 'test/unit'
2
2
  require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3
3
  require 'rubygems/commands/outdated_command'
4
4
 
5
- class TestGemOutdatedCommand < RubyGemTestCase
5
+ class TestGemCommandsOutdatedCommand < RubyGemTestCase
6
6
 
7
7
  def setup
8
8
  super
@@ -28,7 +28,10 @@ class TestGemOutdatedCommand < RubyGemTestCase
28
28
  remote_20.full_name + ".gemspec"
29
29
  FileUtils.rm remote_spec_file
30
30
 
31
- util_setup_source_info_cache remote_10, remote_20
31
+ @fetcher = Gem::FakeFetcher.new
32
+ Gem::RemoteFetcher.fetcher = @fetcher
33
+
34
+ util_setup_spec_fetcher remote_10, remote_20
32
35
 
33
36
  use_ui @ui do @cmd.execute end
34
37
 
@@ -18,16 +18,24 @@ class TestGemCommandsPristineCommand < RubyGemTestCase
18
18
 
19
19
  install_gem a
20
20
 
21
+ foo_path = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo'
22
+
23
+ File.open foo_path, 'w' do |io|
24
+ io.puts 'I changed it!'
25
+ end
26
+
21
27
  @cmd.options[:args] = %w[a]
22
28
 
23
29
  use_ui @ui do
24
30
  @cmd.execute
25
31
  end
26
32
 
33
+ assert_equal "#!/usr/bin/ruby\n", File.read(foo_path), foo_path
34
+
27
35
  out = @ui.output.split "\n"
28
36
 
29
37
  assert_equal "Restoring gem(s) to pristine condition...", out.shift
30
- assert_equal "#{a.full_name} is in pristine condition", out.shift
38
+ assert_equal "Restored #{a.full_name}", out.shift
31
39
  assert out.empty?, out.inspect
32
40
  end
33
41
 
@@ -40,7 +48,7 @@ class TestGemCommandsPristineCommand < RubyGemTestCase
40
48
 
41
49
  install_gem a
42
50
 
43
- gem_bin = File.join @gemhome, 'gems', "#{a.full_name}", 'bin', 'foo'
51
+ gem_bin = File.join @gemhome, 'gems', a.full_name, 'bin', 'foo'
44
52
 
45
53
  FileUtils.rm gem_bin
46
54
 
@@ -50,11 +58,12 @@ class TestGemCommandsPristineCommand < RubyGemTestCase
50
58
  @cmd.execute
51
59
  end
52
60
 
61
+ assert File.exist?(gem_bin)
62
+
53
63
  out = @ui.output.split "\n"
54
64
 
55
65
  assert_equal "Restoring gem(s) to pristine condition...", out.shift
56
- assert_equal "Restoring 1 file to #{a.full_name}...", out.shift
57
- assert_equal " #{gem_bin}", out.shift
66
+ assert_equal "Restored #{a.full_name}", out.shift
58
67
  assert out.empty?, out.inspect
59
68
  end
60
69
 
@@ -7,33 +7,18 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
7
7
  def setup
8
8
  super
9
9
 
10
- util_make_gems
11
-
12
- @a2.summary = 'This is a lot of text. ' * 4
13
-
14
10
  @cmd = Gem::Commands::QueryCommand.new
15
11
 
16
- @si = util_setup_source_info_cache @a1, @a2, @pl1
17
12
  util_setup_fake_fetcher
18
13
 
19
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] = proc do
14
+ @si = util_setup_spec_fetcher @a1, @a2, @pl1
15
+
16
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
20
17
  raise Gem::RemoteFetcher::FetchError
21
18
  end
22
19
  end
23
20
 
24
21
  def test_execute
25
- cache = Gem::SourceInfoCache.cache
26
- cache.update
27
- cache.write_cache
28
- cache.reset_cache_data
29
- Gem::SourceInfoCache.reset
30
-
31
- a2_name = @a2.full_name
32
- @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
33
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
34
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
35
- Marshal.dump @si
36
-
37
22
  @cmd.handle_options %w[-r]
38
23
 
39
24
  use_ui @ui do
@@ -44,10 +29,8 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
44
29
 
45
30
  *** REMOTE GEMS ***
46
31
 
47
- Updating metadata for 1 gems from http://gems.example.com/
48
- .
49
- complete
50
32
  a (2)
33
+ pl (1)
51
34
  EOF
52
35
 
53
36
  assert_equal expected, @ui.output
@@ -55,21 +38,8 @@ a (2)
55
38
  end
56
39
 
57
40
  def test_execute_all
58
- cache = Gem::SourceInfoCache.cache
59
- cache.update
60
- cache.write_cache
61
- cache.reset_cache_data
62
- Gem::SourceInfoCache.reset
63
-
64
41
  a1_name = @a1.full_name
65
42
  a2_name = @a2.full_name
66
- @fetcher.data["#{@gem_repo}/quick/index.rz"] =
67
- util_zip [a1_name, a2_name].join("\n")
68
- @fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = util_zip a2_name
69
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a1_name}.gemspec.rz"] = util_zip Marshal.dump(@a1)
70
- @fetcher.data["#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{a2_name}.gemspec.rz"] = util_zip Marshal.dump(@a2)
71
- @fetcher.data["#{@gem_repo}/Marshal.#{Gem.marshal_version}"] =
72
- Marshal.dump @si
73
43
 
74
44
  @cmd.handle_options %w[-r --all]
75
45
 
@@ -81,10 +51,8 @@ a (2)
81
51
 
82
52
  *** REMOTE GEMS ***
83
53
 
84
- Updating metadata for 2 gems from http://gems.example.com/
85
- ..
86
- complete
87
54
  a (2, 1)
55
+ pl (1)
88
56
  EOF
89
57
 
90
58
  assert_equal expected, @ui.output
@@ -92,6 +60,13 @@ a (2, 1)
92
60
  end
93
61
 
94
62
  def test_execute_details
63
+ @a2.summary = 'This is a lot of text. ' * 4
64
+ @a2.authors = ['Abraham Lincoln', 'Hirohito']
65
+ @a2.homepage = 'http://a.example.com/'
66
+ @a2.rubyforge_project = 'rubygems'
67
+
68
+ @si = util_setup_spec_fetcher @a1, @a2, @pl1
69
+
95
70
  @cmd.handle_options %w[-r -d]
96
71
 
97
72
  use_ui @ui do
@@ -103,10 +78,17 @@ a (2, 1)
103
78
  *** REMOTE GEMS ***
104
79
 
105
80
  a (2)
81
+ Authors: Abraham Lincoln, Hirohito
82
+ Rubyforge: http://rubyforge.org/projects/rubygems
83
+ Homepage: http://a.example.com/
84
+
106
85
  This is a lot of text. This is a lot of text. This is a lot of text.
107
86
  This is a lot of text.
108
87
 
109
88
  pl (1)
89
+ Author: A User
90
+ Homepage: http://example.com
91
+
110
92
  this is a summary
111
93
  EOF
112
94
 
@@ -126,6 +108,7 @@ pl (1)
126
108
  assert_equal 0, e.exit_code
127
109
 
128
110
  assert_equal "true\n", @ui.output
111
+
129
112
  assert_equal '', @ui.error
130
113
  end
131
114
 
@@ -189,6 +172,99 @@ pl (1)
189
172
  assert_equal 1, e.exit_code
190
173
  end
191
174
 
175
+ def test_execute_legacy
176
+ Gem::SpecFetcher.fetcher = nil
177
+ si = util_setup_source_info_cache @a1, @a2, @pl1
178
+
179
+ @fetcher.data["#{@gem_repo}yaml"] = YAML.dump si
180
+ @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] =
181
+ si.dump
182
+
183
+ @fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
184
+
185
+ @cmd.handle_options %w[-r]
186
+
187
+ use_ui @ui do
188
+ @cmd.execute
189
+ end
190
+
191
+ expected = <<-EOF
192
+
193
+ *** REMOTE GEMS ***
194
+
195
+ a (2)
196
+ pl (1)
197
+ EOF
198
+
199
+ assert_equal expected, @ui.output
200
+
201
+ expected = <<-EOF
202
+ WARNING: RubyGems 1.2+ index not found for:
203
+ \t#{@gem_repo}
204
+
205
+ RubyGems will revert to legacy indexes degrading performance.
206
+ EOF
207
+
208
+ assert_equal expected, @ui.error
209
+ end
210
+
211
+ def test_execute_local_details
212
+ @a2.summary = 'This is a lot of text. ' * 4
213
+ @a2.authors = ['Abraham Lincoln', 'Hirohito']
214
+ @a2.homepage = 'http://a.example.com/'
215
+ @a2.rubyforge_project = 'rubygems'
216
+
217
+ @cmd.handle_options %w[--local --details]
218
+
219
+ use_ui @ui do
220
+ @cmd.execute
221
+ end
222
+
223
+ expected = <<-EOF
224
+
225
+ *** LOCAL GEMS ***
226
+
227
+ a (2, 1)
228
+ Author: A User
229
+ Homepage: http://example.com
230
+ Installed at (2): #{@gemhome}
231
+ (1): #{@gemhome}
232
+
233
+ this is a summary
234
+
235
+ a_evil (9)
236
+ Author: A User
237
+ Homepage: http://example.com
238
+ Installed at: #{@gemhome}
239
+
240
+ this is a summary
241
+
242
+ b (2)
243
+ Author: A User
244
+ Homepage: http://example.com
245
+ Installed at: #{@gemhome}
246
+
247
+ this is a summary
248
+
249
+ c (1.2)
250
+ Author: A User
251
+ Homepage: http://example.com
252
+ Installed at: #{@gemhome}
253
+
254
+ this is a summary
255
+
256
+ pl (1)
257
+ Author: A User
258
+ Homepage: http://example.com
259
+ Installed at: #{@gemhome}
260
+
261
+ this is a summary
262
+ EOF
263
+
264
+ assert_equal expected, @ui.output
265
+ assert_equal '', @ui.error
266
+ end
267
+
192
268
  def test_execute_no_versions
193
269
  @cmd.handle_options %w[-r --no-versions]
194
270