2009-10-03 11:59:29 -04:00
|
|
|
require_relative 'gem_installer_test_case'
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/install_update_options'
|
|
|
|
require 'rubygems/command'
|
|
|
|
|
2008-06-25 22:06:00 -04:00
|
|
|
class TestGemInstallUpdateOptions < GemInstallerTestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Command.new 'dummy', 'dummy'
|
|
|
|
@cmd.extend Gem::InstallUpdateOptions
|
2008-06-25 22:06:00 -04:00
|
|
|
@cmd.add_install_update_options
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_add_install_update_options
|
|
|
|
args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
|
2007-12-20 03:39:12 -05:00
|
|
|
--ignore-dependencies --format-exec --include-dependencies]
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
assert @cmd.handles?(args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_security_policy
|
|
|
|
@cmd.handle_options %w[-P HighSecurity]
|
|
|
|
|
|
|
|
assert_equal Gem::Security::HighSecurity, @cmd.options[:security_policy]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_security_policy_unknown
|
|
|
|
@cmd.add_install_update_options
|
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
assert_raises OptionParser::InvalidArgument do
|
2007-11-10 02:48:56 -05:00
|
|
|
@cmd.handle_options %w[-P UnknownSecurity]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-06-25 22:06:00 -04:00
|
|
|
def test_user_install_enabled
|
|
|
|
@cmd.handle_options %w[--user-install]
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert @cmd.options[:user_install]
|
|
|
|
|
2008-06-25 22:06:00 -04:00
|
|
|
@installer = Gem::Installer.new @gem, @cmd.options
|
|
|
|
@installer.install
|
2008-09-25 06:13:50 -04:00
|
|
|
assert File.exist?(File.join(Gem.user_dir, 'gems'))
|
|
|
|
assert File.exist?(File.join(Gem.user_dir, 'gems',
|
2008-06-25 22:06:00 -04:00
|
|
|
@spec.full_name))
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_user_install_disabled_read_only
|
2009-06-09 17:38:59 -04:00
|
|
|
if win_platform?
|
|
|
|
skip('test_user_install_disabled_read_only test skipped on MS Windows')
|
|
|
|
else
|
|
|
|
@cmd.handle_options %w[--no-user-install]
|
2008-06-25 22:06:00 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
refute @cmd.options[:user_install]
|
2008-06-25 22:06:00 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
File.chmod 0755, @userhome
|
|
|
|
FileUtils.chmod 0000, @gemhome
|
|
|
|
|
|
|
|
assert_raises(Gem::FilePermissionError) do
|
|
|
|
@installer = Gem::Installer.new @gem, @cmd.options
|
|
|
|
end
|
2008-06-25 22:06:00 -04:00
|
|
|
end
|
|
|
|
ensure
|
|
|
|
FileUtils.chmod 0755, @gemhome
|
|
|
|
end
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
2009-06-09 17:38:59 -04:00
|
|
|
|