all repos — markup @ ec3a87f58737414e3fe898e9e890386bd5c3fcac

The code we use to render README.your_favorite_markup

Awesome new codeless way of writing tests!
Chris Wanstrath chris@ozmm.org
Sat, 31 Oct 2009 11:09:59 -0700
commit

ec3a87f58737414e3fe898e9e890386bd5c3fcac

parent

fd35b684cbec01d16b22dfa3cad18945036394e1

D test/helper.rb

@@ -1,8 +0,0 @@

-module MarkupTestDSL - def test(filename, input, output) - ext = filename.split('.').last - define_method "test_#{ext}" do - assert_equal output, GitHub::Markup.render(filename, input) - end - end -end
M test/markup_test.rbtest/markup_test.rb

@@ -3,106 +3,16 @@ $LOAD_PATH.unshift File.dirname(__FILE__)

require 'github/markup' require 'test/unit' -require 'helper' class MarkupTest < Test::Unit::TestCase - extend MarkupTestDSL + Dir['test/markups/README.*'].each do |readme| + next if readme =~ /html$/ + markup = readme.split('.').last - def test_graceful_fail - content = "* One\n* Two" - text = GitHub::Markup.render('README.imadeitup', content) - assert_equal content, text + define_method "test_#{markup}" do + expected = File.read("#{readme}.html") + actual = GitHub::Markup.render(readme, File.read(readme)) + assert_equal expected, actual + end end - - test 'README.markdown', <<-input, <<-output -* One -* Two -input -<ul> -<li>One</li> -<li>Two</li> -</ul>\n -output - - test 'README.textile', <<-input, <<-output.strip -* One -* Two -input -<ul> -\t<li>One</li> -\t<li>Two</li> -</ul>\n -output - - test 'README.txt', <<-input, <<-output -* One -* Two -input -* One -* Two -output - - test 'README.rdoc', <<-input, <<-output -* One -* Two -input -<ul> -<li>One\n\n</li> -<li>Two\n\n</li> -</ul> -output - - test 'README.asciidoc', <<-input, <<-output -* One -* Two -input -<div class="ulist"><ul>\r -<li>\r -<p>\r -One\r -</p>\r -</li>\r -<li>\r -<p>\r -Two\r -</p>\r -</li>\r -</ul></div>\r\n -output - - test 'README.rst', <<-input, <<-output -1. Blah blah ``code`` blah - -2. More ``code``, hooray -input -<div class="document"> -<ol class="arabic simple"> -<li>Blah blah <tt class="docutils literal">code</tt> blah</li> -<li>More <tt class="docutils literal">code</tt>, hooray</li> -</ol> -</div>\n -output - - - test 'README.pod', <<-input, <<-output -=head1 NAME - -podsample - A sample pod document - -=item * This is a bulleted list. - -=item * Here's another item. -input -<div name="index"> -<p><a name="__index__"></a></p> - -<ul> - -\t<li><a href="#name">NAME</a></li> -</ul> - -<hr name="index" /> -</div> -output - end
A test/markups/README.asciidoc

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.asciidoc.html

@@ -0,0 +1,12 @@

+<div class="ulist"><ul>\r +<li>\r +<p>\r +One\r +</p>\r +</li>\r +<li>\r +<p>\r +Two\r +</p>\r +</li>\r +</ul></div>\r\n
A test/markups/README.markdown

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.markdown.html

@@ -0,0 +1,5 @@

+<ul> +<li>One</li> +<li>Two</li> +</ul> +
A test/markups/README.noformat

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.noformat.html

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.pod

@@ -0,0 +1,7 @@

+=head1 NAME + +podsample - A sample pod document + +=item * This is a bulleted list. + +=item * Here's another item.
A test/markups/README.pod.html

@@ -0,0 +1,10 @@

+<div name="index"> +<p><a name="__index__"></a></p> + +<ul> + + <li><a href="#name">NAME</a></li> +</ul> + +<hr name="index" /> +</div>
A test/markups/README.rdoc

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.rdoc.html

@@ -0,0 +1,8 @@

+<ul> +<li>One + +</li> +<li>Two + +</li> +</ul>
A test/markups/README.rst

@@ -0,0 +1,3 @@

+1. Blah blah ``code`` blah + +2. More ``code``, hooray
A test/markups/README.rst.html

@@ -0,0 +1,7 @@

+<div class="document"> +<ol class="arabic simple"> +<li>Blah blah <tt class="docutils literal">code</tt> blah</li> +<li>More <tt class="docutils literal">code</tt>, hooray</li> +</ol> +</div> +
A test/markups/README.textile

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.textile.html

@@ -0,0 +1,4 @@

+<ul> + <li>One</li> + <li>Two</li> +</ul>
A test/markups/README.txt

@@ -0,0 +1,2 @@

+* One +* Two
A test/markups/README.txt.html

@@ -0,0 +1,2 @@

+* One +* Two