diff --git a/activerecord/test/cases/secure_password_test.rb b/activerecord/test/cases/secure_password_test.rb index 39ce38c1393..b56998166f7 100644 --- a/activerecord/test/cases/secure_password_test.rb +++ b/activerecord/test/cases/secure_password_test.rb @@ -68,11 +68,11 @@ class SecurePasswordTest < ActiveRecord::TestCase test "authenticate_by accepts any object that implements to_h" do params = Enumerator.new { raise "must access via to_h" } - assert_called_with(params, :to_h, [[]], returns: { token: @user.token, password: @user.password }) do + assert_called_with(params, :to_h, [], returns: { token: @user.token, password: @user.password }) do assert_equal @user, User.authenticate_by(params) end - assert_called_with(params, :to_h, [[]], returns: { token: "wrong", password: @user.password }) do + assert_called_with(params, :to_h, [], returns: { token: "wrong", password: @user.password }) do assert_nil User.authenticate_by(params) end end diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb index 1d016b096a8..ac584ff5353 100644 --- a/activesupport/lib/active_support/testing/method_call_assertions.rb +++ b/activesupport/lib/active_support/testing/method_call_assertions.rb @@ -20,8 +20,8 @@ module ActiveSupport 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) } + if !args.empty? && args.all?(Array) + args.each { |argv| mock.expect(:call, returns, argv) } else mock.expect(:call, returns, args) end