summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 17:49:53 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 17:49:53 +0000
commit49331ddec794834987ec5e7c4aa51264345a8ca0 (patch)
tree7461bd28dd0b520e485e6e4806eca099dd676ccc
parent40f1939614fe43244486fb9086e68dbf2135a506 (diff)
* lib/minitest/unit.rb (assert_match): refix of r35563.
r35563 breaks the intention of the original change. https://github.com/seattlerb/minitest/commit/68858105b2eb11c85105ffac5f32b662c59397f3 * lib/minitest/unit.rb (refute_match): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/minitest/unit.rb4
-rw-r--r--test/minitest/test_minitest_unit.rb9
3 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 38e0c1cc4a8..1ebba7ae97f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue May 8 02:34:26 2012 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * lib/minitest/unit.rb (assert_match): refix of r35563.
+ r35563 breaks the intention of the original change.
+ https://github.com/seattlerb/minitest/commit/68858105b2eb11c85105ffac5f32b662c59397f3
+ * lib/minitest/unit.rb (refute_match): ditto.
+
Mon May 7 21:19:17 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: Merge JSON 1.7.1.
diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb
index 707ec5e055b..9d9439c552e 100644
--- a/lib/minitest/unit.rb
+++ b/lib/minitest/unit.rb
@@ -282,7 +282,7 @@ module MiniTest
def assert_match matcher, obj, msg = nil
msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
assert_respond_to obj, :"=~"
- matcher = Regexp.new Regexp.escape matcher if String === matcher and String === obj
+ matcher = Regexp.new Regexp.escape matcher if String === matcher and obj.respond_to?(:to_str)
assert matcher =~ obj, msg
end
@@ -583,7 +583,7 @@ module MiniTest
def refute_match matcher, obj, msg = nil
msg = message(msg) {"Expected #{mu_pp matcher} to not match #{mu_pp obj}"}
assert_respond_to obj, :"=~"
- matcher = Regexp.new Regexp.escape matcher if String === matcher and String === obj
+ matcher = Regexp.new Regexp.escape matcher if String === matcher and obj.respond_to?(:to_str)
refute matcher =~ obj, msg
end
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb
index 1ef1ce3bee9..1707810a4f9 100644
--- a/test/minitest/test_minitest_unit.rb
+++ b/test/minitest/test_minitest_unit.rb
@@ -952,6 +952,15 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
@tc.assert_match "blah", obj
end
+ def test_assert_match_matchee_match
+ @assertion_count = 2
+
+ obj = Object.new
+ def obj.=~(o); true end
+
+ @tc.assert_match "blah", obj
+ end
+
def test_assert_match_object_triggered
@assertion_count = 2