summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_server.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:39:12 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:39:12 +0000
commit8289771e326006cc4e15a667e3eff3a72cfb3327 (patch)
treef6d367888b42848fd6a660fad57fa2020e38c097 /test/rubygems/test_gem_server.rb
parent40d8543fbdec5485a638a2cb1008089d106b978d (diff)
Import RubyGems 1.0.0, r1575
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_server.rb')
-rw-r--r--test/rubygems/test_gem_server.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index 98c8ba5543..c283e661dc 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -4,6 +4,7 @@ require 'rubygems/server'
require 'stringio'
class Gem::Server
+ attr_accessor :source_index
attr_reader :server
end
@@ -25,6 +26,7 @@ class TestGemServer < RubyGemTestCase
@server.quick @req, @res
+ assert_equal 200, @res.status, @res.body
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'text/plain', @res['content-type']
assert_equal "a-1", @res.body
@@ -36,6 +38,7 @@ class TestGemServer < RubyGemTestCase
@server.quick @req, @res
+ assert_equal 200, @res.status, @res.body
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'text/plain', @res['content-type']
assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
@@ -47,6 +50,7 @@ class TestGemServer < RubyGemTestCase
@server.quick @req, @res
+ assert_equal 200, @res.status, @res.body
assert @res['date']
assert_equal 'text/plain', @res['content-type']
yaml = Zlib::Inflate.inflate(@res.body)
@@ -55,15 +59,54 @@ class TestGemServer < RubyGemTestCase
assert_match %r|version: "1"|, yaml
end
+ def test_quick_a_1_mswin32_gemspec_rz
+ a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
+ si = Gem::SourceIndex.new @a1.full_name => @a1, a1_p.full_name => a1_p
+ @server.source_index = si
+
+ data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
+ @req.parse data
+
+ @server.quick @req, @res
+
+ assert_equal 200, @res.status, @res.body
+ assert @res['date']
+ assert_equal 'text/plain', @res['content-type']
+ yaml = Zlib::Inflate.inflate(@res.body)
+ assert_match %r|Gem::Specification|, yaml
+ assert_match %r|name: a|, yaml
+ assert_match %r|version: "1"|, yaml
+ end
+
+ def test_quick_common_substrings
+ ab1 = quick_gem 'ab', '1'
+ si = Gem::SourceIndex.new @a1.full_name => @a1, ab1.full_name => ab1
+ @server.source_index = si
+
+ data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
+ @req.parse data
+
+ @server.quick @req, @res
+
+ assert_equal 200, @res.status, @res.body
+ assert @res['date']
+ assert_equal 'text/plain', @res['content-type']
+ yaml = Zlib::Inflate.inflate @res.body
+ assert_match %r|Gem::Specification|, yaml
+ assert_match %r|name: a$|, yaml
+ assert_match %r|version: "1"|, yaml
+ end
+
def test_quick_z_9_gemspec_rz
data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
@server.quick @req, @res
+ assert_equal 404, @res.status, @res.body
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'text/plain', @res['content-type']
- assert_equal '', @res.body
+ assert_equal 'No gems found matching "z" "9" nil', @res.body
assert_equal 404, @res.status
end