提交 f7e625b2 编写于 作者: K Kasper Timm Hansen

Merge pull request #21244 from ronakjangir47/method_call_assertions_fix

Replacing lambda with proc getting argument error because of it.
...@@ -5,7 +5,7 @@ module MethodCallAssertions # :nodoc: ...@@ -5,7 +5,7 @@ module MethodCallAssertions # :nodoc:
def assert_called(object, method_name, message = nil, times: 1) def assert_called(object, method_name, message = nil, times: 1)
times_called = 0 times_called = 0
object.stub(method_name, -> { times_called += 1 }) { yield } object.stub(method_name, proc { times_called += 1 }) { yield }
error = "Expected #{method_name} to be called #{times} times, " \ error = "Expected #{method_name} to be called #{times} times, " \
"but was called #{times_called} times" "but was called #{times_called} times"
......
...@@ -27,6 +27,12 @@ def test_assert_called_more_than_once ...@@ -27,6 +27,12 @@ def test_assert_called_more_than_once
end end
end end
def test_assert_called_method_with_arguments
assert_called(@object, :<<) do
@object << 2
end
end
def test_assert_called_failure def test_assert_called_failure
error = assert_raises(Minitest::Assertion) do error = assert_raises(Minitest::Assertion) do
assert_called(@object, :increment) do assert_called(@object, :increment) do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册