0
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/'
0
require 'rdoc/generator/texinfo'
0
# give us access to check this stuff before it's rendered
0
class RDoc::Generator::Texinfo; attr_reader :files, :classes; end
0
class RDoc::RDoc; attr_reader :options; attr_reader :gen; end
0
class TestRdocInfoSections < Test::Unit::TestCase
0
- OUTPUT_DIR = "/tmp/rdoc-#{$$}"
0
- $stdout = File.new('/dev/null','w')
0
- $stderr = File.new('/dev/null','w')
0
+ @output_dir = File.join Dir.tmpdir, "test_rdoc_info_sections_#{$$}"
0
+ @output_file = File.join @output_dir, 'rdoc.texinfo'
0
+ @input_file = Tempfile.new 'my_file.rb'
0
+ open @input_file.path, 'w' do |io|
0
+ RDoc::Parser.alias_extension '.rb', File.extname(@input_file.path)
0
- @rdoc.document(['--fmt=texinfo',
0
- File.expand_path(File.dirname(__FILE__) + '/../lib/rdoc/generator/texinfo.rb'),
0
- File.expand_path(File.dirname(__FILE__) + '/../README.txt'),
0
- "--op=#{OUTPUT_DIR}"])
0
- @text = File.read(OUTPUT_DIR + '/rdoc.texinfo')
0
+ @rdoc.document(['--fmt=texinfo', '--quiet', @input_file.path,
0
+ "--op=#{@output_dir}"])
0
+ @text = File.read @output_file
0
- FileUtils.rm_rf OUTPUT_DIR
0
+ FileUtils.rm_rf @output_dir
0
@@ -35,34 +40,37 @@ class TestRdocInfoSections < Test::Unit::TestCase
0
def test_each_class_has_a_chapter
0
- assert_section "Class RDoc::Generator::Texinfo", '@chapter'
0
- assert_section "Class RDoc::Generator::TexinfoTemplate", '@chapter'
0
+ assert_section "Class MyClass", '@chapter'
0
def test_class_descriptions_are_given
0
- assert_match(/
This generates .*Texinfo.* files for viewing with GNU Info or Emacs from .*RDoc.* extracted from Ruby source files/, @text.gsub("\n", ' '))
0
+ assert_match(/
Documentation for my class/, @text.gsub("\n", ' '))
0
def test_included_modules_are_given
0
- assert_match(/Includes.*
Generator::MarkUp/m, @text)
0
+ assert_match(/Includes.*
MyModule/m, @text)
0
def test_class_methods_are_given
0
- assert_match(/
new\(options\)/, @text)
0
+ assert_match(/
my_class_method\(my_first_argument\)/, @text)
0
def test_classes_instance_methods_are_given
0
- assert_section 'Class RDoc::Generator::Texinfo#generate'
0
- assert_match(/generate\(toplevels\)/, @text)
0
+ assert_section 'Class MyClass#my_method'
0
+ assert_match(/my_method\(my_first_argument\)/, @text)
0
def test_each_module_has_a_chapter
0
- assert_section "RDoc", '@chapter'
0
- assert_section "Generator", '@chapter'
0
+ assert_section 'MyModule', '@chapter'
0
def test_methods_are_shown_only_once
0
- methods = @rdoc.gen.classes.map { |c| c.methods.map{ |m| c.name + '#' + m.name } }.flatten
0
+ methods = @rdoc.gen.classes.map do |c|
0
assert_equal methods, methods.uniq
0
@@ -82,12 +90,47 @@ class TestRdocInfoSections < Test::Unit::TestCase
0
# def test_oh_yeah_dont_forget_files
0
def assert_section(name, command = '@section')
0
assert_match Regexp.new("^#{command}.*#{Regexp.escape name}"), @text, "Could not find a #{command} #{name}"
0
-# @real_stdout.puts(*args)
0
+# Documentation for my module
0
+ # Documentation for my included method
0
+ def my_included_method() end
0
+# Documentation for my class
0
+ # Documentation for my constant
0
+ MY_CONSTANT = 'my value'
0
+ # Documentation for my class method
0
+ def self.my_class_method(my_first_argument) end
0
+ # Documentation for my method
0
+ def my_method(my_first_argument) end
Comments
No one has commented yet.