all repos — markup @ eee42c699b63123cc90fd839a64a6ac18eb478d6

The code we use to render README.your_favorite_markup

test/markup_test.rb (view raw)

 1$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
 2
 3require 'github/markup'
 4require 'test/unit'
 5
 6class MarkupTest < Test::Unit::TestCase
 7  Dir['test/markups/README.*'].each do |readme|
 8    next if readme =~ /html$/
 9    markup = readme.split('.').last
10
11    define_method "test_#{markup}" do
12      expected = File.read("#{readme}.html")
13      actual = GitHub::Markup.render(readme, File.read(readme))
14
15      assert expected == actual, <<-message
16#{markup} expected:
17#{expected}
18#{markup} actual:
19#{actual}
20message
21    end
22  end
23
24  def test_knows_what_it_can_and_cannot_render
25    assert_equal false, GitHub::Markup.can_render?('README.html')
26    assert_equal true, GitHub::Markup.can_render?('README.markdown')
27    assert_equal false, GitHub::Markup.can_render?('README.cmd')
28  end
29
30  def test_fails_gracefully_on_missing_commands
31    GitHub::Markup.command(:i_made_it_up, /mde/)
32    text = 'hi there'
33    assert GitHub::Markup.can_render?('README.mde')
34    actual = GitHub::Markup.render('README.mde', text)
35    assert_equal text, actual
36  end
37
38  def test_fails_gracefully_on_missing_env_commands
39    GitHub::Markup.command('/usr/bin/env totally_fake', /tf/)
40    text = 'hey mang'
41    assert GitHub::Markup.can_render?('README.tf')
42    actual = GitHub::Markup.render('README.tf', text)
43    assert_equal text, actual
44  end
45end