3 require 'rdoc/ri/driver'
5 class TestRDocRIDriver < Test::Unit::TestCase
8 @tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_driver_#{$$}"
9 @home_ri = File.join @tmpdir, 'dot_ri'
10 @cache_dir = File.join @home_ri, 'cache'
11 @class_cache = File.join @cache_dir, 'classes'
13 FileUtils.mkdir_p @tmpdir
14 FileUtils.mkdir_p @home_ri
15 FileUtils.mkdir_p @cache_dir
17 @driver = RDoc::RI::Driver.new
18 @driver.homepath = @home_ri
22 FileUtils.rm_rf @tmpdir
25 def test_lookup_method
26 def @driver.load_cache_for(klassname)
27 { 'Foo#bar' => :found }
30 assert @driver.lookup_method('Foo#bar', 'Foo')
33 def test_lookup_method_class_method
34 def @driver.load_cache_for(klassname)
35 { 'Foo::Bar' => :found }
38 assert @driver.lookup_method('Foo::Bar', 'Foo::Bar')
41 def test_lookup_method_class_missing
42 def @driver.load_cache_for(klassname) end
44 assert_nil @driver.lookup_method('Foo#bar', 'Foo')
47 def test_lookup_method_dot_instance
48 def @driver.load_cache_for(klassname)
49 { 'Foo#bar' => :instance, 'Foo::bar' => :klass }
52 assert_equal :instance, @driver.lookup_method('Foo.bar', 'Foo')
55 def test_lookup_method_dot_class
56 def @driver.load_cache_for(klassname)
57 { 'Foo::bar' => :found }
60 assert @driver.lookup_method('Foo.bar', 'Foo')
63 def test_lookup_method_method_missing
64 def @driver.load_cache_for(klassname) {} end
66 assert_nil @driver.lookup_method('Foo#bar', 'Foo')
70 klass, meth = @driver.parse_name 'Foo::Bar'
72 assert_equal 'Foo::Bar', klass, 'Foo::Bar class'
73 assert_equal nil, meth, 'Foo::Bar method'
75 klass, meth = @driver.parse_name 'Foo#Bar'
77 assert_equal 'Foo', klass, 'Foo#Bar class'
78 assert_equal 'Bar', meth, 'Foo#Bar method'
80 klass, meth = @driver.parse_name 'Foo.Bar'
82 assert_equal 'Foo', klass, 'Foo#Bar class'
83 assert_equal 'Bar', meth, 'Foo#Bar method'
85 klass, meth = @driver.parse_name 'Foo::bar'
87 assert_equal 'Foo', klass, 'Foo::bar class'
88 assert_equal 'bar', meth, 'Foo::bar method'