~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/rubygems/test_gem_commands_help_command.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require "rubygems"
 
2
require "rubygems/test_case"
 
3
require "rubygems/commands/help_command"
 
4
require "rubygems/format"
 
5
require "rubygems/command_manager"
 
6
 
 
7
class TestGemCommandsHelpCommand < Gem::TestCase
 
8
  def setup
 
9
    super
 
10
 
 
11
    @cmd = Gem::Commands::HelpCommand.new
 
12
  end
 
13
 
 
14
  def test_gem_help_bad
 
15
    util_gem 'bad' do |out, err|
 
16
      assert_equal('', out)
 
17
      assert_match(/Unknown command bad. Try gem help commands\n/, err)
 
18
    end
 
19
  end
 
20
 
 
21
  def test_gem_help_platforms
 
22
    util_gem 'platforms' do |out, err|
 
23
      assert_match(/x86-freebsd/, out)
 
24
      assert_equal '', err
 
25
    end
 
26
  end
 
27
 
 
28
  def test_gem_help_commands
 
29
    mgr = Gem::CommandManager.new
 
30
 
 
31
    util_gem 'commands' do |out, err|
 
32
      mgr.command_names.each do |cmd|
 
33
        assert_match(/\s+#{cmd}\s+\S+/, out)
 
34
      end
 
35
      assert_equal '', err
 
36
    end
 
37
  end
 
38
 
 
39
  def test_gem_no_args_shows_help
 
40
    util_gem do |out, err|
 
41
      assert_match(/Usage:/, out)
 
42
      assert_match(/gem install/, out)
 
43
      assert_equal '', err
 
44
    end
 
45
  end
 
46
 
 
47
  def util_gem *args
 
48
    @cmd.options[:args] = args
 
49
 
 
50
    use_ui @ui do
 
51
      Dir.chdir @tempdir do
 
52
        @cmd.execute
 
53
      end
 
54
    end
 
55
 
 
56
    yield @ui.output, @ui.error
 
57
  end
 
58
end