|
7 | 7 | it "should support github style code blocks" do |
8 | 8 | PrettyText.cook("``` |
9 | 9 | test |
10 | | -```").should == "<pre><code class=\"lang-auto\">test \n</code></pre>" |
| 10 | +```").should match_html "<pre><code class=\"lang-auto\">test \n</code></pre>" |
11 | 11 | end |
12 | 12 |
|
13 | 13 | it "should support quoting [] " do |
14 | 14 | PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"][sam][/quote]").should =~ /\[sam\]/ |
15 | 15 | end |
16 | 16 |
|
17 | 17 | it "produces a quote even with new lines in it" do |
18 | | - PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should == "<p></p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
| 18 | + PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]").should match_html "<p></p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
19 | 19 | end |
20 | 20 |
|
21 | 21 | it "should produce a quote" do |
22 | | - PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should == "<p></p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
| 22 | + PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]").should match_html "<p></p><aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
23 | 23 | end |
24 | 24 |
|
25 | 25 | it "trims spaces on quote params" do |
26 | | - PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should == "<p></p><aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
| 26 | + PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]").should match_html "<p></p><aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n <div class=\"quote-controls\"></div>\n <img width=\"20\" height=\"20\" src=\"/users/eviltrout/avatar/40?__ws=http%3A%2F%2Ftest.localhost\" class=\"avatar \" title=\"\">\n EvilTrout\n said:\n </div>\n <blockquote>ddd</blockquote>\n</aside><p> </p>" |
27 | 27 | end |
28 | 28 |
|
29 | 29 |
|
30 | 30 | it "should handle 3 mentions in a row" do |
31 | | - PrettyText.cook('@hello @hello @hello').should == "<p><span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span></p>" |
| 31 | + PrettyText.cook('@hello @hello @hello').should match_html "<p><span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span></p>" |
32 | 32 | end |
33 | 33 |
|
34 | 34 | it "should not do weird @ mention stuff inside a pre block" do |
35 | 35 |
|
36 | 36 | PrettyText.cook("``` |
37 | 37 | a @test |
38 | | -```").should == "<pre><code class=\"lang-auto\">a @test \n</code></pre>" |
| 38 | +```").should match_html "<pre><code class=\"lang-auto\">a @test \n</code></pre>" |
39 | 39 |
|
40 | 40 | end |
41 | 41 |
|
42 | 42 | it "should sanitize the html" do |
43 | | - PrettyText.cook("<script>alert(42)</script>").should == "alert(42)" |
| 43 | + PrettyText.cook("<script>alert(42)</script>").should match_html "alert(42)" |
44 | 44 | end |
45 | 45 |
|
46 | 46 | it "should escape html within the code block" do |
47 | 47 |
|
48 | 48 | PrettyText.cook("```text |
49 | 49 | <header>hello</header> |
50 | | -```").should == "<pre><code class=\"text\"><header>hello</header> \n</code></pre>" |
| 50 | +```").should match_html "<pre><code class=\"text\"><header>hello</header> \n</code></pre>" |
51 | 51 | end |
52 | 52 |
|
53 | 53 | it "should support language choices" do |
54 | 54 |
|
55 | 55 | PrettyText.cook("```ruby |
56 | 56 | test |
57 | | -```").should == "<pre><code class=\"ruby\">test \n</code></pre>" |
| 57 | +```").should match_html "<pre><code class=\"ruby\">test \n</code></pre>" |
58 | 58 | end |
59 | 59 |
|
60 | 60 | it 'should decorate @mentions' do |
61 | | - PrettyText.cook("Hello @eviltrout").should == "<p>Hello <span class=\"mention\">@eviltrout</span></p>" |
| 61 | + PrettyText.cook("Hello @eviltrout").should match_html "<p>Hello <span class=\"mention\">@eviltrout</span></p>" |
62 | 62 | end |
63 | 63 |
|
64 | 64 | it 'should allow for @mentions to have punctuation' do |
65 | | - PrettyText.cook("hello @bob's @bob,@bob; @bob\"").should == |
66 | | - "<p>hello <span class=\"mention\">@bob</span>'s <span class=\"mention\">@bob</span>,<span class=\"mention\">@bob</span>; <span class=\"mention\">@bob</span>\"</p>" |
| 65 | + PrettyText.cook("hello @bob's @bob,@bob; @bob\"").should |
| 66 | + match_html "<p>hello <span class=\"mention\">@bob</span>'s <span class=\"mention\">@bob</span>,<span class=\"mention\">@bob</span>; <span class=\"mention\">@bob</span>\"</p>" |
67 | 67 | end |
68 | 68 |
|
69 | 69 | it 'should add spoiler tags' do |
70 | | - PrettyText.cook("[spoiler]hello[/spoiler]").should == "<p><span class=\"spoiler\">hello</span></p>" |
| 70 | + PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "<p><span class=\"spoiler\">hello</span></p>" |
71 | 71 | end |
72 | 72 |
|
73 | 73 | it "should only detect ``` at the begining of lines" do |
74 | 74 | PrettyText.cook(" ```\n hello\n ```") |
75 | | - .should == "<pre><code>```\nhello\n```\n</code></pre>" |
| 75 | + .should match_html "<pre><code>```\nhello\n```\n</code></pre>" |
76 | 76 | end |
77 | 77 | end |
78 | 78 |
|
|
0 commit comments