summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-08 22:41:03 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-08 22:41:03 +0000
commit7083cebeaea83096128fc5ccb5f60bfbe5bcc939 (patch)
treefb25c12a6cc01a1a8de5221d64da632418e194a3
parentfa343a796fd256fc9098db7fdddf226fe5cbd181 (diff)
* lib/rubygems: Update to RubyGems 2.0.4. See
https://github.com/rubygems/rubygems/blob/2.0/History.txt for changes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/rubygems.rb9
-rw-r--r--lib/rubygems/commands/help_command.rb10
-rw-r--r--lib/rubygems/commands/list_command.rb10
-rw-r--r--lib/rubygems/commands/owner_command.rb2
-rw-r--r--lib/rubygems/commands/pristine_command.rb9
-rw-r--r--lib/rubygems/commands/push_command.rb3
-rw-r--r--lib/rubygems/commands/search_command.rb20
-rw-r--r--lib/rubygems/commands/setup_command.rb58
-rw-r--r--lib/rubygems/commands/specification_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb2
-rwxr-xr-xlib/rubygems/core_ext/kernel_require.rb8
-rw-r--r--lib/rubygems/defaults.rb4
-rw-r--r--lib/rubygems/dependency_installer.rb1
-rw-r--r--lib/rubygems/dependency_resolver.rb2
-rw-r--r--lib/rubygems/errors.rb4
-rw-r--r--lib/rubygems/gemcutter_utilities.rb18
-rw-r--r--lib/rubygems/installer.rb11
-rw-r--r--lib/rubygems/package.rb1
-rw-r--r--lib/rubygems/platform.rb2
-rw-r--r--lib/rubygems/specification.rb50
-rw-r--r--test/rubygems/test_gem.rb6
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb12
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb16
-rw-r--r--test/rubygems/test_gem_commands_search_command.rb25
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb52
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb23
-rw-r--r--test/rubygems/test_gem_installer.rb14
-rw-r--r--test/rubygems/test_gem_package.rb3
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb4
-rw-r--r--test/rubygems/test_gem_specification.rb26
32 files changed, 306 insertions, 111 deletions
diff --git a/ChangeLog b/ChangeLog
index 327ed87..6c2e912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 9 07:39:45 2013 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems: Update to RubyGems 2.0.4. See
+ https://github.com/rubygems/rubygems/blob/2.0/History.txt for changes
+
Tue Jul 9 01:47:16 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 3622f71..2c8dbee 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = '2.0.3'
+ VERSION = '2.0.4'
end
# Must be first since it unloads the prelude from 1.9.2
@@ -173,7 +173,12 @@ module Gem
# require will try to activate the more specific version.
spec = Gem::Specification.find_inactive_by_path path
- return false unless spec
+
+ unless spec
+ spec = Gem::Specification.find_by_path path
+ return true if spec && spec.activated?
+ return false
+ end
begin
spec.activate
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 8e3d97e..7f1fb48 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -113,7 +113,15 @@ platform.
format = "#{' ' * margin_width}%-#{desc_width}s%s"
command_manager.command_names.each do |cmd_name|
- summary = command_manager[cmd_name].summary
+ command = command_manager[cmd_name]
+
+ summary =
+ if command then
+ command.summary
+ else
+ "[No command found for #{cmd_name}, bug?]"
+ end
+
summary = wrap(summary, summary_width).split "\n"
out << sprintf(format, cmd_name, summary.shift)
until summary.empty? do
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index d9b7a95..f3e5da9 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -7,9 +7,8 @@ require 'rubygems/commands/query_command'
class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
- def initialize(name = 'list',
- summary = 'Display gems whose name starts with STRING')
- super name, summary
+ def initialize
+ super 'list', 'Display gems whose name starts with STRING'
remove_option('--name-matches')
end
@@ -27,9 +26,8 @@ class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
end
def execute
- name = get_one_optional_argument || ''
- options[:name] = /^#{name}/i
-
+ string = get_one_optional_argument || ''
+ options[:name] = /^#{string}/i
super
end
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 9267413..11e6e02 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -73,7 +73,7 @@ class Gem::Commands::OwnerCommand < Gem::Command
request.add_field "Authorization", api_key
end
- with_response response
+ with_response response, "Removing #{owner}"
rescue
# ignore
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index f7eb901..f22fe11 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -10,7 +10,8 @@ class Gem::Commands::PristineCommand < Gem::Command
def initialize
super 'pristine',
'Restores installed gems to pristine condition from files located in the gem cache',
- :version => Gem::Requirement.default, :extensions => true,
+ :version => Gem::Requirement.default,
+ :extensions => true,
:all => false
add_option('--all',
@@ -37,7 +38,7 @@ class Gem::Commands::PristineCommand < Gem::Command
end
def defaults_str # :nodoc:
- "--all --extensions"
+ '--extensions'
end
def description # :nodoc:
@@ -52,8 +53,8 @@ for the gem are regenerated.
If the cached gem cannot be found, you will need to use `gem install` to
revert the gem.
-If --no-extensions is provided pristine will not attempt to restore gems with
-extensions.
+If --no-extensions is provided pristine will not attempt to restore gems
+with extensions.
EOF
end
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 2df00b0..fccad20 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -20,7 +20,8 @@ class Gem::Commands::PushCommand < Gem::Command
end
def initialize
- super 'push', description
+ super 'push', description, :host => self.host
+
add_proxy_option
add_key_option
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 92d4b36..7810c85 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -1,17 +1,31 @@
require 'rubygems/command'
-require 'rubygems/commands/list_command'
+require 'rubygems/commands/query_command'
-class Gem::Commands::SearchCommand < Gem::Commands::ListCommand
+class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
def initialize
super 'search', 'Display all gems whose name contains STRING'
- @defaults[:domain] = :remote
+ remove_option '--name-matches'
+ end
+
+ def arguments # :nodoc:
+ "STRING fragment of gem name to search for"
end
def defaults_str # :nodoc:
"--remote --no-details"
end
+ def usage # :nodoc:
+ "#{program_name} [STRING]"
+ end
+
+ def execute
+ string = get_one_optional_argument
+ options[:name] = /#{string}/i
+ super
+ end
+
end
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 1cdc9f4c..face77f 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -159,29 +159,7 @@ By default, this RubyGems will install gem as:
options[:previous_version] = Gem::Version.new(options[:previous_version])
- release_notes = File.join Dir.pwd, 'History.txt'
-
- release_notes = if File.exist? release_notes then
- history = File.read release_notes
- history = history.sub(/^# coding:.*?^=/m, '')
-
- text = history.split(HISTORY_HEADER)
- text.shift # correct an off-by-one generated by split
- version_lines = history.scan(HISTORY_HEADER)
- versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) }
-
- history_string = ""
-
- until versions.length == 0 or versions.shift < options[:previous_version]
- history_string += version_lines.shift + text.shift
- end
-
- history_string
- else
- "Oh-no! Unable to find release notes!"
- end
-
- say release_notes
+ show_release_notes
say
say "-" * 78
@@ -458,6 +436,40 @@ abort "#{deprecation_message}"
end
end
+ def show_release_notes
+ release_notes = File.join Dir.pwd, 'History.txt'
+
+ release_notes =
+ if File.exist? release_notes then
+ history = File.read release_notes
+
+ history.force_encoding Encoding::UTF_8 if
+ Object.const_defined? :Encoding
+
+ history = history.sub(/^# coding:.*?^=/m, '')
+
+ text = history.split(HISTORY_HEADER)
+ text.shift # correct an off-by-one generated by split
+ version_lines = history.scan(HISTORY_HEADER)
+ versions = history.scan(VERSION_MATCHER).flatten.map do |x|
+ Gem::Version.new(x)
+ end
+
+ history_string = ""
+
+ until versions.length == 0 or
+ versions.shift < options[:previous_version] do
+ history_string += version_lines.shift + text.shift
+ end
+
+ history_string
+ else
+ "Oh-no! Unable to find release notes!"
+ end
+
+ say release_notes
+ end
+
def uninstall_old_gemcutter
require 'rubygems/uninstaller'
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 63da5fe..b40dfd5 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -28,7 +28,7 @@ class Gem::Commands::SpecificationCommand < Gem::Command
options[:format] = :ruby
end
- add_option('--yaml', 'Output RUBY format') do |value, options|
+ add_option('--yaml', 'Output YAML format') do |value, options|
options[:format] = :yaml
end
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 66aef49..a31de00 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -94,7 +94,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
say "Updating #{name}"
begin
- @installer.install name, version
+ @installer.install name, Gem::Requirement.new(version)
success = true
rescue Gem::InstallError => e
alert_error "Error installing #{name}:\n\t#{e.message}"
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index e6dfce6..7106241 100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -4,6 +4,8 @@
# See LICENSE.txt for permissions.
#++
+require 'monitor'
+
module Kernel
if defined?(gem_original_require) then
@@ -31,7 +33,11 @@ module Kernel
# The normal <tt>require</tt> functionality of returning false if
# that file has already been loaded is preserved.
+ ACTIVATION_MONITOR = Monitor.new
+
def require path
+ ACTIVATION_MONITOR.enter
+
spec = Gem.find_unresolved_default_spec(path)
if spec
Gem.remove_unresolved_default_spec(spec)
@@ -111,6 +117,8 @@ module Kernel
end
raise load_error
+ ensure
+ ACTIVATION_MONITOR.exit
end
private :require
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 9c5e303..cc8dc72 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -54,7 +54,9 @@ module Gem
# Path for gems in the user's home directory
def self.user_dir
- File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version]
+ parts = [Gem.user_home, '.gem', ruby_engine]
+ parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty?
+ File.join parts
end
##
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 256c91e..6f19a31 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -63,7 +63,6 @@ class Gem::DependencyInstaller
# HACK shouldn't change the global settings, needed for -i behavior
# maybe move to the install command? See also github #442
Gem::Specification.dirs = @install_dir
- Gem.ensure_gem_subdirectories @install_dir
end
options = DEFAULT_OPTIONS.merge options
diff --git a/lib/rubygems/dependency_resolver.rb b/lib/rubygems/dependency_resolver.rb
index e8b620f..66f55eb 100644
--- a/lib/rubygems/dependency_resolver.rb
+++ b/lib/rubygems/dependency_resolver.rb
@@ -349,7 +349,7 @@ module Gem
when Dependency
@dependency == other
when DependencyRequest
- @dependency == other.dep && @requester == other.requester
+ @dependency == other.dependency && @requester == other.requester
else
false
end
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index fdbe39b..e296ef3 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -62,10 +62,10 @@ module Gem
##
# A wordy description of the error.
def wordy
- "Found %s (%), but was for platform%s %s" %
+ "Found %s (%s), but was for platform%s %s" %
[@name,
@version,
- @platforms.size == 1 ? 's' : '',
+ @platforms.size == 1 ? '' : 's',
@platforms.join(' ,')]
end
end
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 474d07f..04d7cd3 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -38,7 +38,7 @@ module Gem::GemcutterUtilities
say "Enter your #{pretty_host} credentials."
say "Don't have an account yet? " +
- "Create one at https://#{sign_in_host}/sign_up"
+ "Create one at #{sign_in_host}/sign_up"
email = ask " Email: "
password = ask_for_password "Password: "
@@ -60,7 +60,14 @@ module Gem::GemcutterUtilities
configured_host = Gem.host unless
Gem.configuration.disable_default_gem_server
- @host ||= ENV['RUBYGEMS_HOST'] || configured_host
+ @host ||=
+ begin
+ env_rubygems_host = ENV['RUBYGEMS_HOST']
+ env_rubygems_host = nil if
+ env_rubygems_host and env_rubygems_host.empty?
+
+ env_rubygems_host|| configured_host
+ end
end
def rubygems_api_request(method, path, host = nil, &block)
@@ -79,7 +86,7 @@ module Gem::GemcutterUtilities
Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
end
- def with_response(resp)
+ def with_response resp, error_prefix = nil
case resp
when Net::HTTPSuccess then
if block_given? then
@@ -88,7 +95,10 @@ module Gem::GemcutterUtilities
say resp.body
end
else
- say resp.body
+ message = resp.body
+ message = "#{error_prefix}: #{message}" if error_prefix
+
+ say message
terminate_interaction 1 # TODO: question this
end
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 4a41891..939bc96 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -331,8 +331,9 @@ class Gem::Installer
# specifications directory.
def write_spec
- File.open(spec_file, "w") do |file|
+ open spec_file, 'w' do |file|
file.puts spec.to_ruby_for_cache
+ file.fsync rescue nil # for filesystems without fsync(2)
end
end
@@ -773,7 +774,13 @@ EOF
def write_build_info_file
return if @build_args.empty?
- open spec.build_info_file, 'w' do |io|
+ build_info_dir = File.join gem_home, 'build_info'
+
+ FileUtils.mkdir_p build_info_dir
+
+ build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
+
+ open build_info_file, 'w' do |io|
@build_args.each do |arg|
io.puts arg
end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 1a064e1..9574462 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -336,7 +336,6 @@ EOM
open destination, 'wb', entry.header.mode do |out|
out.write entry.read
- out.fsync rescue nil # for filesystems without fsync(2)
end
say destination if Gem.configuration.really_verbose
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 7301153..4a4674b 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -74,6 +74,7 @@ class Gem::Platform
when /hpux(\d+)?/ then [ 'hpux', $1 ]
when /^java$/, /^jruby$/ then [ 'java', nil ]
when /^java([\d.]*)/ then [ 'java', $1 ]
+ when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ]
when /^dotnet$/ then [ 'dotnet', nil ]
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
when /linux/ then [ 'linux', $1 ]
@@ -155,6 +156,7 @@ class Gem::Platform
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
when /^i\d86-linux/ then ['x86', 'linux', nil ]
when 'java', 'jruby' then [nil, 'java', nil ]
+ when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ]
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 0fca2ab..02c1eeb 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -5,6 +5,17 @@
# See LICENSE.txt for permissions.
#++
+require 'rubygems/version'
+require 'rubygems/requirement'
+require 'rubygems/platform'
+require 'rubygems/deprecate'
+
+# :stopdoc:
+# date.rb can't be loaded for `make install` due to miniruby
+# Date is needed for old gems that stored #date as Date instead of Time.
+class Date; end
+# :startdoc:
+
##
# The Specification class contains the information for a Gem. Typically
# defined in a .gemspec file or a Rakefile, and looks like this:
@@ -20,32 +31,19 @@
# s.homepage = 'https://rubygems.org/gems/example'
# end
#
-# Starting in RubyGems 1.9.0, a Specification can hold arbitrary
-# metadata. This metadata is accessed via Specification#metadata
-# and has the following restrictions:
+# Starting in RubyGems 1.9.0, a Specification can hold arbitrary
+# metadata. This metadata is accessed via Specification#metadata
+# and has the following restrictions:
#
-# * Must be a Hash object
-# * All keys and values must be Strings
-# * Keys can be a maximum of 128 bytes and values can be a
-# maximum of 1024 bytes
-# * All strings must be UTF8, no binary data is allowed
+# * Must be a Hash object
+# * All keys and values must be Strings
+# * Keys can be a maximum of 128 bytes and values can be a
+# maximum of 1024 bytes
+# * All strings must be UTF8, no binary data is allowed
#
-# For example, to add metadata for the location of a bugtracker:
+# For example, to add metadata for the location of a bugtracker:
#
# s.metadata = { "bugtracker" => "http://somewhere.com/blah" }
-#
-
-
-require 'rubygems/version'
-require 'rubygems/requirement'
-require 'rubygems/platform'
-require 'rubygems/deprecate'
-
-# :stopdoc:
-# date.rb can't be loaded for `make install` due to miniruby
-# Date is needed for old gems that stored #date as Date instead of Time.
-class Date; end
-# :startdoc:
class Gem::Specification
@@ -918,7 +916,7 @@ class Gem::Specification
result = Hash.new { |h,k| h[k] = {} }
native = {}
- Gem::Specification._all.reverse_each do |spec|
+ Gem::Specification.reverse_each do |spec|
next if spec.version.prerelease? unless prerelease
native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY
@@ -995,7 +993,7 @@ class Gem::Specification
# TODO: maybe we should switch to rubygems' version service?
fetcher = Gem::SpecFetcher.fetcher
- latest_specs.each do |local|
+ latest_specs(true).each do |local|
dependency = Gem::Dependency.new local.name, ">= #{local.version}"
remotes, _ = fetcher.search_for_dependency dependency
remotes = remotes.map { |n, _| n.version }
@@ -1236,7 +1234,7 @@ class Gem::Specification
unless dependency.respond_to?(:name) &&
dependency.respond_to?(:version_requirements)
- dependency = Gem::Dependency.new(dependency, requirements, type)
+ dependency = Gem::Dependency.new(dependency.to_s, requirements, type)
end
dependencies << dependency
@@ -2270,7 +2268,7 @@ class Gem::Specification
require 'rubygems/psych_tree'
end
- builder = Gem::NoAliasYAMLTree.create
+ builder = Gem::NoAliasYAMLTree.new({})
builder << self
ast = builder.tree
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index b6c7465..fda8376 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1198,8 +1198,10 @@ class TestGem < Gem::TestCase
end
def test_self_user_dir
- assert_equal File.join(@userhome, '.gem', Gem.ruby_engine,
- Gem::ConfigMap[:ruby_version]), Gem.user_dir
+ parts = [@userhome, '.gem', Gem.ruby_engine]
+ parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty?
+
+ assert_equal File.join(parts), Gem.user_dir
end
def test_self_user_home
diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb
index f039857..a10e575 100644
--- a/test/rubygems/test_gem_commands_help_command.rb
+++ b/test/rubygems/test_gem_commands_help_command.rb
@@ -10,6 +10,9 @@ class TestGemCommandsHelpCommand < Gem::TestCase
super
@cmd = Gem::Commands::HelpCommand.new
+
+ load File.expand_path('../rubygems_plugin.rb', __FILE__) unless
+ Gem::Commands.const_defined? :InterruptCommand
end
def test_gem_help_bad
@@ -34,6 +37,8 @@ class TestGemCommandsHelpCommand < Gem::TestCase
assert_match(/\s+#{cmd}\s+\S+/, out)
end
assert_equal '', err
+
+ refute_match 'No command found for ', out
end
end
diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb
index dc84190..dfbc257 100644
--- a/test/rubygems/test_gem_commands_owner_command.rb
+++ b/test/rubygems/test_gem_commands_owner_command.rb
@@ -140,4 +140,16 @@ EOF
assert_equal '701229f217cdf23b1344c7b4b54ca97', @fetcher.last_request['Authorization']
end
+
+ def test_remove_owners_missing
+ response = 'Owner could not be found.'
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 404, 'Not Found']
+
+ use_ui @ui do
+ @cmd.remove_owners("freewill", ["missing@example"])
+ end
+
+ assert_equal "Removing missing@example: #{response}\n", @ui.output
+ end
+
end
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index 73fd7bf..52109d0 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -61,6 +61,22 @@ class TestGemCommandsPushCommand < Gem::TestCase
assert_match @response, @ui.output
end
+ def test_execute
+ open 'example', 'w' do |io| io.write 'hello' end
+
+ @response = "Successfully registered gem: freewill (1.0.0)"
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK']
+
+ @cmd.options[:args] = %w[example]
+
+ @cmd.execute
+
+ assert_equal Net::HTTP::Post, @fetcher.last_request.class
+ assert_equal 'hello', @fetcher.last_request.body
+ assert_equal "application/octet-stream",
+ @fetcher.last_request["Content-Type"]
+ end
+
def test_execute_host
host = 'https://other.example'
diff --git a/test/rubygems/test_gem_commands_search_command.rb b/test/rubygems/test_gem_commands_search_command.rb
deleted file mode 100644
index 05e7cff..0000000
--- a/test/rubygems/test_gem_commands_search_command.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'rubygems/test_case'
-require 'rubygems/commands/search_command'
-
-class TestGemCommandsSearchCommand < Gem::TestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::SearchCommand.new
- end
-
- def test_execute
- @cmd.handle_options %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r%REMOTE GEMS%, @ui.output
-
- assert_empty @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 16298c9..9c5ee7a 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -1,3 +1,5 @@
+# coding: UTF-8
+
require 'rubygems/test_case'
require 'rubygems/commands/setup_command'
@@ -73,5 +75,55 @@ class TestGemCommandsSetupCommand < Gem::TestCase
assert_path_exists os_defaults_rb
end
+ def test_show_release_notes
+ @default_external = nil
+ capture_io do
+ @default_external, Encoding.default_external =
+ Encoding.default_external, Encoding::US_ASCII
+ end if Object.const_defined? :Encoding
+
+ @cmd.options[:previous_version] = Gem::Version.new '2.0.2'
+
+ open 'History.txt', 'w' do |io|
+ io.puts <<-History_txt
+# coding: UTF-8
+
+=== #{Gem::VERSION} / 2013-03-26
+
+* Bug fixes:
+ * Fixed release note display for LANG=C when installing rubygems
+ * π is tasty
+
+=== 2.0.2 / 2013-03-06
+
+* Bug fixes:
+ * Other bugs fixed
+
+=== 2.0.1 / 2013-03-05
+
+* Bug fixes:
+ * Yet more bugs fixed
+ History_txt
+ end
+
+ use_ui @ui do
+ @cmd.show_release_notes
+ end
+
+ expected = <<-EXPECTED
+=== 2.0.2 / 2013-03-06
+
+* Bug fixes:
+ * Other bugs fixed
+
+ EXPECTED
+
+ assert_equal expected, @ui.output
+ ensure
+ capture_io do
+ Encoding.default_external = @default_external
+ end if @default_external
+ end
+
end
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 38979ac..18b4518 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -15,6 +15,13 @@ class TestGemGemcutterUtilities < Gem::TestCase
@cmd.extend Gem::GemcutterUtilities
end
+ def teardown
+ ENV['RUBYGEMS_HOST'] = nil
+ Gem.configuration.rubygems_api_key = nil
+
+ super
+ end
+
def test_alternate_key_alternate_host
keys = {
:rubygems_api_key => 'KEY',
@@ -63,6 +70,22 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_equal 'OTHER', @cmd.api_key
end
+ def test_host
+ assert_equal 'https://rubygems.org', @cmd.host
+ end
+
+ def test_host_RUBYGEMS_HOST
+ ENV['RUBYGEMS_HOST'] = 'https://other.example'
+
+ assert_equal 'https://other.example', @cmd.host
+ end
+
+ def test_host_RUBYGEMS_HOST_empty
+ ENV['RUBYGEMS_HOST'] = ''
+
+ assert_equal 'https://rubygems.org', @cmd.host
+ end
+
def test_sign_in
api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'
util_sign_in [api_key, 200, 'OK']
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 4f233f9..e513fe6 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -1365,6 +1365,20 @@ gem 'other', version
refute_path_exists @spec.build_info_file
end
+ def test_write_build_info_file_install_dir
+ installer = Gem::Installer.new @gem, :install_dir => "#{@gemhome}2"
+
+ installer.build_args = %w[
+ --with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
+ ]
+
+ installer.write_build_info_file
+
+ refute_path_exists @spec.build_info_file
+ assert_path_exists \
+ File.join("#{@gemhome}2", 'build_info', "#{@spec.full_name}.info")
+ end
+
def test_write_cache_file
cache_file = File.join @gemhome, 'cache', @spec.file_name
gem = File.join @gemhome, @spec.file_name
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 81e7f78..7b3f638 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -511,7 +511,8 @@ class TestGemPackage < Gem::Package::TarTestCase
package.verify
end
- assert_match ' - nonexistent.gem', e.message
+ assert_match %r%^No such file or directory%, e.message
+ assert_match %r%nonexistent.gem$%, e.message
end
def test_verify_security_policy
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index b4aff09..a821057 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -132,8 +132,10 @@ class TestGemSpecFetcher < Gem::TestCase
assert_equal 0, specs_and_sources.size
assert_equal 1, errors.size
+ pmm = errors.first
- assert_equal "i386-linux", errors[0].platforms.first
+ assert_equal "i386-linux", pmm.platforms.first
+ assert_equal "Found pl (1), but was for platform i386-linux", pmm.wordy
end
def test_spec_for_dependency_bad_fetch_spec
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index bdac866..9b2ae82 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -434,6 +434,21 @@ dependencies: []
assert_equal expected, Gem::Specification.normalize_yaml_input(input)
end
+ def test_self_outdated
+ util_clear_gems
+ util_setup_fake_fetcher true
+
+ a4 = quick_gem @a1.name, '4'
+ util_build_gem a4
+ util_setup_spec_fetcher @a1, @a2, @a3a, a4
+
+ Gem::Specification.remove_spec @a1
+ Gem::Specification.remove_spec @a2
+ Gem::Specification.remove_spec a4
+
+ assert_equal %w[a], Gem::Specification.outdated
+ end
+
DATA_PATH = File.expand_path "../data", __FILE__
def test_handles_private_null_type
@@ -597,7 +612,16 @@ dependencies: []
assert @a2.activated?
end
- def test_add_dependency_with_explicit_type
+ def test_add_dependency_with_type
+ gem = quick_spec "awesome", "1.0" do |awesome|
+ awesome.add_dependency true
+ awesome.add_dependency :gem_name
+ end
+
+ assert_equal %w[true gem_name], gem.dependencies.map { |dep| dep.name }
+ end
+
+ def test_add_dependency_with_type_explicit
gem = quick_spec "awesome", "1.0" do |awesome|
awesome.add_development_dependency "monkey"
end