summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_format.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-01 03:11:34 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-01 03:11:34 +0000
commitec84bfc9e3d11a3b1dbebcaf4d1ddf1357307513 (patch)
treecc3b9df7f06f86c52f4d09c03f5c9a3876c87b67 /test/rubygems/test_gem_format.rb
parentf4234c9b8f4707c5979d9a3beddc19ceeb417bd8 (diff)
Import rubygems 1.5.0 (released version @ 1fb59d0)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_format.rb')
-rw-r--r--test/rubygems/test_gem_format.rb30
1 files changed, 24 insertions, 6 deletions
diff --git a/test/rubygems/test_gem_format.rb b/test/rubygems/test_gem_format.rb
index cbf2bc7788..f964cab143 100644
--- a/test/rubygems/test_gem_format.rb
+++ b/test/rubygems/test_gem_format.rb
@@ -4,11 +4,11 @@
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
-require 'rubygems/test_case'
-require "test/rubygems/simple_gem"
+require 'rubygems/package/tar_test_case'
+require 'test/rubygems/simple_gem'
require 'rubygems/format'
-class TestGemFormat < Gem::TestCase
+class TestGemFormat < Gem::Package::TarTestCase
def setup
super
@@ -16,6 +16,7 @@ class TestGemFormat < Gem::TestCase
@simple_gem = SIMPLE_GEM
end
+ # HACK this test should do less
def test_class_from_file_by_path
util_make_gems
@@ -34,6 +35,23 @@ class TestGemFormat < Gem::TestCase
end
end
+ def test_class_from_file_by_path_corrupt
+ Tempfile.open 'corrupt' do |io|
+ data = Gem.gzip 'a' * 10
+ io.write tar_file_header('metadata.gz', "\000x", 0644, data.length)
+ io.write data
+ io.rewind
+
+ e = assert_raises Gem::Package::FormatError do
+ Gem::Format.from_file_by_path io.path
+ end
+
+ sub_message = 'Gem::Package::TarInvalidError: tar is corrupt, name contains null byte'
+ assert_equal "corrupt gem (#{sub_message}) in #{io.path}", e.message
+ assert_equal io.path, e.path
+ end
+ end
+
def test_class_from_file_by_path_empty
util_make_gems
@@ -55,21 +73,21 @@ class TestGemFormat < Gem::TestCase
Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
end
- assert_equal 'No metadata found!', e.message
+ assert_equal 'no metadata found', e.message
e = assert_raises Gem::Package::FormatError do
# Totally bogus input
Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
end
- assert_equal 'No metadata found!', e.message
+ assert_equal 'no metadata found', e.message
e = assert_raises Gem::Package::FormatError do
# This was intentionally screws up YAML parsing.
Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
end
- assert_equal 'No metadata found!', e.message
+ assert_equal 'no metadata found', e.message
end
end