Awesome new codeless way of writing tests!
Chris Wanstrath chris@ozmm.org
Sat, 31 Oct 2009 11:09:59 -0700
18 files changed,
80 insertions(+),
106 deletions(-)
jump to
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.rb
→
test/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.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.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.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> +