0
+require File.join(File.dirname(__FILE__), 'setup_test')
0
+class TestTextiled < Test::Unit::TestCase
0
+ fixtures :stories, :authors
0
+ desc_html = '_why announces <i>Sandbox</i>'
0
+ desc_textile = '_why announces __Sandbox__'
0
+ desc_plain = '_why announces Sandbox'
0
+ assert_equal desc_html, story.description
0
+ assert_equal desc_textile, story.description_source
0
+ assert_equal desc_plain, story.description_plain
0
+ def test_desc_after_save
0
+ start_html = '<i>Beautify</i> your <strong>IRb</strong> prompt'
0
+ assert_equal start_html, story.description
0
+ story.description = "**IRb** is simple"
0
+ changed_html = "<b>IRb</b> is simple"
0
+ assert_equal changed_html, story.description
0
+ assert_equal changed_html, story.description
0
+ assert_equal 'IRb is simple', story.description_plain
0
+ def test_desc_toggle_textile
0
+ desc_html = '<i>Beautify</i> your <strong>IRb</strong> prompt'
0
+ desc_textile = '__Beautify__ your *IRb* prompt'
0
+ assert_equal desc_html, story.description
0
+ story.textiled = false
0
+ assert_equal desc_textile, story.description
0
+ assert_equal desc_textile, story.description
0
+ assert_equal desc_html, story.description
0
+ def test_assocation_textiled
0
+ blog_html = '<a href="http://ozmm.org">ones zeros majors and minors</a>'
0
+ blog_textile = '"ones zeros majors and minors":http://ozmm.org'
0
+ blog_plain = 'ones zeros majors and minors'
0
+ assert_equal blog_html, story.author.blog
0
+ assert_equal blog_textile, story.author.blog_source
0
+ assert_equal blog_plain, story.author.blog_plain
0
+ def test_assocation_textile_toggle
0
+ blog_html = '<a href="http://redhanded.hobix.com">RedHanded</a>'
0
+ blog_textile = '"RedHanded":http://redhanded.hobix.com'
0
+ blog_plain = 'RedHanded'
0
+ assert_equal blog_html, story.author.blog
0
+ story.author.textiled = false
0
+ assert_equal blog_textile, story.author.blog
0
+ story.author.textiled = true
0
+ assert_equal blog_html, story.author.blog
0
+ body_html = %[<p><em>Textile</em> is useful because it makes text <em>slightly</em> easier to <strong>read</strong>.</p>\n\n\n\t<p>If only it were so <strong>easy</strong> to use in every programming language. In Rails,\nwith the help of <a href="http://google.com/search?q=acts_as_textiled">acts_as_textiled</a>,\nit’s way easy. Thanks in no small part to <span style="color:red;">RedCloth</span>, of course.</p>]
0
+ body_textile = %[_Textile_ is useful because it makes text _slightly_ easier to *read*.\n\nIf only it were so *easy* to use in every programming language. In Rails,\nwith the help of "acts_as_textiled":http://google.com/search?q=acts_as_textiled,\nit's way easy. Thanks in no small part to %{color:red}RedCloth%, of course.\n]
0
+ body_plain = %[Textile is useful because it makes text slightly easier to read.\n\n\n\tIf only it were so easy to use in every programming language. In Rails,\nwith the help of acts_as_textiled,\nit's way easy. Thanks in no small part to RedCloth, of course.]
0
+ assert_equal body_html, story.body
0
+ assert_equal body_textile, story.body_source
0
+ assert_equal body_plain, story.body_plain
0
+ def test_character_conversions
0
+ body_html = "<p>Is Textile™ the wave of the future? What about acts_as_textiled©? It’s\ndoubtful. Why does Textile™ smell like <em>Python</em>? Can we do anything to\nfix that? No? Well, I guess there are worse smells – like Ruby. jk.</p>\n\n\n\t<p>But seriously, ice > water and water < rain. But…nevermind. 1×1? 1.</p>\n\n\n\t<p>“You’re a good kid,” he said. “Keep it up.”</p>"
0
+ body_plain = %[Is Textile(TM) the wave of the future? What about acts_as_textiled(C)? It's\ndoubtful. Why does Textile(TM) smell like Python? Can we do anything to\nfix that? No? Well, I guess there are worse smells-like Ruby. jk.\n\n\n\tBut seriously, ice > water and water < rain. But...nevermind. 1x1? 1.\n\n\n\t"You're a good kid," he said. "Keep it up."]
0
+ assert_equal body_html, story.body
0
+ assert_equal body_plain, story.body_plain
0
+ desc_html = '_why announces <i>Sandbox</i>'
0
+ assert_equal 0, story.textiled.size
0
+ assert_equal 2, story.textiled.size
0
+ assert_equal desc_html, story.description
0
+ def test_textilize_after_find
0
+ Story.send(:define_method, :after_find, proc { textilize })
0
+ desc_html = '<i>Beautify</i> your <strong>IRb</strong> prompt'
0
+ assert_equal 2, story.textiled.size
0
+ assert_equal desc_html, story.description
Comments
No one has commented yet.