rubygems-update 1.4.2 → 1.5.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 (150) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +4 -5
  3. data/{test/foo/discover.rb → .gemtest} +0 -0
  4. data/ChangeLog +13 -0
  5. data/History.txt +35 -1
  6. data/Manifest.txt +89 -88
  7. data/README.rdoc +21 -10
  8. data/Rakefile +31 -17
  9. data/UPGRADING.rdoc +81 -0
  10. data/ci_build.sh +27 -0
  11. data/cruise_config.rb +20 -13
  12. data/lib/rbconfig/datadir.rb +1 -1
  13. data/lib/rubygems.rb +102 -45
  14. data/lib/rubygems/builder.rb +5 -11
  15. data/lib/rubygems/command_manager.rb +0 -1
  16. data/lib/rubygems/commands/check_command.rb +2 -17
  17. data/lib/rubygems/commands/cleanup_command.rb +1 -1
  18. data/lib/rubygems/commands/dependency_command.rb +5 -18
  19. data/lib/rubygems/commands/environment_command.rb +5 -4
  20. data/lib/rubygems/commands/fetch_command.rb +0 -1
  21. data/lib/rubygems/commands/generate_index_command.rb +1 -10
  22. data/lib/rubygems/commands/help_command.rb +0 -5
  23. data/lib/rubygems/commands/query_command.rb +4 -24
  24. data/lib/rubygems/commands/setup_command.rb +4 -19
  25. data/lib/rubygems/commands/sources_command.rb +15 -37
  26. data/lib/rubygems/commands/specification_command.rb +1 -2
  27. data/lib/rubygems/commands/unpack_command.rb +19 -7
  28. data/lib/rubygems/commands/update_command.rb +29 -44
  29. data/lib/rubygems/config_file.rb +25 -19
  30. data/lib/rubygems/custom_require.rb +4 -6
  31. data/lib/rubygems/dependency.rb +1 -43
  32. data/lib/rubygems/dependency_installer.rb +1 -1
  33. data/lib/rubygems/doc_manager.rb +3 -1
  34. data/lib/rubygems/ext/builder.rb +3 -1
  35. data/lib/rubygems/ext/rake_builder.rb +10 -2
  36. data/lib/rubygems/format.rb +7 -4
  37. data/lib/rubygems/gem_runner.rb +1 -1
  38. data/lib/rubygems/indexer.rb +11 -74
  39. data/lib/rubygems/install_update_options.rb +13 -8
  40. data/lib/rubygems/installer.rb +139 -95
  41. data/{test/gem_installer_test_case.rb → lib/rubygems/installer_test_case.rb} +41 -2
  42. data/{test/mockgemui.rb → lib/rubygems/mock_gem_ui.rb} +8 -1
  43. data/lib/rubygems/old_format.rb +2 -1
  44. data/lib/rubygems/package.rb +17 -2
  45. data/lib/rubygems/package/tar_input.rb +7 -3
  46. data/lib/rubygems/package/tar_output.rb +2 -0
  47. data/lib/rubygems/package/tar_reader/entry.rb +4 -0
  48. data/{test/gem_package_tar_test_case.rb → lib/rubygems/package/tar_test_case.rb} +5 -2
  49. data/lib/rubygems/package_task.rb +6 -4
  50. data/lib/rubygems/remote_fetcher.rb +10 -2
  51. data/lib/rubygems/require_paths_builder.rb +2 -1
  52. data/lib/rubygems/server.rb +3 -44
  53. data/lib/rubygems/source_index.rb +3 -216
  54. data/lib/rubygems/spec_fetcher.rb +15 -63
  55. data/lib/rubygems/specification.rb +1 -1
  56. data/{test/gemutilities.rb → lib/rubygems/test_case.rb} +219 -90
  57. data/lib/rubygems/test_utilities.rb +7 -20
  58. data/lib/rubygems/uninstaller.rb +27 -28
  59. data/lib/rubygems/user_interaction.rb +81 -42
  60. data/lib/rubygems/validator.rb +0 -73
  61. data/test/{bogussources.rb → rubygems/bogussources.rb} +0 -0
  62. data/test/{data → rubygems/data}/gem-private_key.pem +0 -0
  63. data/test/{data → rubygems/data}/gem-public_cert.pem +0 -0
  64. data/test/{fake_certlib → rubygems/fake_certlib}/openssl.rb +0 -0
  65. data/test/rubygems/foo/discover.rb +0 -0
  66. data/test/{functional.rb → rubygems/functional.rb} +0 -0
  67. data/test/{insure_session.rb → rubygems/insure_session.rb} +0 -0
  68. data/test/{plugin → rubygems/plugin}/exception/rubygems_plugin.rb +0 -0
  69. data/test/{plugin → rubygems/plugin}/load/rubygems_plugin.rb +0 -0
  70. data/test/{plugin → rubygems/plugin}/standarderror/rubygems_plugin.rb +0 -0
  71. data/test/{private_key.pem → rubygems/private_key.pem} +0 -0
  72. data/test/{public_cert.pem → rubygems/public_cert.pem} +0 -0
  73. data/test/rubygems/{commands → rubygems/commands}/crash_command.rb +0 -0
  74. data/test/{rubygems_plugin.rb → rubygems/rubygems_plugin.rb} +0 -0
  75. data/test/rubygems/sff/discover.rb +0 -0
  76. data/test/{simple_gem.rb → rubygems/simple_gem.rb} +2 -2
  77. data/test/{test_config.rb → rubygems/test_config.rb} +2 -2
  78. data/test/{test_gem.rb → rubygems/test_gem.rb} +12 -2
  79. data/test/{test_gem_builder.rb → rubygems/test_gem_builder.rb} +2 -2
  80. data/test/{test_gem_command.rb → rubygems/test_gem_command.rb} +3 -3
  81. data/test/{test_gem_command_manager.rb → rubygems/test_gem_command_manager.rb} +15 -6
  82. data/test/{test_gem_commands_build_command.rb → rubygems/test_gem_commands_build_command.rb} +2 -2
  83. data/test/{test_gem_commands_cert_command.rb → rubygems/test_gem_commands_cert_command.rb} +2 -2
  84. data/test/{test_gem_commands_check_command.rb → rubygems/test_gem_commands_check_command.rb} +2 -2
  85. data/test/{test_gem_commands_contents_command.rb → rubygems/test_gem_commands_contents_command.rb} +3 -3
  86. data/test/{test_gem_commands_dependency_command.rb → rubygems/test_gem_commands_dependency_command.rb} +4 -4
  87. data/test/{test_gem_commands_environment_command.rb → rubygems/test_gem_commands_environment_command.rb} +12 -3
  88. data/test/{test_gem_commands_fetch_command.rb → rubygems/test_gem_commands_fetch_command.rb} +2 -2
  89. data/test/{test_gem_commands_generate_index_command.rb → rubygems/test_gem_commands_generate_index_command.rb} +7 -11
  90. data/test/{test_gem_commands_install_command.rb → rubygems/test_gem_commands_install_command.rb} +2 -2
  91. data/test/{test_gem_commands_list_command.rb → rubygems/test_gem_commands_list_command.rb} +2 -2
  92. data/test/{test_gem_commands_lock_command.rb → rubygems/test_gem_commands_lock_command.rb} +2 -2
  93. data/test/{test_gem_commands_outdated_command.rb → rubygems/test_gem_commands_outdated_command.rb} +2 -2
  94. data/test/{test_gem_commands_owner_command.rb → rubygems/test_gem_commands_owner_command.rb} +5 -5
  95. data/test/{test_gem_commands_pristine_command.rb → rubygems/test_gem_commands_pristine_command.rb} +2 -2
  96. data/test/{test_gem_commands_push_command.rb → rubygems/test_gem_commands_push_command.rb} +3 -3
  97. data/test/{test_gem_commands_query_command.rb → rubygems/test_gem_commands_query_command.rb} +2 -2
  98. data/test/{test_gem_commands_server_command.rb → rubygems/test_gem_commands_server_command.rb} +2 -2
  99. data/test/{test_gem_commands_sources_command.rb → rubygems/test_gem_commands_sources_command.rb} +8 -8
  100. data/test/{test_gem_commands_specification_command.rb → rubygems/test_gem_commands_specification_command.rb} +3 -3
  101. data/test/{test_gem_commands_stale_command.rb → rubygems/test_gem_commands_stale_command.rb} +2 -2
  102. data/test/{test_gem_commands_uninstall_command.rb → rubygems/test_gem_commands_uninstall_command.rb} +16 -10
  103. data/test/{test_gem_commands_unpack_command.rb → rubygems/test_gem_commands_unpack_command.rb} +42 -2
  104. data/test/{test_gem_commands_update_command.rb → rubygems/test_gem_commands_update_command.rb} +2 -2
  105. data/test/{test_gem_commands_which_command.rb → rubygems/test_gem_commands_which_command.rb} +3 -3
  106. data/test/{test_gem_config_file.rb → rubygems/test_gem_config_file.rb} +2 -2
  107. data/test/{test_gem_dependency.rb → rubygems/test_gem_dependency.rb} +3 -27
  108. data/test/{test_gem_dependency_installer.rb → rubygems/test_gem_dependency_installer.rb} +2 -2
  109. data/test/{test_gem_dependency_list.rb → rubygems/test_gem_dependency_list.rb} +3 -3
  110. data/test/{test_gem_doc_manager.rb → rubygems/test_gem_doc_manager.rb} +2 -2
  111. data/test/{test_gem_ext_configure_builder.rb → rubygems/test_gem_ext_configure_builder.rb} +4 -4
  112. data/test/{test_gem_ext_ext_conf_builder.rb → rubygems/test_gem_ext_ext_conf_builder.rb} +46 -2
  113. data/test/{test_gem_ext_rake_builder.rb → rubygems/test_gem_ext_rake_builder.rb} +2 -2
  114. data/test/{test_gem_format.rb → rubygems/test_gem_format.rb} +24 -6
  115. data/test/{test_gem_gem_path_searcher.rb → rubygems/test_gem_gem_path_searcher.rb} +2 -2
  116. data/test/{test_gem_gem_runner.rb → rubygems/test_gem_gem_runner.rb} +2 -2
  117. data/test/{test_gem_gemcutter_utilities.rb → rubygems/test_gem_gemcutter_utilities.rb} +4 -4
  118. data/test/{test_gem_indexer.rb → rubygems/test_gem_indexer.rb} +4 -121
  119. data/test/{test_gem_install_update_options.rb → rubygems/test_gem_install_update_options.rb} +3 -3
  120. data/test/{test_gem_installer.rb → rubygems/test_gem_installer.rb} +106 -13
  121. data/test/{test_gem_local_remote_options.rb → rubygems/test_gem_local_remote_options.rb} +2 -2
  122. data/test/{test_gem_package_tar_header.rb → rubygems/test_gem_package_tar_header.rb} +2 -2
  123. data/test/{test_gem_package_tar_input.rb → rubygems/test_gem_package_tar_input.rb} +21 -4
  124. data/test/{test_gem_package_tar_output.rb → rubygems/test_gem_package_tar_output.rb} +2 -2
  125. data/test/{test_gem_package_tar_reader.rb → rubygems/test_gem_package_tar_reader.rb} +2 -2
  126. data/test/{test_gem_package_tar_reader_entry.rb → rubygems/test_gem_package_tar_reader_entry.rb} +12 -2
  127. data/test/{test_gem_package_tar_writer.rb → rubygems/test_gem_package_tar_writer.rb} +2 -2
  128. data/test/{test_gem_package_task.rb → rubygems/test_gem_package_task.rb} +15 -2
  129. data/test/{test_gem_platform.rb → rubygems/test_gem_platform.rb} +2 -2
  130. data/test/{test_gem_remote_fetcher.rb → rubygems/test_gem_remote_fetcher.rb} +7 -7
  131. data/test/{test_gem_requirement.rb → rubygems/test_gem_requirement.rb} +2 -2
  132. data/test/{test_gem_security.rb → rubygems/test_gem_security.rb} +3 -4
  133. data/test/{test_gem_server.rb → rubygems/test_gem_server.rb} +2 -132
  134. data/test/rubygems/test_gem_silent_ui.rb +113 -0
  135. data/test/{test_gem_source_index.rb → rubygems/test_gem_source_index.rb} +2 -61
  136. data/test/{test_gem_spec_fetcher.rb → rubygems/test_gem_spec_fetcher.rb} +2 -2
  137. data/test/{test_gem_specification.rb → rubygems/test_gem_specification.rb} +4 -4
  138. data/test/{test_gem_stream_ui.rb → rubygems/test_gem_stream_ui.rb} +24 -2
  139. data/test/{test_gem_text.rb → rubygems/test_gem_text.rb} +2 -2
  140. data/test/{test_gem_uninstaller.rb → rubygems/test_gem_uninstaller.rb} +15 -12
  141. data/test/{test_gem_validator.rb → rubygems/test_gem_validator.rb} +3 -3
  142. data/test/{test_gem_version.rb → rubygems/test_gem_version.rb} +2 -2
  143. data/test/{test_gem_version_option.rb → rubygems/test_gem_version_option.rb} +2 -2
  144. data/test/{test_kernel.rb → rubygems/test_kernel.rb} +7 -10
  145. metadata +281 -177
  146. metadata.gz.sig +0 -0
  147. data/lib/rubygems/commands/mirror_command.rb +0 -111
  148. data/lib/rubygems/source_info_cache.rb +0 -394
  149. data/lib/rubygems/source_info_cache_entry.rb +0 -56
  150. data/test/test_gem_commands_mirror_command.rb +0 -60
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gem_package_tar_test_case', __FILE__)
1
+ require 'rubygems/package/tar_test_case'
2
2
  require 'rubygems/package/tar_output'
3
3
 
4
- class TestGemPackageTarOutput < TarTestCase
4
+ class TestGemPackageTarOutput < Gem::Package::TarTestCase
5
5
 
6
6
  def setup
7
7
  super
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gem_package_tar_test_case', __FILE__)
1
+ require 'rubygems/package/tar_test_case'
2
2
  require 'rubygems/package'
3
3
 
4
- class TestGemPackageTarReader < TarTestCase
4
+ class TestGemPackageTarReader < Gem::Package::TarTestCase
5
5
 
6
6
  def test_each_entry
7
7
  tar = tar_dir_header "foo", "bar", 0
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gem_package_tar_test_case', __FILE__)
1
+ require 'rubygems/package/tar_test_case'
2
2
  require 'rubygems/package'
3
3
 
4
- class TestGemPackageTarReaderEntry < TarTestCase
4
+ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
5
5
 
6
6
  def setup
7
7
  super
@@ -61,6 +61,16 @@ class TestGemPackageTarReaderEntry < TarTestCase
61
61
  assert_equal 'lib/foo', @entry.full_name
62
62
  end
63
63
 
64
+ def test_full_name_null
65
+ @entry.header.prefix << "\000"
66
+
67
+ e = assert_raises Gem::Package::TarInvalidError do
68
+ @entry.full_name
69
+ end
70
+
71
+ assert_equal 'tar is corrupt, name contains null byte', e.message
72
+ end
73
+
64
74
  def test_getc
65
75
  assert_equal ?a, @entry.getc
66
76
  end
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gem_package_tar_test_case', __FILE__)
1
+ require 'rubygems/package/tar_test_case'
2
2
  require 'rubygems/package/tar_writer'
3
3
 
4
- class TestTarWriter < TarTestCase
4
+ class TestTarWriter < Gem::Package::TarTestCase
5
5
 
6
6
  def setup
7
7
  super
@@ -1,8 +1,8 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require 'rubygems'
3
3
  require 'rubygems/package_task'
4
4
 
5
- class TestGemPackageTask < RubyGemTestCase
5
+ class TestGemPackageTask < Gem::TestCase
6
6
 
7
7
  def test_gem_package
8
8
  gem = Gem::Specification.new do |g|
@@ -42,5 +42,18 @@ class TestGemPackageTask < RubyGemTestCase
42
42
  assert_equal ["x", "y"], pkg.package_files
43
43
  end
44
44
 
45
+ def test_package_dir_path
46
+ gem = Gem::Specification.new do |g|
47
+ g.name = 'nokogiri'
48
+ g.version = '1.5.0'
49
+ g.platform = 'java'
50
+ end
51
+
52
+ pkg = Gem::PackageTask.new gem
53
+ pkg.define
54
+
55
+ assert_equal 'pkg/nokogiri-1.5.0-java', pkg.package_dir_path
56
+ end
57
+
45
58
  end
46
59
 
@@ -1,8 +1,8 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require 'rubygems/platform'
3
3
  require 'rbconfig'
4
4
 
5
- class TestGemPlatform < RubyGemTestCase
5
+ class TestGemPlatform < Gem::TestCase
6
6
 
7
7
  def test_self_local
8
8
  util_set_arch 'i686-darwin8.10.1'
@@ -1,4 +1,4 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require 'ostruct'
3
3
  require 'webrick'
4
4
  require 'rubygems/remote_fetcher'
@@ -18,7 +18,7 @@ require 'rubygems/format'
18
18
  # software doesn't really care, as long as we hit the proxy URL when a
19
19
  # proxy is configured.
20
20
 
21
- class TestGemRemoteFetcher < RubyGemTestCase
21
+ class TestGemRemoteFetcher < Gem::TestCase
22
22
 
23
23
  include Gem::DefaultUserInteraction
24
24
 
@@ -372,7 +372,7 @@ gems:
372
372
  uri.user, uri.password = 'domain%5Cuser', 'bar'
373
373
  fetcher = Gem::RemoteFetcher.new uri.to_s
374
374
  proxy = fetcher.instance_variable_get("@proxy_uri")
375
- assert_equal 'domain\user', URI.unescape(proxy.user)
375
+ assert_equal 'domain\user', fetcher.unescape(proxy.user)
376
376
  assert_equal 'bar', proxy.password
377
377
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
378
378
  end
@@ -383,7 +383,7 @@ gems:
383
383
  fetcher = Gem::RemoteFetcher.new uri.to_s
384
384
  proxy = fetcher.instance_variable_get("@proxy_uri")
385
385
  assert_equal 'user', proxy.user
386
- assert_equal 'my pass', URI.unescape(proxy.password)
386
+ assert_equal 'my pass', fetcher.unescape(proxy.password)
387
387
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
388
388
  end
389
389
  end
@@ -406,8 +406,8 @@ gems:
406
406
  ENV['http_proxy_pass'] = 'my bar'
407
407
  fetcher = Gem::RemoteFetcher.new nil
408
408
  proxy = fetcher.instance_variable_get("@proxy_uri")
409
- assert_equal 'foo\user', URI.unescape(proxy.user)
410
- assert_equal 'my bar', URI.unescape(proxy.password)
409
+ assert_equal 'foo\user', fetcher.unescape(proxy.user)
410
+ assert_equal 'my bar', fetcher.unescape(proxy.password)
411
411
  assert_data_from_proxy fetcher.fetch_path(@server_uri)
412
412
  end
413
413
  end
@@ -611,7 +611,7 @@ gems:
611
611
  assert_equal '', response.body
612
612
  end
613
613
 
614
- def test_request_unmodifed
614
+ def test_request_unmodified
615
615
  uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
616
616
  conn = util_stub_connection_for :body => '', :code => 304
617
617
 
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require "rubygems/requirement"
3
3
 
4
- class TestGemRequirement < RubyGemTestCase
4
+ class TestGemRequirement < Gem::TestCase
5
5
 
6
6
  def test_equals2
7
7
  r = req "= 1.2"
@@ -1,7 +1,7 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require 'rubygems/security'
3
3
 
4
- class TestGemSecurity < RubyGemTestCase
4
+ class TestGemSecurity < Gem::TestCase
5
5
 
6
6
  def test_class_build_cert
7
7
  name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"
@@ -86,5 +86,4 @@ class TestGemSecurity < RubyGemTestCase
86
86
  Gem::Security.email_to_name('no+body@example', munger).to_s
87
87
  end
88
88
 
89
- end
90
-
89
+ end if defined?(OpenSSL)
@@ -1,4 +1,4 @@
1
- require File.expand_path('../gemutilities', __FILE__)
1
+ require 'rubygems/test_case'
2
2
  require 'rubygems/server'
3
3
  require 'stringio'
4
4
 
@@ -7,7 +7,7 @@ class Gem::Server
7
7
  attr_reader :server
8
8
  end
9
9
 
10
- class TestGemServer < RubyGemTestCase
10
+ class TestGemServer < Gem::TestCase
11
11
 
12
12
  def setup
13
13
  super
@@ -109,104 +109,6 @@ class TestGemServer < RubyGemTestCase
109
109
  assert_equal 2, @server.server.listeners.length
110
110
  end
111
111
 
112
- def test_quick_a_1_gemspec_rz
113
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
114
- @req.parse data
115
-
116
- @server.quick @req, @res
117
-
118
- assert_equal 200, @res.status, @res.body
119
- assert @res['date']
120
- assert_equal 'application/x-deflate', @res['content-type']
121
-
122
- spec = YAML.load Gem.inflate(@res.body)
123
- assert_equal 'a', spec.name
124
- assert_equal Gem::Version.new(1), spec.version
125
- end
126
-
127
- def test_quick_a_1_mswin32_gemspec_rz
128
- quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
129
-
130
- data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
131
- @req.parse data
132
-
133
- @server.quick @req, @res
134
-
135
- assert_equal 200, @res.status, @res.body
136
- assert @res['date']
137
- assert_equal 'application/x-deflate', @res['content-type']
138
-
139
- spec = YAML.load Gem.inflate(@res.body)
140
- assert_equal 'a', spec.name
141
- assert_equal Gem::Version.new(1), spec.version
142
- assert_equal Gem::Platform.local, spec.platform
143
- end
144
-
145
- def test_quick_common_substrings
146
- quick_gem 'ab', '1'
147
-
148
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
149
- @req.parse data
150
-
151
- @server.quick @req, @res
152
-
153
- assert_equal 200, @res.status, @res.body
154
- assert @res['date']
155
- assert_equal 'application/x-deflate', @res['content-type']
156
-
157
- spec = YAML.load Gem.inflate(@res.body)
158
- assert_equal 'a', spec.name
159
- assert_equal Gem::Version.new(1), spec.version
160
- end
161
-
162
- def test_quick_index
163
- data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
164
- @req.parse data
165
-
166
- @server.quick @req, @res
167
-
168
- assert_equal 200, @res.status, @res.body
169
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
170
- assert_equal 'text/plain', @res['content-type']
171
- assert_equal "a-1\na-2", @res.body
172
- end
173
-
174
- def test_quick_index_rz
175
- data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
176
- @req.parse data
177
-
178
- @server.quick @req, @res
179
-
180
- assert_equal 200, @res.status, @res.body
181
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
182
- assert_equal 'application/x-deflate', @res['content-type']
183
- assert_equal "a-1\na-2", Gem.inflate(@res.body)
184
- end
185
-
186
- def test_quick_latest_index
187
- data = StringIO.new "GET /quick/latest_index HTTP/1.0\r\n\r\n"
188
- @req.parse data
189
-
190
- @server.quick @req, @res
191
-
192
- assert_equal 200, @res.status, @res.body
193
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
194
- assert_equal 'text/plain', @res['content-type']
195
- assert_equal 'a-2', @res.body
196
- end
197
-
198
- def test_quick_latest_index_rz
199
- data = StringIO.new "GET /quick/latest_index.rz HTTP/1.0\r\n\r\n"
200
- @req.parse data
201
-
202
- @server.quick @req, @res
203
-
204
- assert_equal 200, @res.status, @res.body
205
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
206
- assert_equal 'application/x-deflate', @res['content-type']
207
- assert_equal 'a-2', Gem.inflate(@res.body)
208
- end
209
-
210
112
  def test_quick_missing
211
113
  data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
212
114
  @req.parse data
@@ -305,38 +207,6 @@ class TestGemServer < RubyGemTestCase
305
207
  Marshal.load(Gem.gunzip(@res.body))
306
208
  end
307
209
 
308
- def test_yaml
309
- data = StringIO.new "GET /yaml.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
310
- @req.parse data
311
-
312
- @server.yaml @req, @res
313
-
314
- assert_equal 200, @res.status, @res.body
315
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
316
- assert_equal 'text/plain', @res['content-type']
317
-
318
- si = Gem::SourceIndex.new
319
- si.add_specs @a1, @a2
320
-
321
- assert_equal si, YAML.load(@res.body)
322
- end
323
-
324
- def test_yaml_Z
325
- data = StringIO.new "GET /yaml.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
326
- @req.parse data
327
-
328
- @server.yaml @req, @res
329
-
330
- assert_equal 200, @res.status, @res.body
331
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
332
- assert_equal 'application/x-deflate', @res['content-type']
333
-
334
- si = Gem::SourceIndex.new
335
- si.add_specs @a1, @a2
336
-
337
- assert_equal si, YAML.load(Gem.inflate(@res.body))
338
- end
339
-
340
210
  def util_listen
341
211
  webrick = Object.new
342
212
  webrick.instance_variable_set :@listeners, []
@@ -0,0 +1,113 @@
1
+ require 'rubygems/test_case'
2
+ require 'rubygems/user_interaction'
3
+ require 'timeout'
4
+
5
+ class TestGemSilentUI < Gem::TestCase
6
+
7
+ def setup
8
+ super
9
+ @sui = Gem::SilentUI.new
10
+ end
11
+
12
+ def test_ask
13
+ value = nil
14
+ out, err = capture_io do
15
+ use_ui @sui do
16
+ value = @sui.ask 'Problem?'
17
+ end
18
+ end
19
+
20
+ assert_empty out, 'No output'
21
+ assert_empty err, 'No output'
22
+
23
+ assert_nil value, 'No value'
24
+ end
25
+
26
+ def test_ask_for_password
27
+ value = nil
28
+ out, err = capture_io do
29
+ use_ui @sui do
30
+ value = @sui.ask_for_password 'Problem?'
31
+ end
32
+ end
33
+
34
+ assert_empty out, 'No output'
35
+ assert_empty err, 'No output'
36
+
37
+ assert_nil value, 'No value'
38
+ end
39
+
40
+ def test_ask_yes_no
41
+ value = nil
42
+ out, err = capture_io do
43
+ use_ui @sui do
44
+ assert_raises(Gem::OperationNotSupportedError) do
45
+ @sui.ask_yes_no 'Problem?'
46
+ end
47
+ end
48
+ end
49
+
50
+ assert_empty out, 'No output'
51
+ assert_empty err, 'No output'
52
+
53
+ out, err = capture_io do
54
+ use_ui @sui do
55
+ value = @sui.ask_yes_no 'Problem?', true
56
+ end
57
+ end
58
+
59
+ assert_empty out, 'No output'
60
+ assert_empty err, 'No output'
61
+
62
+ assert value, 'Value is true'
63
+
64
+ out, err = capture_io do
65
+ use_ui @sui do
66
+ value = @sui.ask_yes_no 'Problem?', false
67
+ end
68
+ end
69
+
70
+ assert_empty out, 'No output'
71
+ assert_empty err, 'No output'
72
+
73
+ assert_equal value, false, 'Value is false'
74
+ end
75
+
76
+ def test_choose_from_list
77
+ value = nil
78
+ out, err = capture_io do
79
+ use_ui @sui do
80
+ value = @sui.choose_from_list 'Problem?', %w[yes no]
81
+ end
82
+ end
83
+
84
+ assert_empty out, 'No output'
85
+ assert_empty err, 'No output'
86
+
87
+ assert_equal [nil, nil], value, 'Value is nil!'
88
+ end
89
+
90
+ def test_progress_reporter
91
+ value = nil
92
+ out, err = capture_io do
93
+ use_ui @sui do
94
+ @sui.progress_reporter 10, 'hi'
95
+ end
96
+ end
97
+
98
+ assert_empty out, 'No output'
99
+ assert_empty err, 'No output'
100
+ end
101
+
102
+ def test_download_reporter
103
+ value = nil
104
+ out, err = capture_io do
105
+ use_ui @sui do
106
+ @sui.download_reporter.fetch 'a.gem', 1024
107
+ end
108
+ end
109
+
110
+ assert_empty out, 'No output'
111
+ assert_empty err, 'No output'
112
+ end
113
+ end