test/test_rdoc_servlet.rb in rdoc-4.0.0.preview2.1 vs test/test_rdoc_servlet.rb in rdoc-4.0.0.rc.2

- old
+ new

@@ -10,11 +10,11 @@ @tempdir = File.join Dir.tmpdir, "test_rdoc_servlet_#{$$}" Gem.use_paths @tempdir Gem.ensure_gem_subdirectories @tempdir @spec = Gem::Specification.new 'spec', '1.0' - @spec.loaded_from = File.join @tempdir, @spec.spec_file + @spec.loaded_from = @spec.spec_file Gem::Specification.reset Gem::Specification.all = [@spec] @server = {} @@ -32,17 +32,19 @@ instance_variable_set :@path, path end @req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] } - @base = File.join @tempdir, 'base' - @system_dir = File.join @tempdir, 'base', 'system' + @base = File.join @tempdir, 'base' + @system_dir = File.join @tempdir, 'base', 'system' + @home_dir = File.join @tempdir, 'home' + @gem_doc_dir = File.join @tempdir, 'doc' @orig_base = RDoc::RI::Paths::BASE RDoc::RI::Paths::BASE.replace @base @orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR - RDoc::RI::Paths::HOMEDIR.replace File.join @tempdir, 'home' + RDoc::RI::Paths::HOMEDIR.replace @home_dir RDoc::RI::Paths.instance_variable_set \ :@gemdirs, %w[/nonexistent/gems/example-1.0/ri] end @@ -361,11 +363,11 @@ ], 'longSearchIndex' => %w[ Ruby\ Documentation ], 'info' => [ - ['Ruby Documentation', '', @system_dir, '', + ['Ruby Documentation', '', 'ruby', '', 'Documentation for the Ruby standard library'], ], } } @@ -412,9 +414,45 @@ @s.show_documentation @req, @res assert_equal 'application/javascript', @res.content_type assert_match %r%\Avar search_data =%, @res.body + end + + def test_store_for_gem + store = @s.store_for 'spec-1.0' + + assert_equal File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path + assert_equal :gem, store.type + end + + def test_store_for_home + store = @s.store_for 'home' + + assert_equal @home_dir, store.path + assert_equal :home, store.type + end + + def test_store_for_missing + e = assert_raises RDoc::Error do + @s.store_for 'missing' + end + + assert_equal 'could not find ri documentation for missing', e.message + end + + def test_store_for_ruby + store = @s.store_for 'ruby' + + assert_equal @system_dir, store.path + assert_equal :system, store.type + end + + def test_store_for_site + store = @s.store_for 'site' + + assert_equal File.join(@base, 'site'), store.path + assert_equal :site, store.type end def touch_system_cache_path store = RDoc::Store.new @system_dir store.title = 'Standard Library Documentation'