1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_gem_install_update_options.rb
ryan 934f537b45 Import rubygems 1.5.0 (release candidate @ 09893d9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-28 23:46:47 +00:00

74 lines
2 KiB
Ruby

######################################################################
# This file is imported from the rubygems project.
# DO NOT make modifications in this repo. They _will_ be reverted!
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
######################################################################
require 'rubygems/installer_test_case'
require 'rubygems/install_update_options'
require 'rubygems/command'
class TestGemInstallUpdateOptions < Gem::InstallerTestCase
def setup
super
@cmd = Gem::Command.new 'dummy', 'dummy'
@cmd.extend Gem::InstallUpdateOptions
@cmd.add_install_update_options
end
def test_add_install_update_options
args = %w[-i /install_to --rdoc --ri -E -f -w -P HighSecurity
--ignore-dependencies --format-exec --include-dependencies]
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
assert_raises OptionParser::InvalidArgument do
@cmd.handle_options %w[-P UnknownSecurity]
end
end
def test_user_install_enabled
@cmd.handle_options %w[--user-install]
assert @cmd.options[:user_install]
@installer = Gem::Installer.new @gem, @cmd.options
@installer.install
assert File.exist?(File.join(Gem.user_dir, 'gems'))
assert File.exist?(File.join(Gem.user_dir, 'gems',
@spec.full_name))
end
def test_user_install_disabled_read_only
if win_platform?
skip('test_user_install_disabled_read_only test skipped on MS Windows')
else
@cmd.handle_options %w[--no-user-install]
refute @cmd.options[:user_install]
File.chmod 0755, @userhome
FileUtils.chmod 0000, @gemhome
assert_raises(Gem::FilePermissionError) do
@installer = Gem::Installer.new @gem, @cmd.options
end
end
ensure
FileUtils.chmod 0755, @gemhome
end
end