1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_kernel.rb
drbrain fbf59bdbea Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-10 07:48:56 +00:00

64 lines
1.5 KiB
Ruby

#!/usr/bin/env ruby
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
require 'test/unit'
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
class TestKernel < RubyGemTestCase
def setup
super
@old_path = $:.dup
util_make_gems
end
def teardown
super
$:.replace @old_path
end
def test_gem
assert gem('a', '= 0.0.1'), "Should load"
assert $:.any? { |p| %r{a-0.0.1/lib} =~ p }
assert $:.any? { |p| %r{a-0.0.1/bin} =~ p }
end
def test_gem_redundent
assert gem('a', '= 0.0.1'), "Should load"
assert ! gem('a', '= 0.0.1'), "Should not load"
assert_equal 1, $:.select { |p| %r{a-0.0.1/lib} =~ p }.size
assert_equal 1, $:.select { |p| %r{a-0.0.1/bin} =~ p }.size
end
def test_gem_overlapping
assert gem('a', '= 0.0.1'), "Should load"
assert ! gem('a', '>= 0.0.1'), "Should not load"
assert_equal 1, $:.select { |p| %r{a-0.0.1/lib} =~ p }.size
assert_equal 1, $:.select { |p| %r{a-0.0.1/bin} =~ p }.size
end
def test_gem_conflicting
assert gem('a', '= 0.0.1'), "Should load"
ex = assert_raise Gem::Exception do
gem 'a', '= 0.0.2'
end
assert_match(/activate a \(= 0\.0\.2\)/, ex.message)
assert_match(/activated a-0\.0\.1/, ex.message)
assert $:.any? { |p| %r{a-0.0.1/lib} =~ p }
assert $:.any? { |p| %r{a-0.0.1/bin} =~ p }
assert ! $:.any? { |p| %r{a-0.0.2/lib} =~ p }
assert ! $:.any? { |p| %r{a-0.0.2/bin} =~ p }
end
end