~ubuntu-branches/ubuntu/lucid/jruby/lucid

« back to all changes in this revision

Viewing changes to test/externals/ruby1.9/rubygems/test_kernel.rb

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Delafond
  • Date: 2009-12-09 17:30:55 UTC
  • Revision ID: james.westby@ubuntu.com-20091209173055-8ffzikq1768gywux
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#--
 
2
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
 
3
# All rights reserved.
 
4
# See LICENSE.txt for permissions.
 
5
#++
 
6
 
 
7
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
 
8
require 'rubygems/package'
 
9
 
 
10
class TestKernel < RubyGemTestCase
 
11
 
 
12
  def setup
 
13
    super
 
14
 
 
15
    @old_path = $:.dup
 
16
 
 
17
    util_make_gems
 
18
  end
 
19
 
 
20
  def teardown
 
21
    super
 
22
 
 
23
    $:.replace @old_path
 
24
  end
 
25
 
 
26
  def test_gem
 
27
    assert gem('a', '= 1'), "Should load"
 
28
    assert $:.any? { |p| %r{a-1/lib} =~ p }
 
29
    assert $:.any? { |p| %r{a-1/bin} =~ p }
 
30
  end
 
31
 
 
32
  def test_gem_redundent
 
33
    assert gem('a', '= 1'), "Should load"
 
34
    assert ! gem('a', '= 1'), "Should not load"
 
35
    assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
 
36
    assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
 
37
  end
 
38
 
 
39
  def test_gem_overlapping
 
40
    assert gem('a', '= 1'), "Should load"
 
41
    assert ! gem('a', '>= 1'), "Should not load"
 
42
    assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
 
43
    assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
 
44
  end
 
45
 
 
46
  def test_gem_conflicting
 
47
    assert gem('a', '= 1'), "Should load"
 
48
 
 
49
    ex = assert_raises Gem::Exception do
 
50
      gem 'a', '= 2'
 
51
    end
 
52
 
 
53
    assert_match(/activate a \(= 2, runtime\)/, ex.message)
 
54
    assert_match(/activated a-1/, ex.message)
 
55
 
 
56
    assert $:.any? { |p| %r{a-1/lib} =~ p }
 
57
    assert $:.any? { |p| %r{a-1/bin} =~ p }
 
58
    assert ! $:.any? { |p| %r{a-2/lib} =~ p }
 
59
    assert ! $:.any? { |p| %r{a-2/bin} =~ p }
 
60
  end
 
61
 
 
62
end
 
63