diff options
author | Samuel Giddins <[email protected]> | 2023-02-14 10:11:56 -0800 |
---|---|---|
committer | git <[email protected]> | 2023-02-22 08:42:18 +0000 |
commit | 931db2120844760a1c1c5c5d6253b558f8034124 (patch) | |
tree | 4dbf7e2366210f96bd817e39498e8021c0a6a3e2 /test/rubygems/test_gem_commands_exec_command.rb | |
parent | 80bfa1b30af7aae60e96f17e86f3a2c5a566ee12 (diff) |
[rubygems/rubygems] Add tests covering pre-releases for gem exec
https://github.com/rubygems/rubygems/commit/f6877c29b9
Diffstat (limited to 'test/rubygems/test_gem_commands_exec_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_exec_command.rb | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index 4b9bacaa1a..e5afc7de37 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -742,4 +742,108 @@ class TestGemCommandsExecCommand < Gem::TestCase assert_equal "#{@gem_home}/gem_exec\n", @ui.output end end + + def test_only_prerelease_available + spec_fetcher do |fetcher| + fetcher.download "a", "1.a" do |s| + s.executables = %w[a] + s.files = %w[lib/a.rb bin/a] + + write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| + f << "Gem.ui.say #{s.original_name.dump} + ' ' + File.basename(__FILE__)" + end + end + end + + use_ui @ui do + assert_raises Gem::MockGemUi::TermError do + invoke "a" + end + assert_equal "ERROR: Could not find a valid gem 'a' (>= 0) in any repository\n" + + "ERROR: Possible alternatives: a\n", @ui.error + assert_empty @ui.output + assert_empty @installed_specs + end + + use_ui @ui do + invoke "a:1.a" + assert_empty @ui.error + assert_equal "a-1.a a\n", @ui.output + assert_equal %w[a-1.a], @installed_specs.map(&:full_name) + end + + FileUtils.rm_rf Gem.dir + + use_ui @ui do + invoke "--version", ">= 1.a", "a" + assert_empty @ui.error + assert_equal "a-1.a a\n", @ui.output + assert_equal %w[a-1.a], @installed_specs.map(&:full_name) + end + + FileUtils.rm_rf Gem.dir + + use_ui @ui do + invoke "--pre", "a" + assert_empty @ui.error + assert_equal "a-1.a a\n", @ui.output + assert_equal %w[a-1.a], @installed_specs.map(&:full_name) + end + end + + def test_newer_prerelease_available + spec_fetcher do |fetcher| + fetcher.download "a", "1" do |s| + s.executables = %w[a] + s.files = %w[lib/a.rb bin/a] + + write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| + f << "Gem.ui.say #{s.original_name.dump} + ' ' + File.basename(__FILE__)" + end + end + + fetcher.download "a", "1.1.a" do |s| + s.executables = %w[a] + s.files = %w[lib/a.rb bin/a] + + write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| + f << "Gem.ui.say #{s.original_name.dump} + ' ' + File.basename(__FILE__)" + end + end + end + + use_ui @ui do + invoke "a" + assert_empty @ui.error + assert_equal "a-1 a\n", @ui.output + assert_equal %w[a-1], @installed_specs.map(&:full_name) + end + + FileUtils.rm_rf Gem.dir + + use_ui @ui do + invoke "a:1.1.a" + assert_empty @ui.error + assert_equal "a-1.1.a a\n", @ui.output + assert_equal %w[a-1.1.a], @installed_specs.map(&:full_name) + end + + FileUtils.rm_rf Gem.dir + + use_ui @ui do + invoke "--version", ">= 1.a", "a" + assert_empty @ui.error + assert_equal "a-1.1.a a\n", @ui.output + assert_equal %w[a-1.1.a], @installed_specs.map(&:full_name) + end + + FileUtils.rm_rf Gem.dir + + use_ui @ui do + invoke "--pre", "a" + assert_empty @ui.error + assert_equal "a-1.1.a a\n", @ui.output + assert_equal %w[a-1.1.a], @installed_specs.map(&:full_name) + end + end end |