diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:02:05 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:02:05 +0000 |
commit | 0dc342de848a642ecce8db697b8fecd83a63e117 (patch) | |
tree | 2b7ed4724aff1f86073e4740134bda9c4aac1a39 /trunk/test/rubygems/test_gem_install_update_options.rb | |
parent | ef70cf7138ab8034b5b806f466e4b484b24f0f88 (diff) |
added tag v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/test/rubygems/test_gem_install_update_options.rb')
-rw-r--r-- | trunk/test/rubygems/test_gem_install_update_options.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/trunk/test/rubygems/test_gem_install_update_options.rb b/trunk/test/rubygems/test_gem_install_update_options.rb new file mode 100644 index 0000000000..3638a0670a --- /dev/null +++ b/trunk/test/rubygems/test_gem_install_update_options.rb @@ -0,0 +1,61 @@ +require 'test/unit' +require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities') +require File.join(File.expand_path(File.dirname(__FILE__)), + 'gem_installer_test_case') +require 'rubygems/install_update_options' +require 'rubygems/command' + +class TestGemInstallUpdateOptions < GemInstallerTestCase + + 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 -t -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_raise OptionParser::InvalidArgument do + @cmd.handle_options %w[-P UnknownSecurity] + end + end + + def test_user_install_enabled + @cmd.handle_options %w[--user-install] + + @installer = Gem::Installer.new @gem, @cmd.options + @installer.install + assert File.exist?(File.join(@userhome, '.gem', 'gems')) + assert File.exist?(File.join(@userhome, '.gem', 'gems', + @spec.full_name)) + end + + def test_user_install_disabled_read_only + @cmd.handle_options %w[--no-user-install] + + File.chmod 0755, @userhome + FileUtils.chmod 0000, @gemhome + + assert_raises(Gem::FilePermissionError) do + @installer = Gem::Installer.new @gem, @cmd.options + end + ensure + FileUtils.chmod 0755, @gemhome + end +end |