2011-01-18 19:08:49 -05:00
|
|
|
######################################################################
|
|
|
|
# This file is imported from the rubygems project.
|
|
|
|
# DO NOT make modifications in this repo. They _will_ be reverted!
|
|
|
|
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
|
|
|
######################################################################
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestKernel < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
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 }
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
def test_gem_redundant
|
2007-12-20 03:39:12 -05:00
|
|
|
assert gem('a', '= 1'), "Should load"
|
2009-06-09 17:38:59 -04:00
|
|
|
refute gem('a', '= 1'), "Should not load"
|
2007-12-20 03:39:12 -05:00
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ 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"
|
2009-06-09 17:38:59 -04:00
|
|
|
refute gem('a', '>= 1'), "Should not load"
|
2007-12-20 03:39:12 -05:00
|
|
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ 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
|
|
|
|
2009-06-09 17:38:59 -04:00
|
|
|
ex = assert_raises Gem::LoadError do
|
2007-12-20 03:39:12 -05:00
|
|
|
gem 'a', '= 2'
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2011-03-07 03:44:45 -05:00
|
|
|
assert_match(/activate a \(= 2\)/, ex.message)
|
2007-12-20 03:39:12 -05:00
|
|
|
assert_match(/activated a-1/, ex.message)
|
2009-06-09 17:38:59 -04:00
|
|
|
assert_equal 'a', ex.name
|
2011-01-18 19:08:49 -05:00
|
|
|
assert_equal Gem::Requirement.new('= 2'), ex.requirement
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2007-12-20 03:39:12 -05:00
|
|
|
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
2009-06-09 17:38:59 -04:00
|
|
|
refute $:.any? { |p| %r{a-2/lib} =~ p }
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2011-01-18 19:08:49 -05:00
|
|
|
def test_gem_not_adding_bin
|
|
|
|
assert gem('a', '= 1'), "Should load"
|
|
|
|
refute $:.any? { |p| %r{a-1/bin} =~ p }
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|