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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
require 'test_helper'
context "Text" do
test 'escaped text markup' do
pending "Not done yet"
end
test "line breaks" do
assert_xpath "//br", render_string("Well this is +\njust fine and dandy, isn't it?"), 1
end
test "single- and double-quoted text" do
rendered = render_string("``Where?,'' she said, flipping through her copy of `The New Yorker.'")
assert_match /“Where\?,”/, rendered
assert_match /‘The New Yorker.’/, rendered
end
test "separator" do
# for some reason, the html enclosure breaks the xpath //*[@id='content']//hr
assert_xpath "//*[@id='content']//hr", render_string("This is separated.\n\n'''\n\n...from this!"), 1
end
test "emphasized text" do
assert_xpath "//em", render_string("An 'emphatic' no")
end
test "emphasized text with escaped single quote" do
assert_xpath "//em[text()=\"Johnny's\"]", render_string("It's 'Johnny\\'s' phone")
end
test "escaped single quote is restore as single quote" do
assert_xpath "//p[contains(text(), \"Let's do it!\")]", render_string("Let\\'s do it!")
end
test "emphasized text at end of line" do
assert_xpath "//em", render_string("This library is 'awesome'")
end
test "emphasized text at beginning of line" do
assert_xpath "//em", render_string("'drop' it")
end
test "emphasized text across line" do
assert_xpath "//em", render_string("'check it'")
end
test "unquoted text" do
assert_no_match /#/, render_string("An #unquoted# word")
end
test "backtick-escaped text followed by single-quoted text" do
assert_match /<tt>foo<\/tt>/, render_string(%Q(run `foo` 'dog'))
end
context "basic styling" do
setup do
@rendered = render_string("A *BOLD* word. An _italic_ word. A +mono+ word. ^superscript!^ and some ~subscript~.")
end
test "strong" do
assert_xpath "//strong", @rendered
end
test "italic" do
assert_xpath "//em", @rendered
end
test "monospaced" do
assert_xpath "//tt", @rendered
end
test "superscript" do
assert_xpath "//sup", @rendered
end
test "subscript" do
assert_xpath "//sub", @rendered
end
test "backticks" do
assert_xpath "//tt", render_string("This is `totally cool`.")
end
test "nested styles" do
rendered = render_string("Winning *big _time_* in the +city *boyeeee*+.")
assert_xpath "//strong/em", rendered
assert_xpath "//tt/strong", rendered
end
test "unconstrained quotes" do
rendered_chars = render_string("**B**__I__++M++")
assert_xpath "//strong", rendered_chars
assert_xpath "//em", rendered_chars
assert_xpath "//tt", rendered_chars
end
end
end
|