Skip to content

fix: Use Minitest must_raise correctly and handle error message#92

Open
mtasaka wants to merge 1 commit intocopiousfreetime:mainfrom
mtasaka:fix-assert_raises-usage
Open

fix: Use Minitest must_raise correctly and handle error message#92
mtasaka wants to merge 1 commit intocopiousfreetime:mainfrom
mtasaka:fix-assert_raises-usage

Conversation

@mtasaka
Copy link
Copy Markdown

@mtasaka mtasaka commented Apr 22, 2026

must_raise is sort of the alias for assert_raises, and actually https://github.com/minitest/minitest/blob/v6.0.5/lib/minitest/assertions.rb#L390 says that assert_raises can take an optional "message" (i.e. string) to help explain failures, so not regex or so to test if assertion message matches it.

Up to Minitest 6.0.4, when passing regex for assert_raises it was simply ignored, ref:

minitest/minitest#1068
https://bugs.ruby-lang.org/issues/22007

Now Minitest 6.0.5 explicitly refuses this usage as: minitest/minitest@6790f86 and now must_raise also refuses this usage.

Closes #91 .

`must_raise` is sort of the alias for `assert_raises`, and actually
https://github.com/minitest/minitest/blob/v6.0.5/lib/minitest/assertions.rb#L390
says that `assert_raises` can take an optional "message" (i.e. string) to help
explain failures, so not regex or so to test if assertion message matches it.

Up to Minitest 6.0.4, when passing regex for `assert_raises` it was simply
ignored, ref:

minitest/minitest#1068
https://bugs.ruby-lang.org/issues/22007

Now Minitest 6.0.5 explicitly refuses this usage as:
minitest/minitest@6790f86
and now `must_raise` also refuses this usage.

Closes copiousfreetime#91 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rake test failure with Minitest 6.0.5

1 participant