aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/guides/textile_extionsions_test.rb
blob: 9f1068d9be5b7b48e63014a529a5ec0258273a7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'isolation/abstract_unit'
require 'guides/rails_guides/textile_extensions'

class TextileExtensionsTest < Test::Unit::TestCase
  include ActiveSupport::Testing::Isolation
  include RailsGuides::TextileExtensions
  
  test "tips can handle a single line" do
    expected_output = "<div class='info'><p>this is a single line tip</p></div>"
    assert_equal expected_output, tip('TIP. this is a single line tip')
  end

  def setup
    @multi_line_tip = "This is a multi-line tip.\n" +
      "Isn't it fantastic?"
  end

  test "tips can handle a multi-line tip" do
    expected_output = "<div class='info'><p>#{@multi_line_tip}</p></div>"

    assert_equal expected_output, tip("TIP. #{@multi_line_tip}")
  end

  test "muli-line tips handles text before and after the tip" do
    pre_line = "This is text before hand.\n\n"
    post_line = "\n\nThis is some text after"
    input_text = pre_line +
      "TIP. #{@multi_line_tip}" +
      post_line

    expected_output = pre_line +
      "<div class='info'><p>#{@multi_line_tip}</p></div>" +
      post_line

    assert_equal expected_output, tip(input_text)
  end
end