~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to test/rubygems/test_kernel.rb

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-24 11:42:29 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080124114229-jw2f87rdxlq6gp11
Tags: 1.9.0.0-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Robustify check for target_os, fixing build failure on lpia.

Show diffs side-by-side

added added

removed removed

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