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

Allow methods arity below -1 in assert_responds.

Every method from MRI's core classes is written in C. This means
Method#arity always returns -1 for methods with a variable number of
arguments. This is not the case with Rubinius, where, for example
Array#slice! is implemented in Ruby and has arity -2, since is
defined as def slice!(start, length = undefined)
This commit is contained in:
Federico Ravasio 2013-10-07 10:24:14 +02:00
parent d8537ef1ec
commit 0aeb11e575

View file

@ -9,10 +9,11 @@ module ActiveRecord
def assert_responds(target, method)
assert target.respond_to?(method)
assert_nothing_raised do
case target.to_a.method(method).arity
when 0
method_arity = target.to_a.method(method).arity
if method_arity.zero?
target.send(method)
when -1
elsif method_arity < 0
if method == :shuffle!
target.send(method)
else