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

« back to all changes in this revision

Viewing changes to test/rubygems/test_gem_gem_path_searcher.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
require 'test/unit'
 
2
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
 
3
require 'rubygems/gem_path_searcher'
 
4
 
 
5
class Gem::GemPathSearcher
 
6
  attr_accessor :gemspecs
 
7
  attr_accessor :lib_dirs
 
8
 
 
9
  public :init_gemspecs
 
10
  public :matching_file
 
11
  public :lib_dirs_for
 
12
end
 
13
 
 
14
class TestGemGemPathSearcher < RubyGemTestCase
 
15
 
 
16
  def setup
 
17
    super
 
18
 
 
19
    @foo1 = quick_gem 'foo', '0.1' do |s|
 
20
      s.require_paths << 'lib2'
 
21
      s.files << 'lib/foo.rb'
 
22
    end
 
23
 
 
24
    path = File.join 'gems', @foo1.full_name, 'lib', 'foo.rb'
 
25
    write_file(path) { |fp| fp.puts "# #{path}" }
 
26
 
 
27
    @foo2 = quick_gem 'foo', '0.2'
 
28
    @bar1 = quick_gem 'bar', '0.1'
 
29
    @bar2 = quick_gem 'bar', '0.2'
 
30
 
 
31
    Gem.source_index = util_setup_source_info_cache @foo1, @foo2, @bar1, @bar2
 
32
 
 
33
    @gps = Gem::GemPathSearcher.new
 
34
  end
 
35
 
 
36
  def test_find
 
37
    assert_equal @foo1, @gps.find('foo')
 
38
  end
 
39
 
 
40
  def test_init_gemspecs
 
41
    assert_equal [@bar2, @bar1, @foo2, @foo1], @gps.init_gemspecs
 
42
  end
 
43
 
 
44
  def test_lib_dirs_for
 
45
    lib_dirs = @gps.lib_dirs_for(@foo1)
 
46
    expected = File.join @gemhome, 'gems', @foo1.full_name, '{lib,lib2}'
 
47
 
 
48
    assert_equal expected, lib_dirs
 
49
  end
 
50
 
 
51
  def test_matching_file
 
52
    assert !@gps.matching_file(@foo1, 'bar')
 
53
    assert @gps.matching_file(@foo1, 'foo')
 
54
  end
 
55
 
 
56
end
 
57