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:
parent
d8537ef1ec
commit
0aeb11e575
1 changed files with 4 additions and 3 deletions
|
@ -9,10 +9,11 @@ module ActiveRecord
|
||||||
def assert_responds(target, method)
|
def assert_responds(target, method)
|
||||||
assert target.respond_to?(method)
|
assert target.respond_to?(method)
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
case target.to_a.method(method).arity
|
method_arity = target.to_a.method(method).arity
|
||||||
when 0
|
|
||||||
|
if method_arity.zero?
|
||||||
target.send(method)
|
target.send(method)
|
||||||
when -1
|
elsif method_arity < 0
|
||||||
if method == :shuffle!
|
if method == :shuffle!
|
||||||
target.send(method)
|
target.send(method)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue