Sha256: d6dd01799fd443af848587c29354878301708857dae5eb85b0520f4c4221e235

Contents?: true

Size: 1.16 KB

Versions: 32

Compression:

Stored size: 1.16 KB

Contents

require "rubygems"
require "rubygems/test_case"
require "rubygems/commands/help_command"
require "rubygems/format"
require "rubygems/command_manager"

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

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
rubygems-update-1.8.30 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.29 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.28 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.23.2 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.27 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.26 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.25 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.24 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.23 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.22 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.21 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.20 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.19 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.18 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.17 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.16 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.15 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.14 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.13 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-1.8.12 test/rubygems/test_gem_commands_help_command.rb