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

« back to all changes in this revision

Viewing changes to test/rubygems/test_gem_command_manager.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_relative 'gemutilities'
 
1
require 'rubygems/test_case'
2
2
require 'rubygems/command_manager'
3
3
 
4
 
class TestGemCommandManager < RubyGemTestCase
 
4
class TestGemCommandManager < Gem::TestCase
5
5
 
6
6
  def setup
7
7
    super
10
10
  end
11
11
 
12
12
  def test_run_interrupt
13
 
    Gem.load_plugins
 
13
    old_load_path = $:.dup
 
14
    $: << File.expand_path("test/rubygems", @@project_dir)
 
15
    Gem.load_env_plugins
14
16
 
15
17
    use_ui @ui do
16
 
      assert_raises MockGemUi::TermError do
 
18
      assert_raises Gem::MockGemUi::TermError do
17
19
        @command_manager.run 'interrupt'
18
20
      end
19
21
      assert_equal '', ui.output
20
22
      assert_equal "ERROR:  Interrupted\n", ui.error
21
23
    end
 
24
  ensure
 
25
    $:.replace old_load_path
 
26
    Gem::CommandManager.reset
22
27
  end
23
28
 
24
29
  def test_run_crash_command
 
30
    old_load_path = $:.dup
 
31
    $: << File.expand_path("test/rubygems", @@project_dir)
 
32
 
25
33
    @command_manager.register_command :crash
26
34
    use_ui @ui do
27
 
      assert_raises MockGemUi::TermError do
 
35
      assert_raises Gem::MockGemUi::TermError do
28
36
        @command_manager.run 'crash'
29
37
      end
30
38
      assert_equal '', ui.output
31
39
      err = ui.error.split("\n").first
32
40
      assert_equal "ERROR:  Loading command: crash (RuntimeError)", err
33
41
    end
 
42
  ensure
 
43
    $:.replace old_load_path
 
44
    @command_manager.unregister_command :crash
34
45
  end
35
46
 
36
47
  def test_process_args_bad_arg
37
48
    use_ui @ui do
38
 
      assert_raises(MockGemUi::TermError) {
 
49
      assert_raises Gem::MockGemUi::TermError do
39
50
        @command_manager.process_args("--bad-arg")
40
 
      }
 
51
      end
41
52
    end
42
53
 
43
54
    assert_match(/invalid option: --bad-arg/i, @ui.error)
54
65
 
55
66
      #check defaults
56
67
      @command_manager.process_args("install")
57
 
      assert_equal false, check_options[:test]
58
68
      assert_equal true, check_options[:generate_rdoc]
59
69
      assert_equal false, check_options[:force]
60
70
      assert_equal :both, check_options[:domain]
66
76
      #check settings
67
77
      check_options = nil
68
78
      @command_manager.process_args(
69
 
        "install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
 
79
        "install --force --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
70
80
      assert_equal true, check_options[:generate_rdoc]
71
81
      assert_equal true, check_options[:force]
72
82
      assert_equal :local, check_options[:domain]
195
205
 
196
206
    #check settings
197
207
    check_options = nil
198
 
    @command_manager.process_args("update --force --test --rdoc --install-dir .")
 
208
    @command_manager.process_args("update --force --rdoc --install-dir .")
199
209
    assert_equal true, check_options[:generate_rdoc]
200
210
    assert_equal true, check_options[:force]
201
211
    assert_equal Dir.pwd, check_options[:install_dir]