Make assert_match behave consistently with test-unit version #117

Closed
wants to merge 1 commit into
from
@@ -275,8 +275,8 @@ def assert_kind_of cls, obj, msg = nil # TODO: merge with instance_of
def assert_match exp, act, msg = nil
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
assert_respond_to act, :"=~"
- exp = Regexp.new Regexp.escape exp if String === exp and String === act
- assert exp =~ act, msg
+ exp = Regexp.new(Regexp.escape(exp)) if String === exp
+ assert act =~ exp, msg
end
##
@@ -927,13 +927,13 @@ def test_assert_match
@tc.assert_match(/\w+/, "blah blah blah")
end
- def test_assert_match_object
+ def test_assert_match_unusual_object
@assertion_count = 2
- pattern = Object.new
- def pattern.=~(other) true end
+ unusual_object = Object.new
+ def unusual_object.=~(other) true end
- @tc.assert_match pattern, 5
+ @tc.assert_match /pattern/, unusual_object
end
def test_assert_match_object_triggered