1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add multiple expected calls to assert_called_with.

This commit is contained in:
Kasper Timm Hansen 2015-07-10 23:24:47 +02:00
parent 3c5bd78ddb
commit 46b92c4d12
2 changed files with 13 additions and 1 deletions

View file

@ -15,7 +15,12 @@ module ActiveSupport
def assert_called_with(object, method_name, args = [], returns: nil)
mock = Minitest::Mock.new
mock.expect(:call, returns, args)
if args.all? { |arg| arg.is_a?(Array) }
args.each { |arg| mock.expect(:call, returns, arg) }
else
mock.expect(:call, returns, args)
end
object.stub(method_name, mock) { yield }

View file

@ -73,6 +73,13 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase
end
end
def test_assert_called_with_multiple_expected_arguments
assert_called_with(@object, :<<, [ [ 1 ], [ 2 ] ]) do
@object << 1
@object << 2
end
end
def test_assert_not_called
assert_not_called(@object, :decrement) do
@object.increment