summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-01-06 14:05:46 +0100
committergit <svn-admin@ruby-lang.org>2022-01-06 23:52:48 +0900
commitee5e684bc1fda49bc28f0fcfc2f79abb26994f08 (patch)
treed742e6f523366d7cab1823d68b303aeb94d3ce94 /test
parente3b0c8c10680d7427bc0b5ec8906a72ce7c64c2d (diff)
[rubygems/rubygems] Fix `gem install <non-existent-gem> --force` crash
Before: ``` $ gem install sfdsfdsfsdide --force ERROR: While executing gem ... (NoMethodError) undefined method `spec' for nil:NilClass @always_install << newest.spec ^^^^^ ``` After: ``` $ gem install sfdsfdsfsdide --force ERROR: Could not find a valid gem 'sfdsfdsfsdide' (>= 0) in any repository ``` https://github.com/rubygems/rubygems/commit/4e2bfd1101
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 0365b2c408..47a97dae4b 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -277,6 +277,22 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a
assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end
+ def test_execute_nonexistent_force
+ spec_fetcher
+
+ @cmd.options[:args] = %w[nonexistent]
+ @cmd.options[:force] = true
+
+ use_ui @ui do
+ e = assert_raise Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ assert_equal 2, e.exit_code
+ end
+
+ assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
+ end
+
def test_execute_dependency_nonexistent
spec_fetcher do |fetcher|
fetcher.spec 'foo', 2, 'bar' => '0.5'