summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rwxr-xr-xbin/gem2
-rw-r--r--gem_prelude.rb8
-rw-r--r--lib/rubygems.rb26
-rw-r--r--lib/rubygems/command.rb18
-rw-r--r--lib/rubygems/commands/environment_command.rb6
-rw-r--r--lib/rubygems/commands/uninstall_command.rb16
-rw-r--r--lib/rubygems/exceptions.rb6
-rw-r--r--lib/rubygems/install_update_options.rb2
-rw-r--r--lib/rubygems/installer.rb1
-rw-r--r--lib/rubygems/package.rb18
-rw-r--r--lib/rubygems/source_index.rb3
-rw-r--r--lib/rubygems/specification.rb16
-rw-r--r--lib/rubygems/uninstaller.rb44
-rw-r--r--lib/rubygems/user_interaction.rb2
-rw-r--r--test/rubygems/test_gem.rb7
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb3
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb3
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb24
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb2
-rw-r--r--test/rubygems/test_gem_server.rb25
-rw-r--r--test/rubygems/test_gem_source_index.rb2
-rw-r--r--test/rubygems/test_gem_version.rb2
-rw-r--r--test/rubygems/test_kernel.rb1
26 files changed, 165 insertions, 85 deletions
diff --git a/ChangeLog b/ChangeLog
index 84a06495fe..fdb0a8ba69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* {bcc32,win32,wince}/Makefile.sub (MISSING): added cbrt.obj.
diff --git a/bin/gem b/bin/gem
index 5478606c52..aa8db57b51 100755
--- a/bin/gem
+++ b/bin/gem
@@ -8,7 +8,7 @@
require 'rubygems'
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
abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
diff --git a/gem_prelude.rb b/gem_prelude.rb
index 63f979ccab..1b4ef4409e 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -166,7 +166,13 @@ module Gem
require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib"))
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']
$:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths
end
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index e25e05a3b8..9549b9bdca 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -290,6 +290,24 @@ module Gem
@ruby
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
# must satisfy all the specified version constraints. If
# +autorequire+ is true, then automatically require the specified
@@ -345,11 +363,13 @@ module Gem
end
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']
- $LOAD_PATH.insert(sitelibdir_index, *require_paths)
+ $LOAD_PATH.insert(insert_index, *require_paths)
else
# we are probably testing in core, -I and RUBYLIB don't apply
$LOAD_PATH.unshift(*require_paths)
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 66855c7c6a..61ed617cc6 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -136,7 +136,7 @@ module Gem
execute
end
end
-
+
# Call the given block when invoked.
#
# Normal command invocations just executes the +execute+ method of
@@ -146,7 +146,7 @@ module Gem
def when_invoked(&block)
@when_invoked = block
end
-
+
# Add a command-line option and handler to the command.
#
# See OptionParser#make_switch for an explanation of +opts+.
@@ -165,7 +165,7 @@ module Gem
option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
end
end
-
+
# Merge a set of command options with the set of default options
# (without modifying the default option hash).
def merge_options(new_options)
@@ -191,7 +191,7 @@ module Gem
parser.parse!(args)
@options[:args] = args
end
-
+
def add_extra_args(args)
result = []
s_extra = Command.specific_extra_args(@command)
@@ -291,7 +291,7 @@ module Gem
def common_options
@common_options ||= []
end
-
+
def add_common_option(*args, &handler)
Gem::Command.common_options << [args, handler]
end
@@ -315,7 +315,7 @@ module Gem
def specific_extra_args(cmd)
specific_extra_args_hash[cmd]
end
-
+
# Add a list of extra arguments for the given command. +args+
# may be an array or a string to be split on white space.
def add_specific_extra_args(cmd,args)
@@ -334,7 +334,7 @@ module Gem
# ----------------------------------------------------------------
# Add the options common to all commands.
- add_common_option('-h', '--help',
+ add_common_option('-h', '--help',
'Get help on this command') do
|value, options|
options[:help] = true
@@ -358,11 +358,11 @@ module Gem
# commands. Both options are actually handled before the other
# options get parsed.
- add_common_option('--config-file FILE',
+ add_common_option('--config-file FILE',
"Use this config file instead of default") do
end
- add_common_option('--backtrace',
+ add_common_option('--backtrace',
'Show stack backtrace on errors') do
end
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index 337d74893b..ab85361753 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -58,7 +58,11 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
end
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"
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 7d2908836c..2d9c46ee52 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -18,18 +18,23 @@ module Gem
options[:all] = value
end
- add_option('-i', '--[no-]ignore-dependencies',
- 'Ignore dependency requirements while',
- 'uninstalling') do |value, options|
+ add_option('-I', '--[no-]ignore-dependencies',
+ 'Ignore dependency requirements while',
+ 'uninstalling') do |value, options|
options[:ignore] = value
end
- add_option('-x', '--[no-]executables',
+ add_option('-x', '--[no-]executables',
'Uninstall applicable executables without',
'confirmation') do |value, options|
options[:executables] = value
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_platform_option
end
@@ -39,7 +44,8 @@ module Gem
end
def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}' --no-force"
+ "--version '#{Gem::Requirement.default}' --no-force " \
+ "--install-dir #{Gem.dir}"
end
def usage # :nodoc:
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 294dad5748..b34bc718ff 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -11,8 +11,12 @@ class Gem::DependencyError < 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
-
+
##
# Potentially raised when a specification is validated.
class Gem::EndOfYAMLException < Gem::Exception; end
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index b93e21551c..af6be423f6 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -37,7 +37,7 @@ module Gem::InstallUpdateOptions
options[:generate_ri] = value
end
- add_option(:"Install/Update", '-E', '--env-shebang',
+ add_option(:"Install/Update", '-E', '--[no-]env-shebang',
"Rewrite the shebang line on installed",
"scripts to use /usr/bin/env") do |value, options|
options[:env_shebang] = value
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index e652ac9c6d..552a803c12 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -63,6 +63,7 @@ class Gem::Installer
:force => false,
:install_dir => Gem.dir,
:exec_format => false,
+ :env_shebang => false
}.merge options
@env_shebang = options[:env_shebang]
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index ee136b6267..f15e4feecb 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -614,14 +614,16 @@ module Gem::Package
# this method would use the String IO approach on all platforms at all
# times. And that's the way it is.
def zipped_stream(entry)
- # This is Jamis Buck's ZLib workaround. The original code is
- # commented out while we evaluate this patch.
- entry.read(10) # skip the gzip header
- zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
- is = StringIO.new(zis.inflate(entry.read))
- # zis = Zlib::GzipReader.new entry
- # dis = zis.read
- # is = StringIO.new(dis)
+ if defined? Rubinius then
+ zis = Zlib::GzipReader.new entry
+ dis = zis.read
+ is = StringIO.new(dis)
+ else
+ # This is Jamis Buck's ZLib workaround for some unknown issue
+ entry.read(10) # skip the gzip header
+ zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
+ is = StringIO.new(zis.inflate(entry.read))
+ end
ensure
zis.finish if zis
end
diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb
index 2df28d9561..1283f8f904 100644
--- a/lib/rubygems/source_index.rb
+++ b/lib/rubygems/source_index.rb
@@ -46,7 +46,7 @@ module Gem
if deprecated.empty?
from_gems_in(*installed_spec_directories)
else
- from_gems_in(*deprecated)
+ from_gems_in(*deprecated) # HACK warn
end
end
@@ -118,6 +118,7 @@ module Gem
def load_gems_in(*spec_dirs)
@gems.clear
specs = Dir.glob File.join("{#{spec_dirs.join(',')}}", "*.gemspec")
+
specs.each do |file_name|
gemspec = self.class.load_specification(file_name.untaint)
add_spec(gemspec) if gemspec
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 6338e73a1d..be03150c96 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -457,7 +457,7 @@ module Gem
overwrite_accessor :default_executable do
begin
- if defined? @default_executable and @default_executable
+ if defined?(@default_executable) and @default_executable
result = @default_executable
elsif @executables and @executables.size == 1
result = Array(@executables).first
@@ -471,14 +471,12 @@ module Gem
end
def add_bindir(executables)
- if not defined? @executables || @executables.nil?
- return nil
- end
+ return nil if executables.nil?
- if defined? @bindir and @bindir then
- Array(@executables).map {|e| File.join(@bindir, e) }
+ if @bindir then
+ Array(executables).map { |e| File.join(@bindir, e) }
else
- @executables
+ executables
end
rescue
return nil
@@ -511,7 +509,7 @@ module Gem
@test_files = [@test_suite_file].flatten
@test_suite_file = nil
end
- if defined? @test_files and @test_files then
+ if defined?(@test_files) and @test_files then
@test_files
else
@test_files = []
@@ -903,7 +901,7 @@ module Gem
# Also, the summary and description are converted to a normal
# format.
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!
@files ||= []
@files.concat(@extra_rdoc_files)
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 268c0b3b83..1c979d8573 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -25,6 +25,8 @@ class Gem::Uninstaller
def initialize(gem, options)
@gem = gem
@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_all = options[:all]
@force_ignore = options[:ignore]
@@ -71,31 +73,38 @@ class Gem::Uninstaller
#
def remove_executables(gemspec)
return if gemspec.nil?
- if(gemspec.executables.size > 0)
- raise Gem::FilePermissionError.new(Gem.bindir) unless
- File.writable?(Gem.bindir)
+
+ if gemspec.executables.size > 0 then
+ bindir = Gem.bindir @gem_home
+
+ raise Gem::FilePermissionError, bindir unless File.writable? bindir
+
list = Gem.source_index.search(gemspec.name).delete_if { |spec|
spec.version == gemspec.version
}
+
executables = gemspec.executables.clone
+
list.each do |spec|
spec.executables.each do |exe_name|
executables.delete(exe_name)
end
end
+
return if executables.size == 0
+
answer = @force_executables || ask_yes_no(
- "Remove executables and scripts for\n" +
- "'#{gemspec.executables.join(", ")}' in addition to the gem?",
+ "Remove executables:\n" \
+ "\t#{gemspec.executables.join(", ")}\n\nin addition to the gem?",
true) # " # appease ruby-mode - don't ask
- unless answer
+
+ unless answer then
say "Executables and scripts will remain installed."
- return
else
gemspec.executables.each do |exe_name|
say "Removing #{exe_name}"
- File.unlink File.join(Gem.bindir, exe_name) rescue nil
- File.unlink File.join(Gem.bindir, exe_name + ".bat") rescue nil
+ FileUtils.rm_f File.join(bindir, exe_name)
+ FileUtils.rm_f File.join(bindir, "#{exe_name}.bat")
end
end
end
@@ -119,11 +128,18 @@ class Gem::Uninstaller
# uninstalled a gem, it is removed from that list.
#
def remove(spec, list)
- unless ok_to_remove? spec then
+ unless dependencies_ok? spec then
raise Gem::DependencyRemovalException,
"Uninstallation aborted due to dependent gem(s)"
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
File.writable?(spec.installation_path)
@@ -157,7 +173,13 @@ class Gem::Uninstaller
list.delete spec
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
srcindex = Gem::SourceIndex.from_installed_gems
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 7ff03eaadf..4970f33c00 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -75,7 +75,7 @@ module Gem
ui.#{methname}(*args)
end
}
- end
+ end
end
####################################################################
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 41b127ce39..e0160950f8 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1,4 +1,3 @@
-require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems'
require 'rubygems/gem_openssl'
@@ -75,6 +74,8 @@ class TestGem < RubyGemTestCase
install_gem foo
end
+ Gem.source_index = nil
+
gem 'foo'
expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
@@ -280,9 +281,7 @@ class TestGem < RubyGemTestCase
def test_self_prefix
file_name = File.expand_path __FILE__
- expected = File.dirname File.dirname(file_name)
- expected = File.dirname expected if expected =~ %r|/test| # for Ruby trunk
- assert_equal expected, Gem.prefix
+ assert_equal File.dirname(File.dirname(file_name)), Gem.prefix
end
def test_self_required_location
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index 09a401e4f7..79e3e72158 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -3,6 +3,10 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
require 'rubygems/commands/cert_command'
+unless defined? OpenSSL then
+ warn "`gem cert` tests are being skipped, module OpenSSL not found"
+end
+
class TestGemCommandsCertCommand < RubyGemTestCase
def setup
@@ -118,5 +122,5 @@ class TestGemCommandsCertCommand < RubyGemTestCase
# HACK this test sucks
end
-end
+end if defined? OpenSSL
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index 65c8cf3133..0913888a6d 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -25,7 +25,8 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
@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|- #{Gem::Platform.local}|, @ui.output
assert_match %r|GEM PATHS:|, @ui.output
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 3aa9119378..d8651680b0 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -1,5 +1,7 @@
require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
+require 'rubygems/package'
+require 'rubygems/security'
require 'rubygems/commands/fetch_command'
class TestGemCommandsFetchCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb
index 3741446536..c8f57fef58 100644
--- a/test/rubygems/test_gem_commands_specification_command.rb
+++ b/test/rubygems/test_gem_commands_specification_command.rb
@@ -85,7 +85,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
@cmd.execute
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
end
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index c299476eeb..d2d33fa313 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -288,19 +288,21 @@ class TestGemDependencyInstaller < RubyGemTestCase
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
end
- def test_install_security_policy
- FileUtils.mv @a1_gem, @cache_dir
- FileUtils.mv @b1_gem, @cache_dir
- policy = Gem::Security::HighSecurity
- inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy
-
- e = assert_raise Gem::Exception do
- inst.install
- end
+ if defined? OpenSSL then
+ def test_install_security_policy
+ FileUtils.mv @a1_gem, @cache_dir
+ FileUtils.mv @b1_gem, @cache_dir
+ policy = Gem::Security::HighSecurity
+ inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy
+
+ e = assert_raise Gem::Exception do
+ inst.install
+ end
- assert_equal 'Unsigned gem', e.message
+ assert_equal 'Unsigned gem', e.message
- assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
+ assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
+ end
end
def test_install_wrappers
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index fd3843851a..5ffaed24e3 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -271,7 +271,7 @@ gems:
fetcher.fetch_path 'uri'
end
- assert_match %r|\AErrno::ECONNREFUSED: .* - connect\(2\) reading uri\z|,
+ assert_match %r|ECONNREFUSED:.*connect\(2\) reading uri\z|,
e.message
end
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index c283e661dc..463ce35180 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -53,10 +53,10 @@ class TestGemServer < RubyGemTestCase
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
+
+ spec = YAML.load Zlib::Inflate.inflate(@res.body)
+ assert_equal 'a', spec.name
+ assert_equal Gem::Version.new(1), spec.version
end
def test_quick_a_1_mswin32_gemspec_rz
@@ -72,10 +72,11 @@ class TestGemServer < RubyGemTestCase
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
+
+ spec = YAML.load Zlib::Inflate.inflate(@res.body)
+ assert_equal 'a', spec.name
+ assert_equal Gem::Version.new(1), spec.version
+ assert_equal Gem::Platform.local, spec.platform
end
def test_quick_common_substrings
@@ -91,10 +92,10 @@ class TestGemServer < RubyGemTestCase
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
+
+ spec = YAML.load Zlib::Inflate.inflate(@res.body)
+ assert_equal 'a', spec.name
+ assert_equal Gem::Version.new(1), spec.version
end
def test_quick_z_9_gemspec_rz
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
index 45f59f2430..8fc8449814 100644
--- a/test/rubygems/test_gem_source_index.rb
+++ b/test/rubygems/test_gem_source_index.rb
@@ -401,7 +401,7 @@ class TestGemSourceIndex < RubyGemTestCase
def test_update_with_missing
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
"#{@gem3.full_name}.gemspec.rz"
- dumped = Marshal.dump(@gem3)
+ dumped = Marshal.dump @gem3
@fetcher.data[marshal_uri] = util_zip(dumped)
use_ui @ui do
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
index 99dd49933d..27c522c3d7 100644
--- a/test/rubygems/test_gem_version.rb
+++ b/test/rubygems/test_gem_version.rb
@@ -185,7 +185,7 @@ class TestGemVersion < RubyGemTestCase
def assert_adequate(version, requirement)
ver = Gem::Version.new(version)
- req = Gem::Version::Requirement.new(requirement)
+ req = Gem::Requirement.new(requirement)
assert req.satisfied_by?(ver),
"Version #{version} should be adequate for Requirement #{requirement}"
end
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
index e06a78e32a..3c6448e470 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -7,6 +7,7 @@
require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
+require 'rubygems/package'
class TestKernel < RubyGemTestCase