require 'rdoc/test_case' class TestRDocGeneratorDarkfish < RDoc::TestCase def setup super @lib_dir = "#{@pwd}/lib" $LOAD_PATH.unshift @lib_dir # ensure we load from this RDoc @options = RDoc::Options.new @options.option_parser = OptionParser.new @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}" FileUtils.mkdir_p @tmpdir Dir.chdir @tmpdir @options.op_dir = @tmpdir @options.generator = RDoc::Generator::Darkfish $LOAD_PATH.each do |path| darkfish_dir = File.join path, 'rdoc/generator/template/darkfish/' next unless File.directory? darkfish_dir @options.template_dir = darkfish_dir break end @rdoc.options = @options @g = @options.generator.new @store, @options @rdoc.generator = @g @top_level = @store.add_file 'file.rb' @top_level.parser = RDoc::Parser::Ruby @klass = @top_level.add_class RDoc::NormalClass, 'Klass' @alias_constant = RDoc::Constant.new 'A', nil, '' @alias_constant.record_location @top_level @top_level.add_constant @alias_constant @klass.add_module_alias @klass, 'A', @top_level @meth = RDoc::AnyMethod.new nil, 'method' @meth_bang = RDoc::AnyMethod.new nil, 'method!' @attr = RDoc::Attr.new nil, 'attr', 'RW', '' @klass.add_method @meth @klass.add_method @meth_bang @klass.add_attribute @attr @ignored = @top_level.add_class RDoc::NormalClass, 'Ignored' @ignored.ignore @store.complete :private @object = @store.find_class_or_module 'Object' @klass_alias = @store.find_class_or_module 'Klass::A' end def teardown super $LOAD_PATH.shift Dir.chdir @pwd FileUtils.rm_rf @tmpdir end def assert_file path assert File.file?(path), "#{path} is not a file" end def refute_file path refute File.exist?(path), "#{path} exists" end def mu_pp obj s = '' s = PP.pp obj, s s = s.force_encoding Encoding.default_external if defined? Encoding s.chomp end def test_generate top_level = @store.add_file 'file.rb' top_level.add_class @klass.class, @klass.name @g.generate assert_file 'index.html' assert_file 'Object.html' assert_file 'table_of_contents.html' assert_file 'js/search_index.js' encoding = if Object.const_defined? :Encoding then Regexp.escape Encoding::UTF_8.name else Regexp.escape 'UTF-8' end assert_match(/