From 0aeb11e5751c5c998f4d52b0084754d848e2865e Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Mon, 7 Oct 2013 10:24:14 +0200 Subject: 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) --- activerecord/test/cases/relation/delegation_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activerecord/test') 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 -- cgit v1.2.3