Skip to content

Commit

Permalink
Merge pull request #50581 from seanpdoyle/method-call-asserts-with-ru…
Browse files Browse the repository at this point in the history
…by-2-7

Remove `MethodCallAssertions` Ruby 2.7 work-around
  • Loading branch information
rafaelfranca committed Jan 4, 2024
2 parents a73cbbe + 7abaeea commit 13265de
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions activesupport/lib/active_support/testing/method_call_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,8 @@ def assert_not_called(object, method_name, message = nil, &block)
assert_called(object, method_name, message, times: 0, &block)
end

#--
# This method is a temporary wrapper for mock.expect as part of
# the Minitest 5.16 / Ruby 3.0 kwargs transition. It can go away
# when we drop support for Ruby 2.7.
if Minitest::Mock.instance_method(:expect).parameters.map(&:first).include?(:keyrest)
def expect_called_with(mock, args, returns: false, **kwargs)
mock.expect(:call, returns, args, **kwargs)
end
else
def expect_called_with(mock, args, returns: false, **kwargs)
if !kwargs.empty?
mock.expect(:call, returns, [*args, kwargs])
else
mock.expect(:call, returns, args)
end
end
def expect_called_with(mock, args, returns: false, **kwargs)
mock.expect(:call, returns, args, **kwargs)
end

def assert_called_on_instance_of(klass, method_name, message = nil, times: 1, returns: nil)
Expand Down

0 comments on commit 13265de

Please sign in to comment.