2016-02-01 15:43:26 +03:00
|
|
|
# frozen_string_literal: true
|
2011-01-29 02:46:47 +03:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 10:48:56 +03:00
|
|
|
|
2011-01-29 02:46:47 +03:00
|
|
|
class TestGemGemRunner < Gem::TestCase
|
2012-11-29 10:52:18 +04:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
2019-12-13 16:10:28 +03:00
|
|
|
require 'rubygems/command'
|
2012-11-29 10:52:18 +04:00
|
|
|
@orig_args = Gem::Command.build_args
|
2020-03-24 09:39:24 +03:00
|
|
|
@orig_specific_extra_args = Gem::Command.specific_extra_args_hash.dup
|
2020-07-22 19:44:59 +03:00
|
|
|
@orig_extra_args = Gem::Command.extra_args.dup
|
2019-12-13 14:19:08 +03:00
|
|
|
|
|
|
|
require 'rubygems/gem_runner'
|
2013-09-14 12:59:02 +04:00
|
|
|
@runner = Gem::GemRunner.new
|
2012-11-29 10:52:18 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
|
|
|
|
|
|
|
Gem::Command.build_args = @orig_args
|
2020-03-24 09:39:24 +03:00
|
|
|
Gem::Command.specific_extra_args_hash = @orig_specific_extra_args
|
2020-07-22 19:44:59 +03:00
|
|
|
Gem::Command.extra_args = @orig_extra_args
|
2012-11-29 10:52:18 +04:00
|
|
|
end
|
|
|
|
|
2007-11-10 10:48:56 +03:00
|
|
|
def test_do_configuration
|
|
|
|
Gem.clear_paths
|
|
|
|
|
|
|
|
temp_conf = File.join @tempdir, '.gemrc'
|
|
|
|
|
|
|
|
other_gem_path = File.join @tempdir, 'other_gem_path'
|
|
|
|
other_gem_home = File.join @tempdir, 'other_gem_home'
|
|
|
|
|
|
|
|
Gem.ensure_gem_subdirectories other_gem_path
|
|
|
|
Gem.ensure_gem_subdirectories other_gem_home
|
|
|
|
|
|
|
|
File.open temp_conf, 'w' do |fp|
|
|
|
|
fp.puts "gem: --commands"
|
|
|
|
fp.puts "gemhome: #{other_gem_home}"
|
|
|
|
fp.puts "gempath:"
|
|
|
|
fp.puts " - #{other_gem_path}"
|
|
|
|
fp.puts "rdoc: --all"
|
|
|
|
end
|
|
|
|
|
|
|
|
gr = Gem::GemRunner.new
|
|
|
|
gr.send :do_configuration, %W[--config-file #{temp_conf}]
|
|
|
|
|
2012-11-29 10:52:18 +04:00
|
|
|
assert_equal [other_gem_path, other_gem_home], Gem.path
|
2007-11-10 10:48:56 +03:00
|
|
|
assert_equal %w[--commands], Gem::Command.extra_args
|
|
|
|
end
|
|
|
|
|
2013-09-14 12:59:02 +04:00
|
|
|
def test_extract_build_args
|
|
|
|
args = %w[]
|
|
|
|
assert_equal [], @runner.extract_build_args(args)
|
|
|
|
assert_equal %w[], args
|
2012-11-29 10:52:18 +04:00
|
|
|
|
2013-09-14 12:59:02 +04:00
|
|
|
args = %w[foo]
|
|
|
|
assert_equal [], @runner.extract_build_args(args)
|
|
|
|
assert_equal %w[foo], args
|
2012-11-29 10:52:18 +04:00
|
|
|
|
2013-09-14 12:59:02 +04:00
|
|
|
args = %w[--foo]
|
|
|
|
assert_equal [], @runner.extract_build_args(args)
|
|
|
|
assert_equal %w[--foo], args
|
2012-11-29 10:52:18 +04:00
|
|
|
|
2013-09-14 12:59:02 +04:00
|
|
|
args = %w[--foo --]
|
|
|
|
assert_equal [], @runner.extract_build_args(args)
|
|
|
|
assert_equal %w[--foo], args
|
2009-06-10 01:38:59 +04:00
|
|
|
|
2013-09-14 12:59:02 +04:00
|
|
|
args = %w[--foo -- --bar]
|
|
|
|
assert_equal %w[--bar], @runner.extract_build_args(args)
|
|
|
|
assert_equal %w[--foo], args
|
2009-06-10 01:38:59 +04:00
|
|
|
end
|
|
|
|
|
2020-02-06 15:54:23 +03:00
|
|
|
def test_query_is_deprecated
|
|
|
|
args = %w[query]
|
|
|
|
|
|
|
|
use_ui @ui do
|
2020-12-08 10:33:39 +03:00
|
|
|
@runner.run(args)
|
2020-02-06 15:54:23 +03:00
|
|
|
end
|
|
|
|
|
2020-03-31 03:41:23 +03:00
|
|
|
assert_match(/WARNING: query command is deprecated. It will be removed in Rubygems [0-9]+/, @ui.error)
|
2020-12-08 10:33:39 +03:00
|
|
|
assert_match(/WARNING: It is recommended that you use `gem search` or `gem list` instead/, @ui.error)
|
2020-02-06 15:54:23 +03:00
|
|
|
end
|
|
|
|
|
2020-02-01 05:14:04 +03:00
|
|
|
def test_info_succeeds
|
|
|
|
args = %w[info]
|
|
|
|
|
|
|
|
use_ui @ui do
|
2020-12-08 10:33:39 +03:00
|
|
|
@runner.run(args)
|
2020-02-01 05:14:04 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_empty @ui.error
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_list_succeeds
|
|
|
|
args = %w[list]
|
|
|
|
|
|
|
|
use_ui @ui do
|
2020-12-08 10:33:39 +03:00
|
|
|
@runner.run(args)
|
2020-02-01 05:14:04 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_empty @ui.error
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_search_succeeds
|
|
|
|
args = %w[search]
|
|
|
|
|
|
|
|
use_ui @ui do
|
2020-12-08 10:33:39 +03:00
|
|
|
@runner.run(args)
|
2020-02-01 05:14:04 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_empty @ui.error
|
|
|
|
end
|
2007-11-10 10:48:56 +03:00
|
|
|
end
|