Skip to content

Commit

Permalink
Add tests for the other features added by pull request ruby#39
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Jun 9, 2011
1 parent c59fa96 commit 1924ddf
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 11 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -5,6 +5,8 @@
more cleanly. See RDoc::Markup for details.
* Document-class for RDoc::Parser::C now supports Foo::CONST as well as
CONST.
* ri method output is now a comma-separated list when displayed
interactively. Pull Request #39 by Benoit Daloze.
* Bug fixes
* RDoc::Parser::C no longer creates classes when processing aliases.
* ri no longer crashes when attempting to complete a plain [.
Expand Down
2 changes: 2 additions & 0 deletions Manifest.txt
Expand Up @@ -64,6 +64,7 @@ lib/rdoc/markup/document.rb
lib/rdoc/markup/formatter.rb
lib/rdoc/markup/formatter_test_case.rb
lib/rdoc/markup/heading.rb
lib/rdoc/markup/indented_paragraph.rb
lib/rdoc/markup/inline.rb
lib/rdoc/markup/list.rb
lib/rdoc/markup/list_item.rb
Expand Down Expand Up @@ -132,6 +133,7 @@ test/test_rdoc_include.rb
test/test_rdoc_markup.rb
test/test_rdoc_markup_attribute_manager.rb
test/test_rdoc_markup_document.rb
test/test_rdoc_markup_indented_paragraph.rb
test/test_rdoc_markup_paragraph.rb
test/test_rdoc_markup_parser.rb
test/test_rdoc_markup_pre_process.rb
Expand Down
5 changes: 3 additions & 2 deletions lib/rdoc/markup/indented_paragraph.rb
Expand Up @@ -9,11 +9,12 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
attr_reader :indent

##
# Creates a new IndentedParagraph containing +parts+ indented with +indent+ spaces
# Creates a new IndentedParagraph containing +parts+ indented with +indent+
# spaces

def initialize indent, *parts
raise ArgumentError, "First argument must be the indent as an Integer" unless indent.is_a? Integer
@indent = indent

super(*parts)
end

Expand Down
40 changes: 40 additions & 0 deletions test/test_rdoc_markup_indented_paragraph.rb
@@ -0,0 +1,40 @@
require 'pp'
require 'rubygems'
require 'minitest/autorun'
require 'rdoc/markup'

class TestRDocMarkupIndentedParagraph < MiniTest::Unit::TestCase

def setup
@IP = RDoc::Markup::IndentedParagraph
end

def test_initialize
ip = @IP.new 2, 'a', 'b'

assert_equal 2, ip.indent
assert_equal %w[a b], ip.parts
end

def test_accept
visitor = Object.new
def visitor.accept_indented_paragraph(obj) @obj = obj end
def visitor.obj() @obj end

paragraph = @IP.new 0

paragraph.accept visitor

assert_equal paragraph, visitor.obj
end

def test_equals2
one = @IP.new 1
two = @IP.new 2

assert_equal one, one
refute_equal one, two
end

end

12 changes: 12 additions & 0 deletions test/test_rdoc_markup_paragraph.rb
Expand Up @@ -5,5 +5,17 @@

class TestRDocMarkupParagraph < MiniTest::Unit::TestCase

def test_accept
visitor = Object.new
def visitor.accept_paragraph(obj) @obj = obj end
def visitor.obj() @obj end

paragraph = RDoc::Markup::Paragraph.new

paragraph.accept visitor

assert_equal paragraph, visitor.obj
end

end

10 changes: 10 additions & 0 deletions test/test_rdoc_markup_to_rdoc.rb
Expand Up @@ -323,5 +323,15 @@ def list_verbatim
assert_equal expected, @to.end_accepting
end

def test_accept_indented_paragraph
ip = RDoc::Markup::IndentedParagraph.new 2, 'cats are cool'

@to.start_accepting

@to.accept_indented_paragraph ip

assert_equal " cats are cool\n", @to.end_accepting
end

end

21 changes: 12 additions & 9 deletions test/test_rdoc_ri_driver.rb
Expand Up @@ -22,12 +22,11 @@ def setup
ENV['HOME'] = @tmpdir
ENV.delete 'RI'

options = RDoc::RI::Driver.process_args []
options[:home] = @tmpdir
options[:use_stdout] = true
options[:formatter] = @RM::ToRdoc
@driver = RDoc::RI::Driver.new options
@interactive_driver = RDoc::RI::Driver.new options.merge :interactive => true
@options = RDoc::RI::Driver.process_args []
@options[:home] = @tmpdir
@options[:use_stdout] = true
@options[:formatter] = @RM::ToRdoc
@driver = RDoc::RI::Driver.new @options
end

def teardown
Expand Down Expand Up @@ -192,26 +191,30 @@ def test_add_includes_one
def test_add_method_list
out = @RM::Document.new

@driver.add_method_list out, %w[new], 'Class methods'
@driver.add_method_list out, %w[new parse], 'Class methods'

expected = @RM::Document.new(
@RM::Heading.new(1, 'Class methods:'),
@RM::BlankLine.new,
@RM::Verbatim.new('new'),
@RM::Verbatim.new('parse'),
@RM::BlankLine.new)

assert_equal expected, out
end

def test_add_method_list_interative
@options[:interactive] = true
driver = RDoc::RI::Driver.new @options

out = @RM::Document.new

@interactive_driver.add_method_list out, %w[new], 'Class methods'
driver.add_method_list out, %w[new parse], 'Class methods'

expected = @RM::Document.new(
@RM::Heading.new(1, 'Class methods:'),
@RM::BlankLine.new,
@RM::IndentedParagraph.new(2, 'new'),
@RM::IndentedParagraph.new(2, 'new, parse'),
@RM::BlankLine.new)

assert_equal expected, out
Expand Down

0 comments on commit 1924ddf

Please sign in to comment.