blob: 2f0b911604a9293c85dca100d418f3690a7d41d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
######################################################################
# 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_path_exists File.join(Gem.user_dir, 'gems')
assert_path_exists 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]
FileUtils.chmod 0755, @userhome
FileUtils.chmod 0000, @gemhome
Gem.use_paths @gemhome, @userhome
assert_raises(Gem::FilePermissionError) do
Gem::Installer.new(@gem, @cmd.options).install
end
end
ensure
FileUtils.chmod 0755, @gemhome
end
end
|