+ assert_match now returns the MatchData on success. (Nakilon)

[git-p4: depot-paths = "//src/minitest/dev/": change = 13421]
This commit is contained in:
Ryan Davis 2022-06-05 14:26:31 -08:00
parent 8a131bfa29
commit ed224bc998
3 changed files with 7 additions and 2 deletions

View File

@ -293,6 +293,8 @@ module Minitest
assert_respond_to matcher, :"=~"
matcher = Regexp.new Regexp.escape matcher if String === matcher
assert matcher =~ obj, msg
Regexp.last_match
end
##

View File

@ -484,7 +484,10 @@ class TestMinitestAssertions < Minitest::Test
def test_assert_match
@assertion_count = 2
@tc.assert_match(/\w+/, "blah blah blah")
m = @tc.assert_match(/\w+/, "blah blah blah")
assert_kind_of MatchData, m
assert_equal "blah", m[0]
end
def test_assert_match_matchee_to_str

View File

@ -505,7 +505,7 @@ describe Minitest::Spec do
it "needs to verify regexp matches" do
@assertion_count += 3 # must_match is 2 assertions
assert_success _("blah").must_match(/\w+/)
assert_kind_of MatchData, _("blah").must_match(/\w+/)
assert_triggered "Expected /\\d+/ to match \"blah\"." do
_("blah").must_match(/\d+/)