Import RubyGems r1601. [ruby-core:15381].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2008-02-10 08:00:19 +00:00
parent c12b289362
commit 5d613c83cc
26 changed files with 165 additions and 85 deletions

View File

@ -1,3 +1,8 @@
Sun Feb 10 16:58:20 2008 Eric Hodel <drbrain@segment7.net>
* lib/rubygems*, test/rubygems*, gem_prelude.rb: Import RubyGems
* r1601. [ruby-core:15381]
Sun Feb 10 15:07:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Feb 10 15:07:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* {bcc32,win32,wince}/Makefile.sub (MISSING): added cbrt.obj. * {bcc32,win32,wince}/Makefile.sub (MISSING): added cbrt.obj.

View File

@ -8,7 +8,7 @@
require 'rubygems' require 'rubygems'
require 'rubygems/gem_runner' require 'rubygems/gem_runner'
required_version = Gem::Requirement.new ">= 1.8.2" required_version = Gem::Requirement.new ">= 1.8.3"
unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then
abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}" abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"

View File

@ -166,7 +166,13 @@ module Gem
require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib")) require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib"))
end end
end end
# "tag" the first require_path inserted into the $LOAD_PATH to enable
# indexing correctly with rubygems proper when it inserts an explicitly
# gem version
unless require_paths.empty?
require_paths.first.instance_variable_set(:@gem_prelude_index, true)
end
# gem directories must come after -I and ENV['RUBYLIB'] # gem directories must come after -I and ENV['RUBYLIB']
$:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths $:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths
end end

View File

@ -290,6 +290,24 @@ module Gem
@ruby @ruby
end end
# Return the index to insert activated gem paths into the $LOAD_PATH
# Defaults to the site lib directory unless gem_prelude.rb has loaded
# paths then it inserts the path before those paths so you can override
# the gem_prelude.rb default $LOAD_PATH paths.
def load_path_insert_index
index = $LOAD_PATH.index ConfigMap[:sitelibdir]
$LOAD_PATH.each_with_index do |path, i|
if path.instance_variables.include?(:@gem_prelude_index) or
path.instance_variables.include?('@gem_prelude_index') then
index = i
break
end
end
index
end
# Activate a gem (i.e. add it to the Ruby load path). The gem # Activate a gem (i.e. add it to the Ruby load path). The gem
# must satisfy all the specified version constraints. If # must satisfy all the specified version constraints. If
# +autorequire+ is true, then automatically require the specified # +autorequire+ is true, then automatically require the specified
@ -345,11 +363,13 @@ module Gem
end end
sitelibdir = ConfigMap[:sitelibdir] sitelibdir = ConfigMap[:sitelibdir]
sitelibdir_index = $LOAD_PATH.index sitelibdir
if sitelibdir_index then # gem directories must come after -I and ENV['RUBYLIB']
insert_index = load_path_insert_index
if insert_index then
# gem directories must come after -I and ENV['RUBYLIB'] # gem directories must come after -I and ENV['RUBYLIB']
$LOAD_PATH.insert(sitelibdir_index, *require_paths) $LOAD_PATH.insert(insert_index, *require_paths)
else else
# we are probably testing in core, -I and RUBYLIB don't apply # we are probably testing in core, -I and RUBYLIB don't apply
$LOAD_PATH.unshift(*require_paths) $LOAD_PATH.unshift(*require_paths)

View File

@ -136,7 +136,7 @@ module Gem
execute execute
end end
end end
# Call the given block when invoked. # Call the given block when invoked.
# #
# Normal command invocations just executes the +execute+ method of # Normal command invocations just executes the +execute+ method of
@ -146,7 +146,7 @@ module Gem
def when_invoked(&block) def when_invoked(&block)
@when_invoked = block @when_invoked = block
end end
# Add a command-line option and handler to the command. # Add a command-line option and handler to the command.
# #
# See OptionParser#make_switch for an explanation of +opts+. # See OptionParser#make_switch for an explanation of +opts+.
@ -165,7 +165,7 @@ module Gem
option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } } option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
end end
end end
# Merge a set of command options with the set of default options # Merge a set of command options with the set of default options
# (without modifying the default option hash). # (without modifying the default option hash).
def merge_options(new_options) def merge_options(new_options)
@ -191,7 +191,7 @@ module Gem
parser.parse!(args) parser.parse!(args)
@options[:args] = args @options[:args] = args
end end
def add_extra_args(args) def add_extra_args(args)
result = [] result = []
s_extra = Command.specific_extra_args(@command) s_extra = Command.specific_extra_args(@command)
@ -291,7 +291,7 @@ module Gem
def common_options def common_options
@common_options ||= [] @common_options ||= []
end end
def add_common_option(*args, &handler) def add_common_option(*args, &handler)
Gem::Command.common_options << [args, handler] Gem::Command.common_options << [args, handler]
end end
@ -315,7 +315,7 @@ module Gem
def specific_extra_args(cmd) def specific_extra_args(cmd)
specific_extra_args_hash[cmd] specific_extra_args_hash[cmd]
end end
# Add a list of extra arguments for the given command. +args+ # Add a list of extra arguments for the given command. +args+
# may be an array or a string to be split on white space. # may be an array or a string to be split on white space.
def add_specific_extra_args(cmd,args) def add_specific_extra_args(cmd,args)
@ -334,7 +334,7 @@ module Gem
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# Add the options common to all commands. # Add the options common to all commands.
add_common_option('-h', '--help', add_common_option('-h', '--help',
'Get help on this command') do 'Get help on this command') do
|value, options| |value, options|
options[:help] = true options[:help] = true
@ -358,11 +358,11 @@ module Gem
# commands. Both options are actually handled before the other # commands. Both options are actually handled before the other
# options get parsed. # options get parsed.
add_common_option('--config-file FILE', add_common_option('--config-file FILE',
"Use this config file instead of default") do "Use this config file instead of default") do
end end
add_common_option('--backtrace', add_common_option('--backtrace',
'Show stack backtrace on errors') do 'Show stack backtrace on errors') do
end end

View File

@ -58,7 +58,11 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
end end
out << " - GEM PATHS:\n" out << " - GEM PATHS:\n"
Gem.path.each do |p| out << " - #{Gem.dir}\n"
path = Gem.path.dup
path.delete Gem.dir
path.each do |p|
out << " - #{p}\n" out << " - #{p}\n"
end end

View File

@ -18,18 +18,23 @@ module Gem
options[:all] = value options[:all] = value
end end
add_option('-i', '--[no-]ignore-dependencies', add_option('-I', '--[no-]ignore-dependencies',
'Ignore dependency requirements while', 'Ignore dependency requirements while',
'uninstalling') do |value, options| 'uninstalling') do |value, options|
options[:ignore] = value options[:ignore] = value
end end
add_option('-x', '--[no-]executables', add_option('-x', '--[no-]executables',
'Uninstall applicable executables without', 'Uninstall applicable executables without',
'confirmation') do |value, options| 'confirmation') do |value, options|
options[:executables] = value options[:executables] = value
end end
add_option('-i', '--install-dir DIR',
'Directory to uninstall gem from') do |value, options|
options[:install_dir] = File.expand_path(value)
end
add_version_option add_version_option
add_platform_option add_platform_option
end end
@ -39,7 +44,8 @@ module Gem
end end
def defaults_str # :nodoc: def defaults_str # :nodoc:
"--version '#{Gem::Requirement.default}' --no-force" "--version '#{Gem::Requirement.default}' --no-force " \
"--install-dir #{Gem.dir}"
end end
def usage # :nodoc: def usage # :nodoc:

View File

@ -11,8 +11,12 @@ class Gem::DependencyError < Gem::Exception; end
class Gem::DependencyRemovalException < Gem::Exception; end class Gem::DependencyRemovalException < Gem::Exception; end
##
# Raised when attempting to uninstall a gem that isn't in GEM_HOME.
class Gem::GemNotInHomeException < Gem::Exception; end
class Gem::DocumentError < Gem::Exception; end class Gem::DocumentError < Gem::Exception; end
## ##
# Potentially raised when a specification is validated. # Potentially raised when a specification is validated.
class Gem::EndOfYAMLException < Gem::Exception; end class Gem::EndOfYAMLException < Gem::Exception; end

View File

@ -37,7 +37,7 @@ module Gem::InstallUpdateOptions
options[:generate_ri] = value options[:generate_ri] = value
end end
add_option(:"Install/Update", '-E', '--env-shebang', add_option(:"Install/Update", '-E', '--[no-]env-shebang',
"Rewrite the shebang line on installed", "Rewrite the shebang line on installed",
"scripts to use /usr/bin/env") do |value, options| "scripts to use /usr/bin/env") do |value, options|
options[:env_shebang] = value options[:env_shebang] = value

View File

@ -63,6 +63,7 @@ class Gem::Installer
:force => false, :force => false,
:install_dir => Gem.dir, :install_dir => Gem.dir,
:exec_format => false, :exec_format => false,
:env_shebang => false
}.merge options }.merge options
@env_shebang = options[:env_shebang] @env_shebang = options[:env_shebang]

View File

@ -614,14 +614,16 @@ module Gem::Package
# this method would use the String IO approach on all platforms at all # this method would use the String IO approach on all platforms at all
# times. And that's the way it is. # times. And that's the way it is.
def zipped_stream(entry) def zipped_stream(entry)
# This is Jamis Buck's ZLib workaround. The original code is if defined? Rubinius then
# commented out while we evaluate this patch. zis = Zlib::GzipReader.new entry
entry.read(10) # skip the gzip header dis = zis.read
zis = Zlib::Inflate.new(-Zlib::MAX_WBITS) is = StringIO.new(dis)
is = StringIO.new(zis.inflate(entry.read)) else
# zis = Zlib::GzipReader.new entry # This is Jamis Buck's ZLib workaround for some unknown issue
# dis = zis.read entry.read(10) # skip the gzip header
# is = StringIO.new(dis) zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
is = StringIO.new(zis.inflate(entry.read))
end
ensure ensure
zis.finish if zis zis.finish if zis
end end

View File

@ -46,7 +46,7 @@ module Gem
if deprecated.empty? if deprecated.empty?
from_gems_in(*installed_spec_directories) from_gems_in(*installed_spec_directories)
else else
from_gems_in(*deprecated) from_gems_in(*deprecated) # HACK warn
end end
end end
@ -118,6 +118,7 @@ module Gem
def load_gems_in(*spec_dirs) def load_gems_in(*spec_dirs)
@gems.clear @gems.clear
specs = Dir.glob File.join("{#{spec_dirs.join(',')}}", "*.gemspec") specs = Dir.glob File.join("{#{spec_dirs.join(',')}}", "*.gemspec")
specs.each do |file_name| specs.each do |file_name|
gemspec = self.class.load_specification(file_name.untaint) gemspec = self.class.load_specification(file_name.untaint)
add_spec(gemspec) if gemspec add_spec(gemspec) if gemspec

View File

@ -457,7 +457,7 @@ module Gem
overwrite_accessor :default_executable do overwrite_accessor :default_executable do
begin begin
if defined? @default_executable and @default_executable if defined?(@default_executable) and @default_executable
result = @default_executable result = @default_executable
elsif @executables and @executables.size == 1 elsif @executables and @executables.size == 1
result = Array(@executables).first result = Array(@executables).first
@ -471,14 +471,12 @@ module Gem
end end
def add_bindir(executables) def add_bindir(executables)
if not defined? @executables || @executables.nil? return nil if executables.nil?
return nil
end
if defined? @bindir and @bindir then if @bindir then
Array(@executables).map {|e| File.join(@bindir, e) } Array(executables).map { |e| File.join(@bindir, e) }
else else
@executables executables
end end
rescue rescue
return nil return nil
@ -511,7 +509,7 @@ module Gem
@test_files = [@test_suite_file].flatten @test_files = [@test_suite_file].flatten
@test_suite_file = nil @test_suite_file = nil
end end
if defined? @test_files and @test_files then if defined?(@test_files) and @test_files then
@test_files @test_files
else else
@test_files = [] @test_files = []
@ -903,7 +901,7 @@ module Gem
# Also, the summary and description are converted to a normal # Also, the summary and description are converted to a normal
# format. # format.
def normalize def normalize
if defined? @extra_rdoc_files and @extra_rdoc_files then if defined?(@extra_rdoc_files) and @extra_rdoc_files then
@extra_rdoc_files.uniq! @extra_rdoc_files.uniq!
@files ||= [] @files ||= []
@files.concat(@extra_rdoc_files) @files.concat(@extra_rdoc_files)

View File

@ -25,6 +25,8 @@ class Gem::Uninstaller
def initialize(gem, options) def initialize(gem, options)
@gem = gem @gem = gem
@version = options[:version] || Gem::Requirement.default @version = options[:version] || Gem::Requirement.default
gem_home = options[:install_dir] || Gem.dir
@gem_home = File.expand_path gem_home
@force_executables = options[:executables] @force_executables = options[:executables]
@force_all = options[:all] @force_all = options[:all]
@force_ignore = options[:ignore] @force_ignore = options[:ignore]
@ -71,31 +73,38 @@ class Gem::Uninstaller
# #
def remove_executables(gemspec) def remove_executables(gemspec)
return if gemspec.nil? return if gemspec.nil?
if(gemspec.executables.size > 0)
raise Gem::FilePermissionError.new(Gem.bindir) unless if gemspec.executables.size > 0 then
File.writable?(Gem.bindir) bindir = Gem.bindir @gem_home
raise Gem::FilePermissionError, bindir unless File.writable? bindir
list = Gem.source_index.search(gemspec.name).delete_if { |spec| list = Gem.source_index.search(gemspec.name).delete_if { |spec|
spec.version == gemspec.version spec.version == gemspec.version
} }
executables = gemspec.executables.clone executables = gemspec.executables.clone
list.each do |spec| list.each do |spec|
spec.executables.each do |exe_name| spec.executables.each do |exe_name|
executables.delete(exe_name) executables.delete(exe_name)
end end
end end
return if executables.size == 0 return if executables.size == 0
answer = @force_executables || ask_yes_no( answer = @force_executables || ask_yes_no(
"Remove executables and scripts for\n" + "Remove executables:\n" \
"'#{gemspec.executables.join(", ")}' in addition to the gem?", "\t#{gemspec.executables.join(", ")}\n\nin addition to the gem?",
true) # " # appease ruby-mode - don't ask true) # " # appease ruby-mode - don't ask
unless answer
unless answer then
say "Executables and scripts will remain installed." say "Executables and scripts will remain installed."
return
else else
gemspec.executables.each do |exe_name| gemspec.executables.each do |exe_name|
say "Removing #{exe_name}" say "Removing #{exe_name}"
File.unlink File.join(Gem.bindir, exe_name) rescue nil FileUtils.rm_f File.join(bindir, exe_name)
File.unlink File.join(Gem.bindir, exe_name + ".bat") rescue nil FileUtils.rm_f File.join(bindir, "#{exe_name}.bat")
end end
end end
end end
@ -119,11 +128,18 @@ class Gem::Uninstaller
# uninstalled a gem, it is removed from that list. # uninstalled a gem, it is removed from that list.
# #
def remove(spec, list) def remove(spec, list)
unless ok_to_remove? spec then unless dependencies_ok? spec then
raise Gem::DependencyRemovalException, raise Gem::DependencyRemovalException,
"Uninstallation aborted due to dependent gem(s)" "Uninstallation aborted due to dependent gem(s)"
end end
unless path_ok? spec then
alert("In order to remove #{spec.name}, please execute:\n" \
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
raise Gem::GemNotInHomeException,
"Gem is not installed in directory #{@gem_home}"
end
raise Gem::FilePermissionError, spec.installation_path unless raise Gem::FilePermissionError, spec.installation_path unless
File.writable?(spec.installation_path) File.writable?(spec.installation_path)
@ -157,7 +173,13 @@ class Gem::Uninstaller
list.delete spec list.delete spec
end end
def ok_to_remove?(spec) def path_ok?(spec)
match_path = File.join @gem_home, 'gems', spec.full_name
match_path == spec.full_gem_path
end
def dependencies_ok?(spec)
return true if @force_ignore return true if @force_ignore
srcindex = Gem::SourceIndex.from_installed_gems srcindex = Gem::SourceIndex.from_installed_gems

View File

@ -75,7 +75,7 @@ module Gem
ui.#{methname}(*args) ui.#{methname}(*args)
end end
} }
end end
end end
#################################################################### ####################################################################

View File

@ -1,4 +1,3 @@
require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems' require 'rubygems'
require 'rubygems/gem_openssl' require 'rubygems/gem_openssl'
@ -75,6 +74,8 @@ class TestGem < RubyGemTestCase
install_gem foo install_gem foo
end end
Gem.source_index = nil
gem 'foo' gem 'foo'
expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo' expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
@ -280,9 +281,7 @@ class TestGem < RubyGemTestCase
def test_self_prefix def test_self_prefix
file_name = File.expand_path __FILE__ file_name = File.expand_path __FILE__
expected = File.dirname File.dirname(file_name) assert_equal File.dirname(File.dirname(file_name)), Gem.prefix
expected = File.dirname expected if expected =~ %r|/test| # for Ruby trunk
assert_equal expected, Gem.prefix
end end
def test_self_required_location def test_self_required_location

View File

@ -3,6 +3,10 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems/commands/cert_command' require 'rubygems/commands/cert_command'
unless defined? OpenSSL then
warn "`gem cert` tests are being skipped, module OpenSSL not found"
end
class TestGemCommandsCertCommand < RubyGemTestCase class TestGemCommandsCertCommand < RubyGemTestCase
def setup def setup
@ -118,5 +122,5 @@ class TestGemCommandsCertCommand < RubyGemTestCase
# HACK this test sucks # HACK this test sucks
end end
end end if defined? OpenSSL

View File

@ -25,7 +25,8 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|, assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
@ui.output @ui.output
assert_match %r|RUBYGEMS PREFIX: |, @ui.output assert_match %r|RUBYGEMS PREFIX: |, @ui.output
assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:RUBY_INSTALL_NAME]}|,
@ui.output
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
assert_match %r|- #{Gem::Platform.local}|, @ui.output assert_match %r|- #{Gem::Platform.local}|, @ui.output
assert_match %r|GEM PATHS:|, @ui.output assert_match %r|GEM PATHS:|, @ui.output

View File

@ -1,5 +1,7 @@
require 'test/unit' require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems/package'
require 'rubygems/security'
require 'rubygems/commands/fetch_command' require 'rubygems/commands/fetch_command'
class TestGemCommandsFetchCommand < RubyGemTestCase class TestGemCommandsFetchCommand < RubyGemTestCase

View File

@ -85,7 +85,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
@cmd.execute @cmd.execute
end end
assert_equal "#{foo.to_yaml}\n", @ui.output assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output
assert_match %r|name: foo|, @ui.output
assert_equal "WARNING: Remote information is not complete\n\n", @ui.error assert_equal "WARNING: Remote information is not complete\n\n", @ui.error
end end

View File

@ -288,19 +288,21 @@ class TestGemDependencyInstaller < RubyGemTestCase
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name } assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
end end
def test_install_security_policy if defined? OpenSSL then
FileUtils.mv @a1_gem, @cache_dir def test_install_security_policy
FileUtils.mv @b1_gem, @cache_dir FileUtils.mv @a1_gem, @cache_dir
policy = Gem::Security::HighSecurity FileUtils.mv @b1_gem, @cache_dir
inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy policy = Gem::Security::HighSecurity
inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy
e = assert_raise Gem::Exception do e = assert_raise Gem::Exception do
inst.install inst.install
end
assert_equal 'Unsigned gem', e.message
assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
end end
assert_equal 'Unsigned gem', e.message
assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
end end
def test_install_wrappers def test_install_wrappers

View File

@ -271,7 +271,7 @@ gems:
fetcher.fetch_path 'uri' fetcher.fetch_path 'uri'
end end
assert_match %r|\AErrno::ECONNREFUSED: .* - connect\(2\) reading uri\z|, assert_match %r|ECONNREFUSED:.*connect\(2\) reading uri\z|,
e.message e.message
end end

View File

@ -53,10 +53,10 @@ class TestGemServer < RubyGemTestCase
assert_equal 200, @res.status, @res.body assert_equal 200, @res.status, @res.body
assert @res['date'] assert @res['date']
assert_equal 'text/plain', @res['content-type'] assert_equal 'text/plain', @res['content-type']
yaml = Zlib::Inflate.inflate(@res.body)
assert_match %r|Gem::Specification|, yaml spec = YAML.load Zlib::Inflate.inflate(@res.body)
assert_match %r|name: a|, yaml assert_equal 'a', spec.name
assert_match %r|version: "1"|, yaml assert_equal Gem::Version.new(1), spec.version
end end
def test_quick_a_1_mswin32_gemspec_rz def test_quick_a_1_mswin32_gemspec_rz
@ -72,10 +72,11 @@ class TestGemServer < RubyGemTestCase
assert_equal 200, @res.status, @res.body assert_equal 200, @res.status, @res.body
assert @res['date'] assert @res['date']
assert_equal 'text/plain', @res['content-type'] assert_equal 'text/plain', @res['content-type']
yaml = Zlib::Inflate.inflate(@res.body)
assert_match %r|Gem::Specification|, yaml spec = YAML.load Zlib::Inflate.inflate(@res.body)
assert_match %r|name: a|, yaml assert_equal 'a', spec.name
assert_match %r|version: "1"|, yaml assert_equal Gem::Version.new(1), spec.version
assert_equal Gem::Platform.local, spec.platform
end end
def test_quick_common_substrings def test_quick_common_substrings
@ -91,10 +92,10 @@ class TestGemServer < RubyGemTestCase
assert_equal 200, @res.status, @res.body assert_equal 200, @res.status, @res.body
assert @res['date'] assert @res['date']
assert_equal 'text/plain', @res['content-type'] assert_equal 'text/plain', @res['content-type']
yaml = Zlib::Inflate.inflate @res.body
assert_match %r|Gem::Specification|, yaml spec = YAML.load Zlib::Inflate.inflate(@res.body)
assert_match %r|name: a$|, yaml assert_equal 'a', spec.name
assert_match %r|version: "1"|, yaml assert_equal Gem::Version.new(1), spec.version
end end
def test_quick_z_9_gemspec_rz def test_quick_z_9_gemspec_rz

View File

@ -401,7 +401,7 @@ class TestGemSourceIndex < RubyGemTestCase
def test_update_with_missing def test_update_with_missing
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}", marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
"#{@gem3.full_name}.gemspec.rz" "#{@gem3.full_name}.gemspec.rz"
dumped = Marshal.dump(@gem3) dumped = Marshal.dump @gem3
@fetcher.data[marshal_uri] = util_zip(dumped) @fetcher.data[marshal_uri] = util_zip(dumped)
use_ui @ui do use_ui @ui do

View File

@ -185,7 +185,7 @@ class TestGemVersion < RubyGemTestCase
def assert_adequate(version, requirement) def assert_adequate(version, requirement)
ver = Gem::Version.new(version) ver = Gem::Version.new(version)
req = Gem::Version::Requirement.new(requirement) req = Gem::Requirement.new(requirement)
assert req.satisfied_by?(ver), assert req.satisfied_by?(ver),
"Version #{version} should be adequate for Requirement #{requirement}" "Version #{version} should be adequate for Requirement #{requirement}"
end end

View File

@ -7,6 +7,7 @@
require 'test/unit' require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems/package'
class TestKernel < RubyGemTestCase class TestKernel < RubyGemTestCase