test/test-readme-parser.rb in rabbit-2.1.1 vs test/test-readme-parser.rb in rabbit-2.1.2

- old
+ new

@@ -17,43 +17,141 @@ require "rabbit/readme-parser" class TestREADMEParser < Test::Unit::TestCase def setup @parser = Rabbit::READMEParser.new - end - - def test_rd - title = "Theme benchmark" - description = <<-EOD.strip + @title = "Theme benchmark" + @description = <<-DESCRIPTION.strip It's a slide for checking a Rabbit's theme. It contains many elements. So it's useful for confirming your theme. Please try to create your original theme! -EOD + DESCRIPTION + end - assert_parse(title, description, <<-EOR) -= #{title} + private + def assert_parse(content, extension=nil) + readme_path = "README#{extension}" + stub(File).read(readme_path) {content} + @parser.parse(readme_path) + assert_equal({ + :title => @title, + :description => @description, + }, + { + :title => @parser.title, + :description => @parser.description, + }) + end -#{description} + class TestRD < self + private + def readme_content + <<-README += #{@title} +#{@description} + == For author === Show rake -EOR + README + end + + class TestExtension < self + def test_no_extension + assert_parse(readme_content) + end + + def test_rd + assert_parse(readme_content, ".rd") + end + + def test_rab + assert_parse(readme_content, ".rab") + end + end end - private - def assert_parse(title, description, content) - stub(File).read("README") {content} - @parser.parse("README") - assert_equal({ - :title => title, - :description => description, - }, - { - :title => @parser.title, - :description => @parser.description, - }) + class TestHiki < self + private + def readme_content + <<-README +! #{@title} + +#{@description} + +!! For author + +!!! Show + + rake + README + end + + class TestExtension < self + def test_no_extension + assert_parse(readme_content) + end + + def test_hiki + assert_parse(readme_content, ".hiki") + end + end + end + + class TestMarkdown < self + private + def readme_content + <<-README +# #{@title} + +#{@description} + +## For author + +### Show + + rake + README + end + + class TestExtension < self + def test_no_extension + assert_parse(readme_content) + end + + def test_md + assert_parse(readme_content, ".md") + end + end + end + + class TestTextile < self + private + def readme_content + <<-README +h1. #{@title} + +#{@description} + +h2. For author + +h3. Show + + rake + README + end + + class TestExtension < self + def test_no_extension + assert_parse(readme_content) + end + + def test_textile + assert_parse(readme_content, ".textile") + end + end end end