summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-06 11:51:15 +0900
committergit <svn-admin@ruby-lang.org>2022-10-06 18:24:43 +0900
commite929b0aac530f4fe4d905ff147fe94fe2a3e856c (patch)
tree6b952245c79fa54880bf1f5de7531b9b1ccd9c39 /test/rdoc
parent4e1086f903030534db636b1417beefeafcfef3b7 (diff)
[ruby/rdoc] Add `RDoc::Markup::ToHtml#accept_table` test
https://github.com/ruby/rdoc/commit/0cb3df713b
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb
index a5927dccae..8a053575d2 100644
--- a/test/rdoc/test_rdoc_markup_to_html.rb
+++ b/test/rdoc/test_rdoc_markup_to_html.rb
@@ -876,5 +876,28 @@ EXPECTED
@to.end_accepting
end
+ def test_accept_table
+ header = %w[Col1 Col2 Col3]
+ body = [
+ %w[cell1_1 cell1_2 cell1_3],
+ %w[cell2_1 cell2_2 cell2_3],
+ ['<script>alert("foo");</script>',],
+ ]
+ aligns = [:left, :right, nil]
+ @to.start_accepting
+ @to.accept_table(header, body, aligns)
+ res = @to.end_accepting
+ assert_include(res[%r<<th[^<>]*>Col1</th>>], 'align="left"')
+ assert_include(res[%r<<th[^<>]*>Col2</th>>], 'align="right"')
+ assert_not_include(res[%r<<th[^<>]*>Col3</th>>], 'align=')
+ assert_include(res[%r<<td[^<>]*>cell1_1</td>>], 'align="left"')
+ assert_include(res[%r<<td[^<>]*>cell1_2</td>>], 'align="right"')
+ assert_not_include(res[%r<<td[^<>]*>cell1_3</td>>], 'align=')
+ assert_include(res[%r<<td[^<>]*>cell2_1</td>>], 'align="left"')
+ assert_include(res[%r<<td[^<>]*>cell2_2</td>>], 'align="right"')
+ assert_not_include(res[%r<<td[^<>]*>cell2_3</td>>], 'align=')
+ assert_not_include(res, '<script>')
+ assert_include(res[%r<<td[^<>]*>.*script.*</td>>], '&lt;script&gt;')
+ end
end