minitest.diff
| lib/minitest/unit.rb (working copy) | ||
|---|---|---|
| 116 | 116 |
end |
| 117 | 117 | |
| 118 | 118 |
def assert_match exp, act, msg = nil |
| 119 |
msg = message(msg) { "Expected #{mu_pp(act)} to match #{mu_pp(exp)}" }
|
|
| 120 |
assert_respond_to act, :"=~" |
|
| 121 |
(exp = /#{Regexp.escape(exp)}/) if String === exp && String === act
|
|
| 122 |
assert act =~ exp, msg |
|
| 119 |
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
|
|
| 120 |
assert Regexp.new(exp) === act, msg |
|
| 123 | 121 |
end |
| 124 | 122 | |
| 125 | 123 |
def assert_nil obj, msg = nil |
| ... | ... | |
| 280 | 278 |
end |
| 281 | 279 | |
| 282 | 280 |
def refute_match exp, act, msg = nil |
| 283 |
msg = message(msg) { "Expected #{mu_pp(act)} to not match #{mu_pp(exp)}" }
|
|
| 284 |
refute act =~ exp, msg
|
|
| 281 |
msg = message(msg) { "Expected #{mu_pp(exp)} to not match #{mu_pp(act)}" }
|
|
| 282 |
refute Regexp.new(exp) === act, msg
|
|
| 285 | 283 |
end |
| 286 | 284 | |
| 287 | 285 |
def refute_nil obj, msg = nil |
| test/minitest/test_mini_test.rb (working copy) | ||
|---|---|---|
| 464 | 464 |
end |
| 465 | 465 | |
| 466 | 466 |
def test_assert_match |
| 467 |
@assertion_count = 2
|
|
| 468 |
@tc.assert_match "blah blah blah", /\w+/
|
|
| 467 |
@assertion_count = 1
|
|
| 468 |
@tc.assert_match /\w+/, "blah blah blah"
|
|
| 469 | 469 |
end |
| 470 | 470 | |
| 471 | 471 |
def test_assert_match_triggered |
| 472 |
@assertion_count = 2
|
|
| 472 |
@assertion_count = 1
|
|
| 473 | 473 |
util_assert_triggered 'Expected /\d+/ to match "blah blah blah".' do |
| 474 |
@tc.assert_match "blah blah blah", /\d+/
|
|
| 474 |
@tc.assert_match /\d+/, "blah blah blah"
|
|
| 475 | 475 |
end |
| 476 | 476 |
end |
| 477 | 477 | |
| ... | ... | |
| 795 | 795 |
end |
| 796 | 796 | |
| 797 | 797 |
def test_refute_match |
| 798 |
@tc.refute_match "blah blah blah", /\d+/
|
|
| 798 |
@tc.refute_match /\d+/, "blah blah blah"
|
|
| 799 | 799 |
end |
| 800 | 800 | |
| 801 | 801 |
def test_refute_match_triggered |
| 802 | 802 |
util_assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do |
| 803 |
@tc.refute_match "blah blah blah", /\w+/
|
|
| 803 |
@tc.refute_match /\w+/, "blah blah blah"
|
|
| 804 | 804 |
end |
| 805 | 805 |
end |
| 806 | 806 | |