seattlerb/minitest — pull request #117 by bensomers (2012-04-12 00:33:17+00:00)
Title: Make assert_match behave consistently with test-unit version

Currently, minitest's assert_match uses the #=~ method of the pattern, passing the object. This is inconsistent with test-unit (which does it the other way around), and also inconvenient when working with objects that have unusual implementations for #=~.

Notably, Mail::Body objects in mikel lindsaar's mail gem (https://github.com/mikel/mail/blob/master/lib/mail/body.rb, line 84) have an interesting #=~; the Mail::Body decodes itself before attempting to match. This has the convenient side effect of enabling the user to run assert_match against email bodies directly, without decoding them first.

The current implementation is limited to relying on Regexp#=~, so tricks like the one mikel pulled to make the user's life easier aren't possible. I also think there's value in not changing the behavior from test-unit's, for users upgrading from 1.8 to 1.9 and switching from test-unit to minitest.