49 lines
1.8 KiB
Diff
49 lines
1.8 KiB
Diff
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>
|
|
---
|
|
railties/test/generators/actions_test.rb | 14 ++--
|
|
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
|
|
index f62754fe0813e..6b5cdcf781922 100644
|
|
--- a/railties/test/generators/actions_test.rb
|
|
+++ b/railties/test/generators/actions_test.rb
|
|
@@ -734,11 +734,17 @@ def assert_runs(commands, config = {}, &block)
|
|
config_matcher = ->(actual_config) do
|
|
assert_equal config, actual_config.slice(*config.keys)
|
|
end if config
|
|
- args = Array(commands).map { |command| [command, *config_matcher] }
|
|
-
|
|
- assert_called_with(generator, :run, args) do
|
|
- block.call
|
|
- end
|
|
+
|
|
+ mock = Minitest::Mock.new
|
|
+
|
|
+ Array(commands).each do |command|
|
|
+ args = [command, *config_matcher]
|
|
+ mock.expect(:call, nil, args)
|
|
+ end
|
|
+
|
|
+ generator.stub(:run, mock, &block)
|
|
+
|
|
+ assert_mock(mock)
|
|
end
|
|
|
|
def assert_routes(*route_commands)
|