Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/rdoc/support/text_formatter_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ def test_accept_paragraph_wrap
# Test case that calls <tt>@to.accept_table</tt>

def test_accept_table_align
header = ['AA', 'BB', 'CCCCC']
header = ['AA', 'BB', 'CCCCC', 'DDDDD']
body = [
['', 'bbb', 'c'],
['aaaa', 'b', ''],
['a', '', 'cc']
['', 'bbb', 'c', ''],
['aaaa', 'b', '', 'dd'],
['a', '', 'cc', 'dd']
]
aligns = [nil, :left, :right]
aligns = [nil, :left, :right, :center]
@to.start_accepting
@to.accept_table header, body, aligns

Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_ansi.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative 'helper'

class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase
class RDocMarkupToAnsiTest < RDoc::Markup::TextFormatterTestCase

add_visitor_tests
add_text_tests
Expand Down Expand Up @@ -350,11 +350,11 @@ def list_verbatim

def accept_table_align
expected = "\e[0m" + <<-EXPECTED
AA |BB |CCCCC
----|---|-----
|bbb| c
aaaa|b |
a | | cc
AA |BB |CCCCC|DDDDD
----|---|-----|-----
|bbb| c|
aaaa|b | | dd
a | | cc| dd
EXPECTED
assert_equal expected, @to.end_accepting
end
Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_bs.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative 'helper'

class TestRDocMarkupToBs < RDoc::Markup::TextFormatterTestCase
class RDocMarkupToBsTest < RDoc::Markup::TextFormatterTestCase

add_visitor_tests
add_text_tests
Expand Down Expand Up @@ -351,11 +351,11 @@ def list_verbatim

def accept_table_align
expected = <<-EXPECTED
AA |BB |CCCCC
----|---|-----
|bbb| c
aaaa|b |
a | | cc
AA |BB |CCCCC|DDDDD
----|---|-----|-----
|bbb| c|
aaaa|b | | dd
a | | cc| dd
EXPECTED
assert_equal expected, @to.end_accepting
end
Expand Down
17 changes: 10 additions & 7 deletions test/rdoc/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative 'helper'

class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
class RDocMarkupToHtmlTest < RDoc::Markup::FormatterTestCase

add_visitor_tests

Expand Down Expand Up @@ -956,31 +956,34 @@ def util_format text
end

def test_accept_table
header = %w[Col1 Col2 Col3]
header = %w[Col1 Col2 Col3 Col4]
body = [
%w[cell1_1 cell1_2 cell1_3],
%w[cell2_1 cell2_2 cell2_3],
['<script>alert("foo");</script>',],
%w[+code+ _em_ **strong**],
%w[cell1_1 cell1_2 cell1_3 cell1_4],
%w[cell2_1 cell2_2 cell2_3 cell2_4],
['<script>alert("foo");</script>'],
%w[+code+ _em_ **strong** C1],
]
aligns = [:left, :right, nil]
aligns = [:left, :right, nil, :center]
@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<<th[^<>]*>Col4</th>>], 'align="center"')
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_include(res[%r<<td[^<>]*>cell2_4</td>>], 'align="center"')
assert_not_include(res, '<script>')
assert_include(res[%r<<td[^<>]*>.*script.*</td>>], '&lt;script&gt;')
assert_include(res[%r<<td[^<>]*>.*code.*</td>>], '<code>code</code>')
assert_include(res[%r<<td[^<>]*>.*em.*</td>>], '<em>em</em>')
assert_include(res[%r<<td[^<>]*>.*strong.*</td>>], '<strong>strong</strong>')
assert_include(res[%r<<td[^<>]*>C1</td>>], 'C1')
end

def assert_escaped(unexpected, code)
Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_markdown.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative 'helper'

class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase
class RDocMarkupToMarkdownTest < RDoc::Markup::TextFormatterTestCase

add_visitor_tests
add_text_tests
Expand Down Expand Up @@ -348,11 +348,11 @@ def list_verbatim

def accept_table_align
expected = <<-EXPECTED
AA |BB |CCCCC
----|---|-----
|bbb| c
aaaa|b |
a | | cc
AA |BB |CCCCC|DDDDD
----|---|-----|-----
|bbb| c|
aaaa|b | | dd
a | | cc| dd
EXPECTED
assert_equal expected, @to.end_accepting
end
Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_rdoc.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require_relative 'helper'

class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
class RDocMarkupToRDocTest < RDoc::Markup::TextFormatterTestCase

add_visitor_tests
add_text_tests
Expand Down Expand Up @@ -348,11 +348,11 @@ def list_verbatim

def accept_table_align
expected = <<-EXPECTED
AA |BB |CCCCC
----|---|-----
|bbb| c
aaaa|b |
a | | cc
AA |BB |CCCCC|DDDDD
----|---|-----|-----
|bbb| c|
aaaa|b | | dd
a | | cc| dd
EXPECTED
assert_equal expected, @to.end_accepting
end
Expand Down
Loading