2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-05-31 23:45:05 -04:00
|
|
|
require "rubygems"
|
|
|
|
require "rubygems/test_case"
|
|
|
|
require "rubygems/commands/help_command"
|
2012-11-29 01:52:18 -05:00
|
|
|
require "rubygems/package"
|
2011-05-31 23:45:05 -04:00
|
|
|
require "rubygems/command_manager"
|
|
|
|
|
|
|
|
class TestGemCommandsHelpCommand < Gem::TestCase
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Commands::HelpCommand.new
|
2013-07-08 18:41:03 -04:00
|
|
|
|
2019-12-13 06:19:08 -05:00
|
|
|
load File.expand_path('../rubygems_plugin.rb', __FILE__) unless Gem::Commands.const_defined? :InterruptCommand
|
2011-05-31 23:45:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_help_bad
|
|
|
|
util_gem 'bad' do |out, err|
|
|
|
|
assert_equal('', out)
|
2013-09-14 04:59:02 -04:00
|
|
|
assert_match "Unknown command bad", err
|
2011-05-31 23:45:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_gem_help_gem_dependencies
|
|
|
|
util_gem 'gem_dependencies' do |out, err|
|
|
|
|
assert_match 'gem.deps.rb', out
|
|
|
|
assert_equal '', err
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def test_gem_help_platforms
|
|
|
|
util_gem 'platforms' do |out, err|
|
|
|
|
assert_match(/x86-freebsd/, out)
|
|
|
|
assert_equal '', err
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_help_commands
|
|
|
|
mgr = Gem::CommandManager.new
|
|
|
|
|
|
|
|
util_gem 'commands' do |out, err|
|
|
|
|
mgr.command_names.each do |cmd|
|
|
|
|
assert_match(/\s+#{cmd}\s+\S+/, out)
|
|
|
|
end
|
2013-07-08 18:41:03 -04:00
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
if defined?(OpenSSL::SSL)
|
2013-09-14 04:59:02 -04:00
|
|
|
assert_empty err
|
|
|
|
|
|
|
|
refute_match 'No command found for ', out
|
|
|
|
end
|
2011-05-31 23:45:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_no_args_shows_help
|
|
|
|
util_gem do |out, err|
|
|
|
|
assert_match(/Usage:/, out)
|
|
|
|
assert_match(/gem install/, out)
|
|
|
|
assert_equal '', err
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def util_gem(*args)
|
2011-05-31 23:45:05 -04:00
|
|
|
@cmd.options[:args] = args
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
Dir.chdir @tempdir do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
yield @ui.output, @ui.error
|
|
|
|
end
|
2019-02-14 07:59:03 -05:00
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
end
|