Sha256: aa4e85fdbeaced80661155cd6f2e99e872b971c70a2a567016fe36e65c14447b

Contents?: true

Size: 1.59 KB

Versions: 30

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true
require "rubygems"
require "rubygems/test_case"
require "rubygems/commands/help_command"
require "rubygems/package"
require "rubygems/command_manager"
require File.expand_path('../rubygems_plugin', __FILE__)

class TestGemCommandsHelpCommand < Gem::TestCase
  def setup
    super

    @cmd = Gem::Commands::HelpCommand.new

    load File.expand_path('../rubygems_plugin.rb', __FILE__) unless
      Gem::Commands.const_defined? :InterruptCommand
  end

  def test_gem_help_bad
    util_gem 'bad' do |out, err|
      assert_equal('', out)
      assert_match "Unknown command bad", err
    end
  end

  def test_gem_help_gem_dependencies
    util_gem 'gem_dependencies' do |out, err|
      assert_match 'gem.deps.rb', out
      assert_equal '', 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

      if defined?(OpenSSL::SSL) then
        assert_empty err

        refute_match 'No command found for ', out
      end
    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

30 entries across 30 versions & 2 rubygems

Version Path
rubygems-update-2.7.11 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.10 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.9 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.8 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.7 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.6 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.5 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.4 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.4.pre1 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.3 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.2 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.1 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.7.0 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.14 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.13 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.12 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.11 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.10 test/rubygems/test_gem_commands_help_command.rb
rubygems-update-2.6.9 test/rubygems/test_gem_commands_help_command.rb
ruby-compiler-0.1.1 vendor/ruby/test/rubygems/test_gem_commands_help_command.rb