1 require File.dirname(__FILE__) + '/../helpers'
2 require 'bloggit/text_formatter'
4 class TextFormatterTest < Test::Unit::TestCase
6 should "render text using Textile" do
7 keys = [:textile, :Textile, :teXtile, 'Textile', 'teXTIle']
9 output = Bloggit::TextFormatter.render('Hello, *Sally*', key)
10 assert_equal "<p>Hello, <strong>Sally</strong></p>", output
14 should "render text using Markdown" do
15 keys = [:markdown, :Markdown, :markDOWN, 'Markdown', 'MarKDowN']
17 output = Bloggit::TextFormatter.render('Hello, *Sally*', key)
18 assert_equal "<p>Hello, <em>Sally</em></p>", output
22 should "raise an error when trying to use an undefined format" do
23 assert_raise(RuntimeError) { Bloggit::TextFormatter.render('Hello, *Sally*', :cpt_gloval) }
26 should "allow registration of custom text formatter" do
27 # Register Formatter...
28 Bloggit::TextFormatter.register :rdoc do |text|
29 require 'rdoc/markup/simple_markup'
30 require 'rdoc/markup/simple_markup/to_html'
32 p = SM::SimpleMarkup.new
37 assert_nothing_raised(RuntimeError) do
38 output = Bloggit::TextFormatter.render('Hello, *Sally*', :rdoc)
39 assert_equal "<p>\nHello, <b>Sally</b>\n</p>\n", output