Sha256: 12e3a2aa683d81e3cd826d48a5eea675db0f266836a1af444120dd2419f34942
Contents?: true
Size: 1.99 KB
Versions: 7
Compression:
Stored size: 1.99 KB
Contents
require 'rubygems' Gem::manage_gems require 'test/unit' require 'stringio' class TestFormat < Test::Unit::TestCase def setup require File.dirname(__FILE__) + "/simple_gem.rb" @simple_gem = SIMPLE_GEM end def test_garbled_gem_throws_format_exception assert_raises(RuntimeError) { # subtly bogus input Gem::Format.from_io(StringIO.new(@simple_gem.upcase)) } assert_raises(RuntimeError) { # Totally bogus input Gem::Format.from_io(StringIO.new(@simple_gem.reverse)) } assert_raises(RuntimeError) { # This was intentionally screws up YAML parsing. Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom"))) } end def test_passing_nonexistent_files_throws_sensible_exception assert_raises(Gem::Exception) { Gem::Format.from_file_by_path("/this/path/almost/definitely/will/not/exist") } end end class TestOldFormat # < Test::Unit::TestCase def setup require File.dirname(__FILE__) + "/simple_gem.rb" @simple_gem = SIMPLE_GEM end def test_from_io_returns_format_object format = Gem::OldFormat.from_io(StringIO.new(@simple_gem)) assert_equal(Gem::OldFormat, format.class) assert_equal(Gem::Specification, format.spec.class) # simple_gem.rb's gem has 3 files in it assert_equal(3, format.file_entries.size) end def test_garbled_gem_throws_format_exception assert_raises(RuntimeError) { # subtly bogus input Gem::OldFormat.from_io(StringIO.new(@simple_gem.upcase)) } assert_raises(RuntimeError) { # Totally bogus input Gem::OldFormat.from_io(StringIO.new(@simple_gem.reverse)) } assert_raises(RuntimeError) { # This was intentionally screws up YAML parsing. Gem::OldFormat.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom"))) } end def test_passing_nonexistent_files_throws_sensible_exception assert_raises(Gem::Exception) { Gem::OldFormat.from_file_by_path("/this/path/almost/definitely/will/not/exist") } end end
Version data entries
7 entries across 7 versions & 1 rubygems