diff --git a/lib/active_model/serializer/lint.rb b/lib/active_model/serializer/lint.rb index 2941f55ad..bf3b7a371 100644 --- a/lib/active_model/serializer/lint.rb +++ b/lib/active_model/serializer/lint.rb @@ -78,7 +78,7 @@ def test_to_json end # Passes if the object responds to cache_key and if it takes no - # arguments. + # arguments (Rails 4.0) or a splat (Rails 4.1+). # Fails otherwise. # # cache_key returns a (self-expiring) unique key for the object, @@ -86,7 +86,11 @@ def test_to_json # It is not required unless caching is enabled. def test_cache_key assert_respond_to resource, :cache_key - assert_equal resource.method(:cache_key).arity, 0 + actual_arity = resource.method(:cache_key).arity + # using absolute value since arity is: + # 0 for Rails 4.1+, *timestamp_names + # -1 for Rails 4.0, no arguments + assert_includes [-1, 0], actual_arity, "expected #{actual_arity.inspect} to be 0 or -1" end # Passes if the object responds to id and if it takes no