1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_gem_commands_help_command.rb
sorah 73a1e841d6 * test/rubygems/test_gem_commands_help_command.rb: Add one
`require` because if run test-all with test/unit parallel
  running, sometimes this test fails by some constants not found.
  The error reason is some worker doesn't require the file needed by
  this test. This issue is related to [ruby-core:36168].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-09 02:08:44 +00:00

59 lines
1.2 KiB
Ruby

require "rubygems"
require "rubygems/test_case"
require "rubygems/commands/help_command"
require "rubygems/format"
require "rubygems/command_manager"
require_relative "rubygems_plugin"
class TestGemCommandsHelpCommand < Gem::TestCase
def setup
super
@cmd = Gem::Commands::HelpCommand.new
end
def test_gem_help_bad
util_gem 'bad' do |out, err|
assert_equal('', out)
assert_match(/Unknown command bad. Try gem help commands\n/, err)
end
end
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
assert_equal '', err
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