Bug #896 ยป minitest.diff
lib/minitest/unit.rb (working copy) | ||
---|---|---|
end
|
||
def assert_match exp, act, msg = nil
|
||
msg = message(msg) { "Expected #{mu_pp(act)} to match #{mu_pp(exp)}" }
|
||
assert_respond_to act, :"=~"
|
||
(exp = /#{Regexp.escape(exp)}/) if String === exp && String === act
|
||
assert act =~ exp, msg
|
||
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
|
||
assert Regexp.new(exp) === act, msg
|
||
end
|
||
def assert_nil obj, msg = nil
|
||
... | ... | |
end
|
||
def refute_match exp, act, msg = nil
|
||
msg = message(msg) { "Expected #{mu_pp(act)} to not match #{mu_pp(exp)}" }
|
||
refute act =~ exp, msg
|
||
msg = message(msg) { "Expected #{mu_pp(exp)} to not match #{mu_pp(act)}" }
|
||
refute Regexp.new(exp) === act, msg
|
||
end
|
||
def refute_nil obj, msg = nil
|
test/minitest/test_mini_test.rb (working copy) | ||
---|---|---|
end
|
||
def test_assert_match
|
||
@assertion_count = 2
|
||
@tc.assert_match "blah blah blah", /\w+/
|
||
@assertion_count = 1
|
||
@tc.assert_match /\w+/, "blah blah blah"
|
||
end
|
||
def test_assert_match_triggered
|
||
@assertion_count = 2
|
||
@assertion_count = 1
|
||
util_assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
|
||
@tc.assert_match "blah blah blah", /\d+/
|
||
@tc.assert_match /\d+/, "blah blah blah"
|
||
end
|
||
end
|
||
... | ... | |
end
|
||
def test_refute_match
|
||
@tc.refute_match "blah blah blah", /\d+/
|
||
@tc.refute_match /\d+/, "blah blah blah"
|
||
end
|
||
def test_refute_match_triggered
|
||
util_assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
|
||
@tc.refute_match "blah blah blah", /\w+/
|
||
@tc.refute_match /\w+/, "blah blah blah"
|
||
end
|
||
end
|
||