You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.8 KiB
40 lines
1.8 KiB
From df0de681dc1873534ecd2fc8371e1f2562984b68 Mon Sep 17 00:00:00 2001
|
|
From: John Crepezzi <john.crepezzi@gmail.com>
|
|
Date: Thu, 16 Jun 2022 08:34:05 -0400
|
|
Subject: [PATCH] Remove the multi-call form of assert_called_with
|
|
|
|
The `assert_called_with` helper allows passing a multi-dimensional array to
|
|
mock multiple calls to the same method for a given block. This works
|
|
fine now, but when adding support for real kwargs arguments to line up with
|
|
recent upgrades in Minitest, this approach is no longer workable because
|
|
we can't pass multiple sets of differing kwargs.
|
|
|
|
Rather than complicated this method further, this commit removes the
|
|
multi-call form of `assert_called_with` and modifies the tests that
|
|
currently make use of that functionality to just use the underlying
|
|
`Minitest::Mock` calls.
|
|
|
|
Co-authored-by: Eileen M. Uchitelle <eileencodes@gmail.com>
|
|
---
|
|
.../testing/method_call_assertions.rb | 7 +-
|
|
1 file changed, 1 insertion(+), 6 deletions(-)
|
|
|
|
diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb
|
|
index c8d2dbaa52ab5..72451faaa8cc4 100644
|
|
--- a/activesupport/lib/active_support/testing/method_call_assertions.rb
|
|
+++ b/activesupport/lib/active_support/testing/method_call_assertions.rb
|
|
@@ -19,12 +19,7 @@ def assert_called(object, method_name, message = nil, times: 1, returns: nil, &b
|
|
|
|
def assert_called_with(object, method_name, args, returns: nil, &block)
|
|
mock = Minitest::Mock.new
|
|
-
|
|
- if args.all?(Array)
|
|
- args.each { |arg| mock.expect(:call, returns, arg) }
|
|
- else
|
|
- mock.expect(:call, returns, args)
|
|
- end
|
|
+ mock.expect(:call, returns, args)
|
|
|
|
object.stub(method_name, mock, &block)
|
|
|