summaryrefslogtreecommitdiff
path: root/test/rubygems
diff options
context:
space:
mode:
authorGustavo Ribeiro <g2_ribeiro@hotmail.com>2022-12-22 15:24:34 -0300
committergit <svn-admin@ruby-lang.org>2022-12-26 19:08:55 +0000
commit08f6196bdac6b53df35caa5810839d28100d073c (patch)
treeff4e37e1f03bf9d188d187165e6f24a1109d6f7a /test/rubygems
parent28a17436503c3c4cb7a35b423a894b697cd80da9 (diff)
[rubygems/rubygems] add global flag (-C) to change execution directory
https://github.com/rubygems/rubygems/commit/312fc36711
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem_command_manager.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
index 0b533329a9..6b34156187 100644
--- a/test/rubygems/test_gem_command_manager.rb
+++ b/test/rubygems/test_gem_command_manager.rb
@@ -126,6 +126,46 @@ class TestGemCommandManager < Gem::TestCase
@command_manager.unregister_command :crash
end
+ def test_process_args_with_c_flag
+ custom_start_point = File.join @tempdir, "nice_folder"
+ FileUtils.mkdir_p custom_start_point
+
+ execution_path = nil
+ use_ui @ui do
+ @command_manager[:install].when_invoked do
+ execution_path = Dir.pwd
+ true
+ end
+ @command_manager.process_args %W[-C #{custom_start_point} install net-scp-4.0.0.gem --local]
+ end
+
+ assert_equal custom_start_point, execution_path
+ end
+
+ def test_process_args_with_c_flag_without_path
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @command_manager.process_args %w[-C install net-scp-4.0.0.gem --local]
+ end
+ end
+
+ assert_match(/install isn't a directory./i, @ui.error)
+ end
+
+ def test_process_args_with_c_flag_path_not_found
+ custom_start_point = File.join @tempdir, "nice_folder"
+ FileUtils.mkdir_p custom_start_point
+ custom_start_point.tr!("_", "-")
+
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @command_manager.process_args %W[-C #{custom_start_point} install net-scp-4.0.0.gem --local]
+ end
+ end
+
+ assert_match(/#{custom_start_point} isn't a directory./i, @ui.error)
+ end
+
def test_process_args_bad_arg
use_ui @ui do
assert_raise Gem::MockGemUi::TermError do