2 require 'minitest/unit'
4 require 'rdoc/ri/driver'
6 class TestRDocRIDriver < MiniTest::Unit::TestCase
9 @tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_driver_#{$$}"
10 @home_ri = File.join @tmpdir, 'dot_ri'
11 @cache_dir = File.join @home_ri, 'cache'
12 @class_cache = File.join @cache_dir, 'classes'
14 FileUtils.mkdir_p @tmpdir
15 FileUtils.mkdir_p @home_ri
16 FileUtils.mkdir_p @cache_dir
18 @driver = RDoc::RI::Driver.new(RDoc::RI::Driver.process_args([]))
19 @driver.homepath = @home_ri
23 FileUtils.rm_rf @tmpdir
26 def test_lookup_method
27 def @driver.load_cache_for(klassname)
28 { 'Foo#bar' => :found }
31 assert @driver.lookup_method('Foo#bar', 'Foo')
34 def test_lookup_method_class_method
35 def @driver.load_cache_for(klassname)
36 { 'Foo::Bar' => :found }
39 assert @driver.lookup_method('Foo::Bar', 'Foo::Bar')
42 def test_lookup_method_class_missing
43 def @driver.load_cache_for(klassname) end
45 assert_nil @driver.lookup_method('Foo#bar', 'Foo')
48 def test_lookup_method_dot_instance
49 def @driver.load_cache_for(klassname)
50 { 'Foo#bar' => :instance, 'Foo::bar' => :klass }
53 assert_equal :instance, @driver.lookup_method('Foo.bar', 'Foo')
56 def test_lookup_method_dot_class
57 def @driver.load_cache_for(klassname)
58 { 'Foo::bar' => :found }
61 assert @driver.lookup_method('Foo.bar', 'Foo')
64 def test_lookup_method_method_missing
65 def @driver.load_cache_for(klassname) {} end
67 assert_nil @driver.lookup_method('Foo#bar', 'Foo')
71 klass, meth = @driver.parse_name 'Foo::Bar'
73 assert_equal 'Foo::Bar', klass, 'Foo::Bar class'
74 assert_equal nil, meth, 'Foo::Bar method'
76 klass, meth = @driver.parse_name 'Foo#Bar'
78 assert_equal 'Foo', klass, 'Foo#Bar class'
79 assert_equal 'Bar', meth, 'Foo#Bar method'
81 klass, meth = @driver.parse_name 'Foo.Bar'
83 assert_equal 'Foo', klass, 'Foo#Bar class'
84 assert_equal 'Bar', meth, 'Foo#Bar method'
86 klass, meth = @driver.parse_name 'Foo::bar'
88 assert_equal 'Foo', klass, 'Foo::bar class'
89 assert_equal 'bar', meth, 'Foo::bar method'
94 MiniTest::Unit.autorun