@@ -36,7 +36,17 @@ def test_serializable_hash
36
36
# Typically, it is implemented by including ActiveModel::Serialization.
37
37
def test_read_attribute_for_serialization
38
38
assert_respond_to resource , :read_attribute_for_serialization , "The resource should respond to read_attribute_for_serialization"
39
- assert_equal resource . method ( :read_attribute_for_serialization ) . arity , 1
39
+ actual_arity = resource . method ( :read_attribute_for_serialization ) . arity
40
+ if defined? ( ::Rubinius )
41
+ # 1 for def read_attribute_for_serialization(name); end
42
+ # -2 for alias :read_attribute_for_serialization :send for rbx because :shrug:
43
+ assert_includes [ 1 , -2 ] , actual_arity , "expected #{ actual_arity . inspect } to be 1 or -2"
44
+ else
45
+ # using absolute value since arity is:
46
+ # 1 for def read_attribute_for_serialization(name); end
47
+ # -1 for alias :read_attribute_for_serialization :send
48
+ assert_includes [ 1 , -1 ] , actual_arity , "expected #{ actual_arity . inspect } to be 1 or -1"
49
+ end
40
50
end
41
51
42
52
# Passes if the object responds to <tt>as_json</tt> and if it takes
@@ -68,15 +78,19 @@ def test_to_json
68
78
end
69
79
70
80
# Passes if the object responds to <tt>cache_key</tt> and if it takes no
71
- # arguments.
81
+ # arguments (Rails 4.0) or a splat (Rails 4.1+) .
72
82
# Fails otherwise.
73
83
#
74
84
# <tt>cache_key</tt> returns a (self-expiring) unique key for the object,
75
85
# which is used by the adapter.
76
86
# It is not required unless caching is enabled.
77
87
def test_cache_key
78
88
assert_respond_to resource , :cache_key
79
- assert_equal resource . method ( :cache_key ) . arity , 0
89
+ actual_arity = resource . method ( :cache_key ) . arity
90
+ # using absolute value since arity is:
91
+ # 0 for Rails 4.1+, *timestamp_names
92
+ # -1 for Rails 4.0, no arguments
93
+ assert_includes [ -1 , 0 ] , actual_arity , "expected #{ actual_arity . inspect } to be 0 or -1"
80
94
end
81
95
82
96
# Passes if the object responds to <tt>id</tt> and if it takes no
0 commit comments