2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2008-03-31 18:40:06 -04:00
|
|
|
require 'rubygems/commands/update_command'
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemCommandsUpdateCommand < Gem::TestCase
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
2013-09-14 04:59:02 -04:00
|
|
|
common_installer_setup
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
@cmd = Gem::Commands::UpdateCommand.new
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
@cmd.options[:document] = []
|
2009-06-09 17:38:59 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
@specs = spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 1
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
fetcher.download 'a', '3.a'
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
@a1_path = @specs['a-1'].cache_file
|
|
|
|
@a2_path = @specs['a-1'].cache_file
|
|
|
|
@a3a_path = @specs['a-3.a'].cache_file
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
2011-03-07 03:44:45 -05:00
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_execute_multiple
|
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
|
|
|
fetcher.download 'ab', 2
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'ab', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = %w[a]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
def test_execute_system
|
|
|
|
spec_fetcher do |fetcher|
|
2019-02-14 07:59:03 -05:00
|
|
|
fetcher.download 'rubygems-update', 9 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
2011-03-07 03:44:45 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = true
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating rubygems-update", out.shift
|
|
|
|
assert_equal "Installing RubyGems 9", out.shift
|
|
|
|
assert_equal "RubyGems system software updated", out.shift
|
|
|
|
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_system_at_latest
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'rubygems-update', Gem::VERSION do |s|
|
2013-11-11 19:16:41 -05:00
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
end
|
2011-03-07 03:44:45 -05:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = true
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
assert_raises Gem::MockGemUi::SystemExitException do
|
2011-03-07 03:44:45 -05:00
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
2017-10-07 21:32:18 -04:00
|
|
|
assert_equal "Latest version already installed. Done.", out.shift
|
2011-03-07 03:44:45 -05:00
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_system_multiple
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2019-02-14 07:59:03 -05:00
|
|
|
fetcher.download 'rubygems-update', 8 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.download 'rubygems-update', 9 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
2011-03-07 03:44:45 -05:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = true
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating rubygems-update", out.shift
|
|
|
|
assert_equal "Installing RubyGems 9", out.shift
|
|
|
|
assert_equal "RubyGems system software updated", out.shift
|
|
|
|
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_system_specific
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2019-02-14 07:59:03 -05:00
|
|
|
fetcher.download 'rubygems-update', 8 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.download 'rubygems-update', 9 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
2011-03-07 03:44:45 -05:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = "8"
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating rubygems-update", out.shift
|
|
|
|
assert_equal "Installing RubyGems 8", out.shift
|
|
|
|
assert_equal "RubyGems system software updated", out.shift
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_empty out
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2020-01-31 21:14:04 -05:00
|
|
|
def test_execute_system_specific_older_than_3_2_removes_plugins_dir
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'rubygems-update', 3.1 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = "3.1"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p Gem.plugins_dir
|
|
|
|
write_file File.join(Gem.plugins_dir, 'a_plugin.rb')
|
|
|
|
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
refute_path_exists Gem.plugins_dir, "Plugins folder not removed when updating rubygems to pre-3.2"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_execute_system_specific_newer_than_or_equal_to_3_2_leaves_plugins_dir_alone
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'rubygems-update', 3.2 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = "3.2"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p Gem.plugins_dir
|
|
|
|
plugin_file = File.join(Gem.plugins_dir, 'a_plugin.rb')
|
|
|
|
write_file plugin_file
|
|
|
|
|
|
|
|
@cmd.execute
|
|
|
|
|
|
|
|
assert_path_exists Gem.plugins_dir, "Plugin folder removed when updating rubygems to post-3.2"
|
|
|
|
assert_path_exists plugin_file, "Plugin removed when updating rubygems to post-3.2"
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def test_execute_system_specifically_to_latest_version
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2019-02-14 07:59:03 -05:00
|
|
|
fetcher.download 'rubygems-update', 8 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.download 'rubygems-update', 9 do |s|
|
|
|
|
s.files = %w[setup.rb]
|
|
|
|
end
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
2011-05-31 23:45:05 -04:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
@cmd.options[:system] = "9"
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating rubygems-update", out.shift
|
|
|
|
assert_equal "Installing RubyGems 9", out.shift
|
|
|
|
assert_equal "RubyGems system software updated", out.shift
|
|
|
|
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2011-03-07 03:44:45 -05:00
|
|
|
def test_execute_system_with_gems
|
|
|
|
@cmd.options[:args] = %w[gem]
|
|
|
|
@cmd.options[:system] = true
|
|
|
|
|
|
|
|
assert_raises Gem::MockGemUi::TermError do
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_empty @ui.output
|
|
|
|
assert_equal "ERROR: Gem names are not allowed with the --system option\n",
|
|
|
|
@ui.error
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
# before:
|
|
|
|
# a1 -> c1.2
|
|
|
|
# after:
|
|
|
|
# a2 -> b2 # new dependency
|
|
|
|
# a2 -> c2
|
|
|
|
|
|
|
|
def test_execute_dependencies
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2, 'b' => 2, 'c' => 2
|
|
|
|
fetcher.download 'b', 2
|
|
|
|
fetcher.download 'c', 2
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 1, 'c' => '1.2'
|
|
|
|
fetcher.spec 'c', '1.2'
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
Gem::Specification.reset
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
@cmd.options[:args] = []
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a b c",
|
2008-03-31 18:40:06 -04:00
|
|
|
out.shift
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_empty out
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_execute_rdoc
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
Gem.done_installing(&Gem::RDoc.method(:generation_hook))
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
@cmd.options[:document] = %w[rdoc ri]
|
|
|
|
|
|
|
|
@cmd.options[:args] = %w[a]
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_child_process_to_exit
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
a2 = @specs['a-2']
|
|
|
|
|
|
|
|
assert_path_exists File.join(a2.doc_dir, 'rdoc')
|
2015-04-12 04:36:37 -04:00
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_named
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
@cmd.options[:args] = %w[a]
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_empty out
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_execute_named_some_up_to_date
|
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 2
|
2014-09-13 23:30:02 -04:00
|
|
|
fetcher.spec 'a', 1
|
|
|
|
|
|
|
|
fetcher.spec 'b', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = %w[a b]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
|
|
|
assert_equal "Gems already up-to-date: b", out.shift
|
|
|
|
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_named_up_to_date
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
@cmd.options[:args] = %w[a]
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
|
|
|
assert_equal "Nothing to update", out.shift
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_empty out
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_execute_named_up_to_date_prerelease
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', '3.a'
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:args] = %w[a]
|
2012-11-29 01:52:18 -05:00
|
|
|
@cmd.options[:prerelease] = true
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
def test_execute_up_to_date
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
2008-03-31 18:40:06 -04:00
|
|
|
|
|
|
|
@cmd.options[:args] = []
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
|
|
|
assert_equal "Nothing to update", out.shift
|
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_empty out
|
2008-03-31 18:40:06 -04:00
|
|
|
end
|
2011-03-07 03:44:45 -05:00
|
|
|
|
2013-02-19 19:34:58 -05:00
|
|
|
def test_execute_user_install
|
2020-01-31 21:14:04 -05:00
|
|
|
a = util_spec "a", 1
|
|
|
|
b = util_spec "b", 1
|
|
|
|
install_gem_user(a)
|
|
|
|
install_gem(b)
|
2013-02-19 19:34:58 -05:00
|
|
|
|
|
|
|
@cmd.handle_options %w[--user-install]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
installer = @cmd.installer
|
|
|
|
user_install = installer.instance_variable_get :@user_install
|
|
|
|
|
2020-01-31 21:14:04 -05:00
|
|
|
assert user_install, "user_install must be set on the installer"
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
assert_equal "Updating installed gems", out.shift
|
|
|
|
assert_equal "Updating a", out.shift
|
|
|
|
assert_equal "Gems updated: a", out.shift
|
|
|
|
assert_empty out
|
2013-02-19 19:34:58 -05:00
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
def test_fetch_remote_gems
|
2013-11-11 19:16:41 -05:00
|
|
|
specs = spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 1
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
expected = [
|
|
|
|
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
2019-06-04 04:40:30 -04:00
|
|
|
Gem::Source.new(@gem_repo)],
|
2013-10-15 20:14:16 -04:00
|
|
|
]
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_fetch_remote_gems_error
|
|
|
|
Gem.sources.replace %w[http://nonexistent.example]
|
|
|
|
|
|
|
|
assert_raises Gem::RemoteFetcher::FetchError do
|
2013-11-11 19:16:41 -05:00
|
|
|
@cmd.fetch_remote_gems @specs['a-1']
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-18 18:14:56 -04:00
|
|
|
def test_fetch_remote_gems_mismatch
|
|
|
|
platform = Gem::Platform.new 'x86-freebsd9'
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
specs = spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'a', 2
|
2019-02-14 07:59:03 -05:00
|
|
|
|
|
|
|
fetcher.spec 'a', 2 do |s|
|
|
|
|
s.platform = platform
|
|
|
|
end
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
2013-10-18 18:14:56 -04:00
|
|
|
|
|
|
|
expected = [
|
|
|
|
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
2019-06-04 04:40:30 -04:00
|
|
|
Gem::Source.new(@gem_repo)],
|
2013-10-18 18:14:56 -04:00
|
|
|
]
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
2013-10-18 18:14:56 -04:00
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
def test_fetch_remote_gems_prerelease
|
2013-11-11 19:16:41 -05:00
|
|
|
specs = spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 1
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
fetcher.gem 'a', '3.a'
|
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
@cmd.options[:prerelease] = true
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
[Gem::NameTuple.new('a', v(2), Gem::Platform::RUBY),
|
2019-06-04 04:40:30 -04:00
|
|
|
Gem::Source.new(@gem_repo)],
|
2013-10-15 20:14:16 -04:00
|
|
|
[Gem::NameTuple.new('a', v('3.a'), Gem::Platform::RUBY),
|
2019-06-04 04:40:30 -04:00
|
|
|
Gem::Source.new(@gem_repo)],
|
2013-10-15 20:14:16 -04:00
|
|
|
]
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal expected, @cmd.fetch_remote_gems(specs['a-1'])
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
|
2011-03-07 03:44:45 -05:00
|
|
|
def test_handle_options_system
|
|
|
|
@cmd.handle_options %w[--system]
|
|
|
|
|
|
|
|
expected = {
|
2012-11-29 01:52:18 -05:00
|
|
|
:args => [],
|
|
|
|
:document => %w[rdoc ri],
|
|
|
|
:force => false,
|
|
|
|
:system => true,
|
2011-03-07 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal expected, @cmd.options
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_handle_options_system_non_version
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
@cmd.handle_options %w[--system non-version]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_handle_options_system_specific
|
|
|
|
@cmd.handle_options %w[--system 1.3.7]
|
|
|
|
|
|
|
|
expected = {
|
2012-11-29 01:52:18 -05:00
|
|
|
:args => [],
|
|
|
|
:document => %w[rdoc ri],
|
|
|
|
:force => false,
|
|
|
|
:system => "1.3.7",
|
2011-03-07 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal expected, @cmd.options
|
|
|
|
end
|
|
|
|
|
2014-10-01 04:30:21 -04:00
|
|
|
def test_update_gem_prerelease
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', '1.a'
|
|
|
|
fetcher.gem 'a', '1.b'
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.update_gem 'a', Gem::Requirement.new('= 1.b')
|
|
|
|
|
|
|
|
refute_empty @cmd.updated
|
|
|
|
|
|
|
|
assert @cmd.installer.instance_variable_get :@prerelease
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_update_gem_unresolved_dependency
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.gem 'a', 2 do |s|
|
|
|
|
s.add_dependency 'b', '>= 2'
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.spec 'b', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.update_gem 'a'
|
|
|
|
|
|
|
|
assert_empty @cmd.updated
|
|
|
|
end
|
|
|
|
|
2013-09-18 17:29:41 -04:00
|
|
|
def test_update_rubygems_arguments
|
|
|
|
@cmd.options[:system] = true
|
|
|
|
|
|
|
|
arguments = @cmd.update_rubygems_arguments
|
|
|
|
|
|
|
|
assert_equal '--prefix', arguments.shift
|
|
|
|
assert_equal Gem.prefix, arguments.shift
|
2019-06-01 05:45:11 -04:00
|
|
|
assert_equal '--no-document', arguments.shift
|
2013-09-18 17:29:41 -04:00
|
|
|
assert_equal '--previous-version', arguments.shift
|
|
|
|
assert_equal Gem::VERSION, arguments.shift
|
|
|
|
assert_empty arguments
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
def test_explain
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:explain] = true
|
|
|
|
@cmd.options[:args] = %w[a]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
2015-04-12 04:36:37 -04:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal "Gems to update:", out.shift
|
|
|
|
assert_equal " a-2", out.shift
|
|
|
|
assert_empty out
|
|
|
|
end
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2019-03-04 22:32:58 -05:00
|
|
|
def test_explain_platform_local
|
|
|
|
local = Gem::Platform.local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
|
|
|
|
fetcher.download 'a', 2 do |s|
|
|
|
|
s.platform = local
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
@cmd.options[:explain] = true
|
|
|
|
@cmd.options[:args] = %w[a]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
|
|
|
|
assert_equal "Gems to update:", out.shift
|
|
|
|
assert_equal " a-2-#{local}", out.shift
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_explain_platform_ruby
|
|
|
|
local = Gem::Platform.local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
|
|
|
|
fetcher.download 'a', 2 do |s|
|
|
|
|
s.platform = local
|
|
|
|
end
|
|
|
|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
# equivalent to --platform=ruby
|
|
|
|
Gem.platforms = [Gem::Platform::RUBY]
|
|
|
|
|
|
|
|
@cmd.options[:explain] = true
|
|
|
|
@cmd.options[:args] = %w[a]
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
out = @ui.output.split "\n"
|
|
|
|
|
|
|
|
assert_equal "Gems to update:", out.shift
|
|
|
|
assert_equal " a-2", out.shift
|
|
|
|
assert_empty out
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
end
|