diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:02:05 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:02:05 +0000 |
commit | 0dc342de848a642ecce8db697b8fecd83a63e117 (patch) | |
tree | 2b7ed4724aff1f86073e4740134bda9c4aac1a39 /trunk/test/rubygems/test_gem_format.rb | |
parent | ef70cf7138ab8034b5b806f466e4b484b24f0f88 (diff) |
added tag v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/test/rubygems/test_gem_format.rb')
-rw-r--r-- | trunk/test/rubygems/test_gem_format.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/trunk/test/rubygems/test_gem_format.rb b/trunk/test/rubygems/test_gem_format.rb new file mode 100644 index 0000000000..4014acfed9 --- /dev/null +++ b/trunk/test/rubygems/test_gem_format.rb @@ -0,0 +1,69 @@ +#-- +# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. +# All rights reserved. +# See LICENSE.txt for permissions. +#++ + +require 'test/unit' +require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') +require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem') +require 'rubygems/format' + +class TestGemFormat < RubyGemTestCase + + def setup + super + + @simple_gem = SIMPLE_GEM + end + + def test_from_file_by_path + util_make_gems + + gems = Dir[File.join(@gemhome, 'cache', '*.gem')] + + names = [@a1, @a2, @a_evil9, @b2, @c1_2, @pl1].map do |spec| + spec.original_name + end + + gems_n_names = gems.sort.zip names + + gems_n_names.each do |gemfile, name| + spec = Gem::Format.from_file_by_path(gemfile).spec + + assert_equal name, spec.original_name + end + end + + def test_from_file_by_path_nonexistent + assert_raise Gem::Exception do + Gem::Format.from_file_by_path '/nonexistent' + end + end + + def test_from_io_garbled + e = assert_raise Gem::Package::FormatError do + # subtly bogus input + Gem::Format.from_io(StringIO.new(@simple_gem.upcase)) + end + + assert_equal 'No metadata found!', e.message + + e = assert_raise Gem::Package::FormatError do + # Totally bogus input + Gem::Format.from_io(StringIO.new(@simple_gem.reverse)) + end + + assert_equal 'No metadata found!', e.message + + e = assert_raise 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 + end + +end + + |