[前][次][番号順一覧][スレッド一覧]

ruby-changes:73870

From: Nobuyoshi <ko1@a...>
Date: Thu, 6 Oct 2022 18:24:57 +0900 (JST)
Subject: [ruby-changes:73870] e929b0aac5 (master): [ruby/rdoc] Add `RDoc::Markup::ToHtml#accept_table` test

https://git.ruby-lang.org/ruby.git/commit/?id=e929b0aac5

From e929b0aac530f4fe4d905ff147fe94fe2a3e856c Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 6 Oct 2022 11:51:15 +0900
Subject: [ruby/rdoc] Add `RDoc::Markup::ToHtml#accept_table` test

https://github.com/ruby/rdoc/commit/0cb3df713b
---
 test/rdoc/test_rdoc_markup_to_html.rb | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

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 https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_markup_to_html.rb#L876
     @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
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]