diff options
author | Federico Ravasio <ravasio.federico@gmail.com> | 2013-10-07 10:24:14 +0200 |
---|---|---|
committer | Federico Ravasio <ravasio.federico@gmail.com> | 2013-10-08 00:15:11 +0200 |
commit | 0aeb11e5751c5c998f4d52b0084754d848e2865e (patch) | |
tree | 27bb4393dfdd2ffefff6795897b35ea3ad2d32ed /activerecord/test | |
parent | d8537ef1ec1ba51eb08087b4c929474f267bdf10 (diff) | |
download | rails-0aeb11e5751c5c998f4d52b0084754d848e2865e.tar.gz rails-0aeb11e5751c5c998f4d52b0084754d848e2865e.tar.bz2 rails-0aeb11e5751c5c998f4d52b0084754d848e2865e.zip |
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)
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index 71ade0bcc2..c171c5e14e 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -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 |