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"
|
2012-11-29 01:52:18 -05:00
|
|
|
require File.expand_path('../rubygems_plugin', __FILE__)
|
2011-05-31 23:45:05 -04:00
|
|
|
|
|
|
|
class TestGemCommandsHelpCommand < Gem::TestCase
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Commands::HelpCommand.new
|
2013-07-08 18:41:03 -04: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
|
|
|
|
2013-09-14 04:59:02 -04:00
|
|
|
if defined?(OpenSSL::SSL) then
|
|
|
|
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
|
|
|
|
|
|
|
|
def util_gem *args
|
|
|
|
@cmd.options[:args] = args
|
|
|
|
|
|
|
|
use_ui @ui do
|
|
|
|
Dir.chdir @tempdir do
|
|
|
|
@cmd.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
yield @ui.output, @ui.error
|
|
|
|
end
|
|
|
|
end
|