all repos — markup @ eb6d8b0c480d01a78b9e11ebe22581013c3f9046

The code we use to render README.your_favorite_markup

new testing style, start adding ReST
Chris Wanstrath chris@ozmm.org
Fri, 30 Oct 2009 19:16:29 -0700
commit

eb6d8b0c480d01a78b9e11ebe22581013c3f9046

parent

5f0d596341c85a9ce8950161805faabcb9a16947

3 files changed, 51 insertions(+), 17 deletions(-)

jump to
M lib/github/markups.rblib/github/markups.rb

@@ -6,3 +6,7 @@ markup(:redcloth, /textile/) do |content|

RedCloth.new(content).to_html end +markup('github/markup/rest', /rest|rst/) do |content| + GitHub::Markup::ReST.translate(content) +end +
A test/helper.rb

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

+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

@@ -1,33 +1,55 @@

$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib" +$LOAD_PATH.unshift File.dirname(__FILE__) require 'github/markup' require 'test/unit' +require 'helper' class MarkupTest < Test::Unit::TestCase - def test_markdown - markdown = GitHub::Markup.render('README.markdown', "* One\n* Two") - assert_equal <<markdown, markdown + extend MarkupTestDSL + + def test_graceful_fail + content = "* One\n* Two" + text = GitHub::Markup.render('README.imadeitup', content) + assert_equal content, text + end + + test 'README.markdown', <<-input, <<-output +* One +* Two +input <ul> <li>One</li> <li>Two</li> -</ul> +</ul>\n +output -markdown - end + test 'README.textile', <<-input, <<-output.strip +* One +* Two +input +<ul> +\t<li>One</li> +\t<li>Two</li> +</ul>\n +output - def test_textile - textile = GitHub::Markup.render('README.textile', "* One\n* Two") - assert_equal <<textile.strip, textile + test 'README.txt', <<-input, <<-output +* One +* Two +input +* One +* Two +output + + test 'README.rst', <<-input, <<-output +1. Blah blah ``code`` blah + +2. More ``code``, hooray +input <ul> \t<li>One</li> \t<li>Two</li> </ul> -textile - end - - def test_graceful_fail - content = "* One\n* Two" - text = GitHub::Markup.render('README.imadeitup', content) - assert_equal content, text - end +output end