2 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3 require 'rubygems/gem_path_searcher'
5 class Gem::GemPathSearcher
6 attr_accessor :gemspecs
7 attr_accessor :lib_dirs
14 class TestGemGemPathSearcher < RubyGemTestCase
19 @foo1 = quick_gem 'foo', '0.1' do |s|
20 s.require_paths << 'lib2'
21 s.files << 'lib/foo.rb'
24 path = File.join 'gems', @foo1.full_name, 'lib', 'foo.rb'
25 write_file(path) { |fp| fp.puts "# #{path}" }
27 @foo2 = quick_gem 'foo', '0.2'
28 @bar1 = quick_gem 'bar', '0.1'
29 @bar2 = quick_gem 'bar', '0.2'
31 Gem.source_index = util_setup_source_info_cache @foo1, @foo2, @bar1, @bar2
33 @gps = Gem::GemPathSearcher.new
37 assert_equal @foo1, @gps.find('foo')
40 def test_init_gemspecs
41 assert_equal [@bar2, @bar1, @foo2, @foo1], @gps.init_gemspecs
45 lib_dirs = @gps.lib_dirs_for(@foo1)
46 expected = File.join @gemhome, 'gems', @foo1.full_name, '{lib,lib2}'
48 assert_equal expected, lib_dirs
51 def test_matching_file
52 assert !@gps.matching_file(@foo1, 'bar')
53 assert @gps.matching_file(@foo1, 'foo')