Created
May 17, 2012 19:14
-
-
Save kiszal/2721046 to your computer and use it in GitHub Desktop.
issue #130
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/minitest/mock.rb b/lib/minitest/mock.rb | |
index 59c531e..876be20 100644 | |
--- a/lib/minitest/mock.rb | |
+++ b/lib/minitest/mock.rb | |
@@ -11,6 +11,7 @@ module MiniTest | |
class Mock | |
alias :__respond_to? :respond_to? | |
+ alias :__singleton_class :singleton_class | |
skip_methods = %w(object_id respond_to_missing? inspect === to_s) | |
@@ -45,6 +46,7 @@ module MiniTest | |
# @mock.verify # => raises MockExpectationError | |
def expect(name, retval, args=[]) | |
+ __singleton_class.send :undef_method, name if __respond_to?(name, true) | |
raise ArgumentError, "args must be an array" unless Array === args | |
@expected_calls[name] << { :retval => retval, :args => args } | |
self | |
diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb | |
index 234bc3f..7bb66f7 100644 | |
--- a/test/minitest/test_minitest_mock.rb | |
+++ b/test/minitest/test_minitest_mock.rb | |
@@ -55,6 +55,11 @@ class TestMiniTestMock < MiniTest::Unit::TestCase | |
assert_equal "mocked method :sum expects 2 arguments, got 0", e.message | |
end | |
+ def test_calling_method_call_on_mock | |
+ @mock = MiniTest::Mock.new.expect(:call, nil) | |
+ assert_nil @mock.call | |
+ end | |
+ | |
def test_return_mock_does_not_raise | |
retval = MiniTest::Mock.new | |
mock = MiniTest::Mock.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment