From 75eb6cc98ed3c6862769e839941c27591da2d700 Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 20 Feb 2013 00:34:58 +0000 Subject: * lib/rubygems/commands/update_command.rb: Create the installer after options are processed. [ruby-trunk - Bug #7779] * test/rubygems/test_gem_commands_update_command.rb: Test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/rubygems/commands/update_command.rb | 7 ++++++- test/rubygems/test_gem_commands_update_command.rb | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a761046917..891bcd438d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Feb 20 09:34:43 2013 Eric Hodel + + * lib/rubygems/commands/update_command.rb: Create the installer after + options are processed. [ruby-trunk - Bug #7779] + * test/rubygems/test_gem_commands_update_command.rb: Test for the + above. + Wed Feb 20 07:51:19 2013 Eric Hodel * lib/rubygems/installer.rb: Use gsub instead of gsub! to avoid diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index be76c4c7cd..66aef49b4d 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -14,6 +14,8 @@ class Gem::Commands::UpdateCommand < Gem::Command include Gem::LocalRemoteOptions include Gem::VersionOption + attr_reader :installer # :nodoc: + def initialize super 'update', 'Update installed gems to the latest version', :document => %w[rdoc ri], @@ -39,7 +41,7 @@ class Gem::Commands::UpdateCommand < Gem::Command add_prerelease_option "as update targets" @updated = [] - @installer = Gem::DependencyInstaller.new options + @installer = nil end def arguments # :nodoc: @@ -85,6 +87,9 @@ class Gem::Commands::UpdateCommand < Gem::Command def update_gem name, version = Gem::Requirement.default return if @updated.any? { |spec| spec.name == name } + + @installer ||= Gem::DependencyInstaller.new options + success = false say "Updating #{name}" diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 536a3d57fb..006d821210 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -355,6 +355,23 @@ class TestGemCommandsUpdateCommand < Gem::TestCase assert_empty out end + def test_execute_user_install + util_clear_gems + + Gem::Installer.new(@a1_path).install + + @cmd.handle_options %w[--user-install] + + use_ui @ui do + @cmd.execute + end + + installer = @cmd.installer + user_install = installer.instance_variable_get :@user_install + + assert user_install, 'user_install must be set on the installer' + end + def test_handle_options_system @cmd.handle_options %w[--system] -- cgit v1.2.3