|
| 1 | +require 'stringio' |
| 2 | +require 'test/unit' |
| 3 | +require 'rdoc/ri/formatter' |
| 4 | +require 'rdoc/ri/display' |
| 5 | +require 'rdoc/ri/driver' |
| 6 | + |
| 7 | +class TestRDocRIDefaultDisplay < Test::Unit::TestCase |
| 8 | + |
| 9 | + def setup |
| 10 | + @output = StringIO.new |
| 11 | + @width = 78 |
| 12 | + @indent = ' ' |
| 13 | + |
| 14 | + @dd = RDoc::RI::DefaultDisplay.new RDoc::RI::Formatter, @width, true, |
| 15 | + @output |
| 16 | + end |
| 17 | + |
| 18 | + def test_display_class_info |
| 19 | + klass = { |
| 20 | + 'attributes' => [ |
| 21 | + { 'name' => 'author', 'rw' => 'RW', |
| 22 | + 'comment' => RDoc::Markup::Flow::P.new("<b>Recommended</b>: blah") }, |
| 23 | + ], |
| 24 | + 'class_methods' => [], |
| 25 | + 'class_method_extensions' => [], |
| 26 | + 'constants' => [ |
| 27 | + { 'name' => 'VERSION', 'value' => '"1.5.1"', |
| 28 | + 'comment' => RDoc::Markup::Flow::P.new('The version of Hoe') }, |
| 29 | + ], |
| 30 | + 'display_name' => 'Class', |
| 31 | + 'full_name' => 'Hoe', |
| 32 | + 'includes' => [], |
| 33 | + 'instance_methods' => [ |
| 34 | + { 'name' => 'developer' }, |
| 35 | + { 'name' => 'paragraphs_of' }, |
| 36 | + ], |
| 37 | + 'instance_method_extensions' => [], |
| 38 | + 'superclass_string' => 'Object', |
| 39 | + } |
| 40 | + ri_reader = nil |
| 41 | + |
| 42 | + @dd.display_class_info klass, ri_reader |
| 43 | + |
| 44 | + expected = <<-EOF |
| 45 | +---------------------------------------------------------- Class: Hoe < Object |
| 46 | + (no description...) |
| 47 | +------------------------------------------------------------------------------ |
| 48 | +
|
| 49 | +
|
| 50 | +Constants: |
| 51 | +---------- |
| 52 | +
|
| 53 | + VERSION: \"1.5.1\" |
| 54 | +
|
| 55 | +
|
| 56 | +Instance methods: |
| 57 | +----------------- |
| 58 | +
|
| 59 | + developer, paragraphs_of |
| 60 | +
|
| 61 | +Attributes: |
| 62 | + author |
| 63 | + EOF |
| 64 | + |
| 65 | + assert_equal expected, @output.string |
| 66 | + end |
| 67 | + |
| 68 | +end |
| 69 | + |
0 commit comments