##// END OF EJS Templates
More detailed failures message....
Jean-Philippe Lang -
r3456:c312b8b0584a
parent child
Show More
@@ -1,81 +1,81
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.dirname(__FILE__) + '/../../../../test_helper'
18 require File.dirname(__FILE__) + '/../../../../test_helper'
19
19
20 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
20 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase
21
21
22 def setup
22 def setup
23 @formatter = Redmine::WikiFormatting::Textile::Formatter
23 @formatter = Redmine::WikiFormatting::Textile::Formatter
24 end
24 end
25
25
26 MODIFIERS = {
26 MODIFIERS = {
27 "*" => 'strong', # bold
27 "*" => 'strong', # bold
28 "_" => 'em', # italic
28 "_" => 'em', # italic
29 "+" => 'ins', # underline
29 "+" => 'ins', # underline
30 "-" => 'del', # deleted
30 "-" => 'del', # deleted
31 "^" => 'sup', # superscript
31 "^" => 'sup', # superscript
32 "~" => 'sub' # subscript
32 "~" => 'sub' # subscript
33 }
33 }
34
34
35 def test_modifiers
35 def test_modifiers
36 assert_html_output(
36 assert_html_output(
37 '*bold*' => '<strong>bold</strong>',
37 '*bold*' => '<strong>bold</strong>',
38 'before *bold*' => 'before <strong>bold</strong>',
38 'before *bold*' => 'before <strong>bold</strong>',
39 '*bold* after' => '<strong>bold</strong> after',
39 '*bold* after' => '<strong>bold</strong> after',
40 '*two words*' => '<strong>two words</strong>',
40 '*two words*' => '<strong>two words</strong>',
41 '*two*words*' => '<strong>two*words</strong>',
41 '*two*words*' => '<strong>two*words</strong>',
42 '*two * words*' => '<strong>two * words</strong>',
42 '*two * words*' => '<strong>two * words</strong>',
43 '*two* *words*' => '<strong>two</strong> <strong>words</strong>',
43 '*two* *words*' => '<strong>two</strong> <strong>words</strong>',
44 '*(two)* *(words)*' => '<strong>(two)</strong> <strong>(words)</strong>',
44 '*(two)* *(words)*' => '<strong>(two)</strong> <strong>(words)</strong>',
45 # with class
45 # with class
46 '*(foo)two words*' => '<strong class="foo">two words</strong>'
46 '*(foo)two words*' => '<strong class="foo">two words</strong>'
47 )
47 )
48 end
48 end
49
49
50 def test_modifiers_combination
50 def test_modifiers_combination
51 MODIFIERS.each do |m1, tag1|
51 MODIFIERS.each do |m1, tag1|
52 MODIFIERS.each do |m2, tag2|
52 MODIFIERS.each do |m2, tag2|
53 next if m1 == m2
53 next if m1 == m2
54 text = "#{m2}#{m1}Phrase modifiers#{m1}#{m2}"
54 text = "#{m2}#{m1}Phrase modifiers#{m1}#{m2}"
55 html = "<#{tag2}><#{tag1}>Phrase modifiers</#{tag1}></#{tag2}>"
55 html = "<#{tag2}><#{tag1}>Phrase modifiers</#{tag1}></#{tag2}>"
56 assert_html_output text => html
56 assert_html_output text => html
57 end
57 end
58 end
58 end
59 end
59 end
60
60
61 def test_inline_code
61 def test_inline_code
62 assert_html_output(
62 assert_html_output(
63 'this is @some code@' => 'this is <code>some code</code>',
63 'this is @some code@' => 'this is <code>some code</code>',
64 '@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>'
64 '@<Location /redmine>@' => '<code>&lt;Location /redmine&gt;</code>'
65 )
65 )
66 end
66 end
67
67
68 def test_escaping
68 def test_escaping
69 assert_html_output(
69 assert_html_output(
70 'this is a <script>' => 'this is a &lt;script&gt;'
70 'this is a <script>' => 'this is a &lt;script&gt;'
71 )
71 )
72 end
72 end
73
73
74 private
74 private
75
75
76 def assert_html_output(to_test)
76 def assert_html_output(to_test)
77 to_test.each do |text, expected|
77 to_test.each do |text, expected|
78 assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html
78 assert_equal "<p>#{expected}</p>", @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n"
79 end
79 end
80 end
80 end
81 end
81 end
General Comments 0
You need to be logged in to leave comments. Login now