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
@@ -102,7 +102,7 @@ load 'my_exec'
102
102
  @installer.ensure_dependency @spec, dep
103
103
  end
104
104
 
105
- assert_equal 'a requires b (> 2)', e.message
105
+ assert_equal 'a requires b (> 2, runtime)', e.message
106
106
  end
107
107
 
108
108
  def test_expand_and_validate_gem_dir
@@ -128,7 +128,12 @@ load 'my_exec'
128
128
 
129
129
  @installer.extract_files
130
130
 
131
- assert_equal 'thefile', File.read(File.join(util_gem_dir, 'thefile'))
131
+ thefile_path = File.join(util_gem_dir, 'thefile')
132
+ assert_equal 'thefile', File.read(thefile_path)
133
+
134
+ unless Gem.win_platform? then
135
+ assert_equal 0400, File.stat(thefile_path).mode & 0777
136
+ end
132
137
  end
133
138
 
134
139
  def test_extract_files_bad_dest
@@ -313,6 +318,31 @@ load 'my_exec'
313
318
  #assert_no_match %r|generated by RubyGems|, wrapper
314
319
  end
315
320
 
321
+ def test_generate_bin_script_wrappers
322
+ @installer.wrappers = true
323
+ util_make_exec
324
+ @installer.gem_dir = util_gem_dir
325
+ installed_exec = File.join(util_inst_bindir, "my_exec")
326
+
327
+ real_exec = File.join util_gem_dir, 'bin', 'my_exec'
328
+
329
+ # fake --no-wrappers for previous install
330
+ unless Gem.win_platform? then
331
+ FileUtils.mkdir_p File.dirname(installed_exec)
332
+ FileUtils.ln_s real_exec, installed_exec
333
+ end
334
+
335
+ @installer.generate_bin
336
+ assert_equal true, File.directory?(util_inst_bindir)
337
+ assert_equal true, File.exist?(installed_exec)
338
+ assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
339
+
340
+ assert_match %r|generated by RubyGems|, File.read(installed_exec)
341
+
342
+ assert_no_match %r|generated by RubyGems|, File.read(real_exec),
343
+ 'real executable overwritten'
344
+ end
345
+
316
346
  def test_generate_bin_symlink
317
347
  return if win_platform? #Windows FS do not support symlinks
318
348
 
@@ -46,12 +46,13 @@ class TestGemLocalRemoteOptions < RubyGemTestCase
46
46
  def test_source_option
47
47
  @cmd.add_source_option
48
48
 
49
- s1 = URI.parse 'http://more-gems.example.com'
50
- s2 = URI.parse 'http://even-more-gems.example.com'
49
+ s1 = URI.parse 'http://more-gems.example.com/'
50
+ s2 = URI.parse 'http://even-more-gems.example.com/'
51
+ s3 = URI.parse 'http://other-gems.example.com/some_subdir'
51
52
 
52
- @cmd.handle_options %W[--source #{s1} --source #{s2}]
53
+ @cmd.handle_options %W[--source #{s1} --source #{s2} --source #{s3}]
53
54
 
54
- assert_equal [s1, s2], Gem.sources
55
+ assert_equal [s1.to_s, s2.to_s, "#{s3}/"], Gem.sources
55
56
  end
56
57
 
57
58
  def test_update_sources_option
@@ -77,7 +78,7 @@ class TestGemLocalRemoteOptions < RubyGemTestCase
77
78
  @cmd.handle_options %W[--source #{s1}]
78
79
  end
79
80
 
80
- assert_equal %w[http://gems.example.com], Gem.sources
81
+ assert_equal [@gem_repo], Gem.sources
81
82
  end
82
83
 
83
84
  end
@@ -24,7 +24,7 @@ require 'rubygems/remote_fetcher'
24
24
  # Note that the proxy server is not a *real* proxy server. But our
25
25
  # software doesn't really care, as long as we hit the proxy URL when a
26
26
  # proxy is configured.
27
- #
27
+
28
28
  class TestGemRemoteFetcher < RubyGemTestCase
29
29
 
30
30
  include Gem::DefaultUserInteraction
@@ -105,7 +105,7 @@ gems:
105
105
 
106
106
  @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
107
107
 
108
- Gem::RemoteFetcher.instance_variable_set :@fetcher, nil
108
+ Gem::RemoteFetcher.fetcher = nil
109
109
  end
110
110
 
111
111
  def test_self_fetcher
@@ -144,7 +144,7 @@ gems:
144
144
 
145
145
  def test_fetch_size_socket_error
146
146
  fetcher = Gem::RemoteFetcher.new nil
147
- def fetcher.connect_to(host, port)
147
+ def fetcher.connection_for(uri)
148
148
  raise SocketError
149
149
  end
150
150
 
@@ -153,7 +153,8 @@ gems:
153
153
  fetcher.fetch_size uri
154
154
  end
155
155
 
156
- assert_equal "SocketError (SocketError)\n\tgetting size of #{uri}", e.message
156
+ assert_equal "SocketError (SocketError)\n\tfetching size (#{uri})",
157
+ e.message
157
158
  end
158
159
 
159
160
  def test_no_proxy
@@ -182,7 +183,7 @@ gems:
182
183
  @test_data
183
184
  end
184
185
 
185
- raise Gem::RemoteFetcher::FetchError, "haha!"
186
+ raise Gem::RemoteFetcher::FetchError.new("haha!", nil)
186
187
  end
187
188
  end
188
189
 
@@ -371,7 +372,8 @@ gems:
371
372
  fetcher.fetch_path 'uri'
372
373
  end
373
374
 
374
- assert_equal 'EOFError: EOFError reading uri', e.message
375
+ assert_equal 'EOFError: EOFError (uri)', e.message
376
+ assert_equal 'uri', e.uri
375
377
  end
376
378
 
377
379
  def test_fetch_path_socket_error
@@ -383,7 +385,8 @@ gems:
383
385
  fetcher.fetch_path 'uri'
384
386
  end
385
387
 
386
- assert_equal 'SocketError: SocketError reading uri', e.message
388
+ assert_equal 'SocketError: SocketError (uri)', e.message
389
+ assert_equal 'uri', e.uri
387
390
  end
388
391
 
389
392
  def test_fetch_path_system_call_error
@@ -397,8 +400,9 @@ gems:
397
400
  fetcher.fetch_path 'uri'
398
401
  end
399
402
 
400
- assert_match %r|ECONNREFUSED:.*connect\(2\) reading uri\z|,
403
+ assert_match %r|ECONNREFUSED:.*connect\(2\) \(uri\)\z|,
401
404
  e.message
405
+ assert_equal 'uri', e.uri
402
406
  end
403
407
 
404
408
  def test_get_proxy_from_env_empty
@@ -494,7 +498,8 @@ gems:
494
498
  fetcher.send :open_uri_or_path, 'http://gems.example.com/redirect'
495
499
  end
496
500
 
497
- assert_equal 'too many redirects', e.message
501
+ assert_equal 'too many redirects (http://gems.example.com/redirect)',
502
+ e.message
498
503
  end
499
504
 
500
505
  def test_zip
@@ -14,34 +14,69 @@ class TestGemServer < RubyGemTestCase
14
14
  super
15
15
 
16
16
  @a1 = quick_gem 'a', '1'
17
+ @a2 = quick_gem 'a', '2'
17
18
 
18
19
  @server = Gem::Server.new Gem.dir, process_based_port, false
19
20
  @req = WEBrick::HTTPRequest.new :Logger => nil
20
21
  @res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
21
22
  end
22
23
 
23
- def test_quick_index
24
- data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
24
+ def test_Marshal
25
+ data = StringIO.new "GET /Marshal.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
25
26
  @req.parse data
26
27
 
27
- @server.quick @req, @res
28
+ @server.Marshal @req, @res
28
29
 
29
30
  assert_equal 200, @res.status, @res.body
30
31
  assert_match %r| \d\d:\d\d:\d\d |, @res['date']
31
- assert_equal 'text/plain', @res['content-type']
32
- assert_equal "a-1", @res.body
32
+ assert_equal 'application/octet-stream', @res['content-type']
33
+
34
+ si = Gem::SourceIndex.new
35
+ si.add_specs @a1, @a2
36
+
37
+ assert_equal si, Marshal.load(@res.body)
33
38
  end
34
39
 
35
- def test_quick_index_rz
36
- data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
40
+ def test_Marshal_Z
41
+ data = StringIO.new "GET /Marshal.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
37
42
  @req.parse data
38
43
 
39
- @server.quick @req, @res
44
+ @server.Marshal @req, @res
40
45
 
41
46
  assert_equal 200, @res.status, @res.body
42
47
  assert_match %r| \d\d:\d\d:\d\d |, @res['date']
43
- assert_equal 'text/plain', @res['content-type']
44
- assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
48
+ assert_equal 'application/x-deflate', @res['content-type']
49
+
50
+ si = Gem::SourceIndex.new
51
+ si.add_specs @a1, @a2
52
+
53
+ assert_equal si, Marshal.load(Gem.inflate(@res.body))
54
+ end
55
+
56
+ def test_latest_specs
57
+ data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
58
+ @req.parse data
59
+
60
+ @server.latest_specs @req, @res
61
+
62
+ assert_equal 200, @res.status, @res.body
63
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
64
+ assert_equal 'application/octet-stream', @res['content-type']
65
+ assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
66
+ Marshal.load(@res.body)
67
+ end
68
+
69
+ def test_latest_specs_gz
70
+ data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
71
+ @req.parse data
72
+
73
+ @server.latest_specs @req, @res
74
+
75
+ assert_equal 200, @res.status, @res.body
76
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
77
+ assert_equal 'application/x-gzip', @res['content-type']
78
+ assert_equal [['a', Gem::Version.new(2), Gem::Platform::RUBY]],
79
+ Marshal.load(Gem.gunzip(@res.body))
45
80
  end
46
81
 
47
82
  def test_quick_a_1_gemspec_rz
@@ -52,17 +87,15 @@ class TestGemServer < RubyGemTestCase
52
87
 
53
88
  assert_equal 200, @res.status, @res.body
54
89
  assert @res['date']
55
- assert_equal 'text/plain', @res['content-type']
90
+ assert_equal 'application/x-deflate', @res['content-type']
56
91
 
57
- spec = YAML.load Zlib::Inflate.inflate(@res.body)
92
+ spec = YAML.load Gem.inflate(@res.body)
58
93
  assert_equal 'a', spec.name
59
94
  assert_equal Gem::Version.new(1), spec.version
60
95
  end
61
96
 
62
97
  def test_quick_a_1_mswin32_gemspec_rz
63
98
  a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
64
- si = Gem::SourceIndex.new @a1.full_name => @a1, a1_p.full_name => a1_p
65
- @server.source_index = si
66
99
 
67
100
  data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
68
101
  @req.parse data
@@ -71,9 +104,9 @@ class TestGemServer < RubyGemTestCase
71
104
 
72
105
  assert_equal 200, @res.status, @res.body
73
106
  assert @res['date']
74
- assert_equal 'text/plain', @res['content-type']
107
+ assert_equal 'application/x-deflate', @res['content-type']
75
108
 
76
- spec = YAML.load Zlib::Inflate.inflate(@res.body)
109
+ spec = YAML.load Gem.inflate(@res.body)
77
110
  assert_equal 'a', spec.name
78
111
  assert_equal Gem::Version.new(1), spec.version
79
112
  assert_equal Gem::Platform.local, spec.platform
@@ -81,8 +114,6 @@ class TestGemServer < RubyGemTestCase
81
114
 
82
115
  def test_quick_common_substrings
83
116
  ab1 = quick_gem 'ab', '1'
84
- si = Gem::SourceIndex.new @a1.full_name => @a1, ab1.full_name => ab1
85
- @server.source_index = si
86
117
 
87
118
  data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
88
119
  @req.parse data
@@ -91,14 +122,62 @@ class TestGemServer < RubyGemTestCase
91
122
 
92
123
  assert_equal 200, @res.status, @res.body
93
124
  assert @res['date']
94
- assert_equal 'text/plain', @res['content-type']
125
+ assert_equal 'application/x-deflate', @res['content-type']
95
126
 
96
- spec = YAML.load Zlib::Inflate.inflate(@res.body)
127
+ spec = YAML.load Gem.inflate(@res.body)
97
128
  assert_equal 'a', spec.name
98
129
  assert_equal Gem::Version.new(1), spec.version
99
130
  end
100
131
 
101
- def test_quick_z_9_gemspec_rz
132
+ def test_quick_index
133
+ data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
134
+ @req.parse data
135
+
136
+ @server.quick @req, @res
137
+
138
+ assert_equal 200, @res.status, @res.body
139
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
140
+ assert_equal 'text/plain', @res['content-type']
141
+ assert_equal "a-1\na-2", @res.body
142
+ end
143
+
144
+ def test_quick_index_rz
145
+ data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
146
+ @req.parse data
147
+
148
+ @server.quick @req, @res
149
+
150
+ assert_equal 200, @res.status, @res.body
151
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
152
+ assert_equal 'application/x-deflate', @res['content-type']
153
+ assert_equal "a-1\na-2", Gem.inflate(@res.body)
154
+ end
155
+
156
+ def test_quick_latest_index
157
+ data = StringIO.new "GET /quick/latest_index HTTP/1.0\r\n\r\n"
158
+ @req.parse data
159
+
160
+ @server.quick @req, @res
161
+
162
+ assert_equal 200, @res.status, @res.body
163
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
164
+ assert_equal 'text/plain', @res['content-type']
165
+ assert_equal 'a-2', @res.body
166
+ end
167
+
168
+ def test_quick_latest_index_rz
169
+ data = StringIO.new "GET /quick/latest_index.rz HTTP/1.0\r\n\r\n"
170
+ @req.parse data
171
+
172
+ @server.quick @req, @res
173
+
174
+ assert_equal 200, @res.status, @res.body
175
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
176
+ assert_equal 'application/x-deflate', @res['content-type']
177
+ assert_equal 'a-2', Gem.inflate(@res.body)
178
+ end
179
+
180
+ def test_quick_missing
102
181
  data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
103
182
  @req.parse data
104
183
 
@@ -111,5 +190,112 @@ class TestGemServer < RubyGemTestCase
111
190
  assert_equal 404, @res.status
112
191
  end
113
192
 
193
+ def test_quick_marshal_a_1_gemspec_rz
194
+ data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
195
+ @req.parse data
196
+
197
+ @server.quick @req, @res
198
+
199
+ assert_equal 200, @res.status, @res.body
200
+ assert @res['date']
201
+ assert_equal 'application/x-deflate', @res['content-type']
202
+
203
+ spec = Marshal.load Gem.inflate(@res.body)
204
+ assert_equal 'a', spec.name
205
+ assert_equal Gem::Version.new(1), spec.version
206
+ end
207
+
208
+ def test_quick_marshal_a_1_mswin32_gemspec_rz
209
+ a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
210
+
211
+ data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
212
+ @req.parse data
213
+
214
+ @server.quick @req, @res
215
+
216
+ assert_equal 200, @res.status, @res.body
217
+ assert @res['date']
218
+ assert_equal 'application/x-deflate', @res['content-type']
219
+
220
+ spec = Marshal.load Gem.inflate(@res.body)
221
+ assert_equal 'a', spec.name
222
+ assert_equal Gem::Version.new(1), spec.version
223
+ assert_equal Gem::Platform.local, spec.platform
224
+ end
225
+
226
+
227
+ def test_root
228
+ data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
229
+ @req.parse data
230
+
231
+ @server.root @req, @res
232
+
233
+ assert_equal 200, @res.status, @res.body
234
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
235
+ assert_equal 'text/html', @res['content-type']
236
+ end
237
+
238
+ def test_specs
239
+ data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
240
+ @req.parse data
241
+
242
+ @server.specs @req, @res
243
+
244
+ assert_equal 200, @res.status, @res.body
245
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
246
+ assert_equal 'application/octet-stream', @res['content-type']
247
+
248
+ assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
249
+ ['a', Gem::Version.new(2), Gem::Platform::RUBY]],
250
+ Marshal.load(@res.body)
251
+ end
252
+
253
+ def test_specs_gz
254
+ data = StringIO.new "GET /specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
255
+ @req.parse data
256
+
257
+ @server.specs @req, @res
258
+
259
+ assert_equal 200, @res.status, @res.body
260
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
261
+ assert_equal 'application/x-gzip', @res['content-type']
262
+
263
+ assert_equal [['a', Gem::Version.new(1), Gem::Platform::RUBY],
264
+ ['a', Gem::Version.new(2), Gem::Platform::RUBY]],
265
+ Marshal.load(Gem.gunzip(@res.body))
266
+ end
267
+
268
+ def test_yaml
269
+ data = StringIO.new "GET /yaml.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
270
+ @req.parse data
271
+
272
+ @server.yaml @req, @res
273
+
274
+ assert_equal 200, @res.status, @res.body
275
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
276
+ assert_equal 'text/plain', @res['content-type']
277
+
278
+ si = Gem::SourceIndex.new
279
+ si.add_specs @a1, @a2
280
+
281
+ assert_equal si, YAML.load(@res.body)
282
+ end
283
+
284
+ def test_yaml_Z
285
+ data = StringIO.new "GET /yaml.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
286
+ @req.parse data
287
+
288
+ @server.yaml @req, @res
289
+
290
+ assert_equal 200, @res.status, @res.body
291
+ assert_match %r| \d\d:\d\d:\d\d |, @res['date']
292
+ assert_equal 'application/x-deflate', @res['content-type']
293
+
294
+ si = Gem::SourceIndex.new
295
+ si.add_specs @a1, @a2
296
+
297
+ assert_equal si, YAML.load(Gem.inflate(@res.body))
298
+ end
299
+
114
300
  end
115
301