Skip to content

Commit 71d4090

Browse files
authored
Change error message assertion to make it pass in JRuby (#1425)
Fix JRuby ci failure ``` Failure: test_check_files_warn(RDocOptionsTest) /home/runner/work/rdoc/rdoc/test/rdoc/rdoc_options_test.rb:50:in 'test_check_files_warn' 49: assert_empty out => 50: assert_equal "file 'nonexistent' not found\n", err 51: assert_empty @options.files 52: end <"file 'nonexistent' not found\n"> expected but was <"/home/runner/work/rdoc/rdoc/lib/rdoc/options.rb:1370: warning: file 'nonexistent' not found\n"> ``` Related to ruby/prism#3647
1 parent 2308312 commit 71d4090

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

test/rdoc/rdoc_context_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_add_method_duplicate
237237
expected = 'Duplicate method (unknown)#name in file second.rb, ' \
238238
'previously in file first.rb'
239239

240-
assert_equal expected, err.chomp
240+
assert_include err, expected
241241

242242
method = @context.method_list.first
243243

test/rdoc/rdoc_encoding_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_class_read_file_encoding_fail
6060

6161
assert_nil contents
6262

63-
assert_match %r%^unable to convert%, err
63+
assert_include err, 'unable to convert'
6464
end
6565

6666
def test_class_read_file_encoding_fancy
@@ -101,7 +101,7 @@ def test_class_read_file_encoding_invalid
101101
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
102102
end
103103

104-
assert_equal "unable to convert \"\\xE4\" on US-ASCII for #{@tempfile.path}, skipping\n", err
104+
assert_include err, "unable to convert \"\\xE4\" on US-ASCII for #{@tempfile.path}, skipping\n"
105105

106106
assert_nil contents
107107
end

test/rdoc/rdoc_options_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_check_files_warn
4747
end
4848

4949
assert_empty out
50-
assert_equal "file 'nonexistent' not found\n", err
50+
assert_include err, "file 'nonexistent' not found\n"
5151
assert_empty @options.files
5252
end
5353

@@ -828,7 +828,7 @@ def test_warn
828828
end
829829

830830
assert_empty out
831-
assert_equal "warnings on\n", err
831+
assert_include err, "warnings on\n"
832832
end
833833

834834
def test_write_options

test/rdoc/rdoc_parser_c_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ def test_do_aliases_missing_class
289289
refute util_get_class(content, 'cDate')
290290
end
291291

292-
assert_equal "Enclosing class or module \"cDate\" for alias b a is not known\n",
293-
err
292+
assert_include err, "Enclosing class or module \"cDate\" for alias b a is not known\n"
294293
end
295294

296295
def test_do_classes_class
@@ -827,7 +826,7 @@ def test_do_missing_cycle
827826
expected = 'Unable to create class Y (y), class Z (z) ' +
828827
'due to a cyclic class or module creation'
829828

830-
assert_equal expected, err.chomp
829+
assert_include err, expected
831830

832831
assert_equal %w[A A::B A::B::C],
833832
@store.all_classes_and_modules.map { |m| m.full_name }.sort

test/rdoc/rdoc_rdoc_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def test_normalized_file_list_non_file_directory
146146
assert_empty files
147147

148148
assert_empty out
149-
assert_match %r"^rdoc can't parse", err
150-
assert_match %r"#{dev}$", err
149+
assert_include err, "rdoc can't parse"
150+
assert_match %r"#{dev}$", err
151151
end
152152

153153
def test_normalized_file_list_with_dot_doc

test/rdoc/rdoc_task_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ def test_inline_source
2424
assert @t.inline_source
2525
end
2626

27-
assert_equal "RDoc::Task#inline_source is deprecated\n", err
27+
assert_include err, "RDoc::Task#inline_source is deprecated\n"
2828

2929
_, err = verbose_capture_output do
3030
@t.inline_source = false
3131
end
3232

33-
assert_equal "RDoc::Task#inline_source is deprecated\n", err
33+
assert_include err, "RDoc::Task#inline_source is deprecated\n"
3434

3535
capture_output do
3636
assert @t.inline_source

test/rdoc/rdoc_text_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def test_to_html_tt_tag_mismatch
571571
assert_equal '<tt>hi', to_html('<tt>hi')
572572
end
573573

574-
assert_equal "mismatched <tt> tag\n", err
574+
assert_include err, "mismatched <tt> tag\n"
575575
end
576576

577577
def formatter

0 commit comments

Comments
 (0)