2007-11-10 02:48:56 -05:00
|
|
|
#--
|
|
|
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
|
|
|
# All rights reserved.
|
|
|
|
# See LICENSE.txt for permissions.
|
|
|
|
#++
|
|
|
|
|
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
2008-02-10 03:00:19 -05:00
|
|
|
require 'rubygems/package'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
class TestKernel < RubyGemTestCase
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@old_path = $:.dup
|
|
|
|
|
|
|
|
util_make_gems
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
|
|
|
|
|
|
|
$:.replace @old_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem
|
2007-12-20 03:39:12 -05:00
|
|
|
assert gem('a', '= 1'), "Should load"
|
|
|
|
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
|
|
|
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_redundent
|
2007-12-20 03:39:12 -05:00
|
|
|
assert gem('a', '= 1'), "Should load"
|
|
|
|
assert ! gem('a', '= 1'), "Should not load"
|
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_overlapping
|
2007-12-20 03:39:12 -05:00
|
|
|
assert gem('a', '= 1'), "Should load"
|
|
|
|
assert ! gem('a', '>= 1'), "Should not load"
|
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_conflicting
|
2007-12-20 03:39:12 -05:00
|
|
|
assert gem('a', '= 1'), "Should load"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2008-10-25 18:58:43 -04:00
|
|
|
ex = assert_raises Gem::Exception do
|
2007-12-20 03:39:12 -05:00
|
|
|
gem 'a', '= 2'
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2008-06-17 18:04:18 -04:00
|
|
|
assert_match(/activate a \(= 2, runtime\)/, ex.message)
|
2007-12-20 03:39:12 -05:00
|
|
|
assert_match(/activated a-1/, ex.message)
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
|
|
|
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
|
|
|
assert ! $:.any? { |p| %r{a-2/lib} =~ p }
|
|
|
|
assert ! $:.any? { |p| %r{a-2/bin} =~ p }
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|