From eb73d7dafa343507a60f765c43c748d6987ec652 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 17 Aug 2014 16:31:00 +0200 Subject: Define the Duration#instance_of? method Since Duration is extending from ProxyObject which extends itself from BasicObject, the Duration object doesn't respond to the #instance_of? method. Thus, the #method_missing hook get triggered, delegating the method to its `value` attribute. However, Rubinius' #eql? definition relies on #instance_of?, thus this will equal to true with a Fixnum (since its `value` attribute is a Fixnum) while it should not. The previous behavior was wrong anyway, no matter the implementation. --- activesupport/test/core_ext/duration_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 31af3c4521..330d995b7c 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -41,6 +41,11 @@ class DurationTest < ActiveSupport::TestCase assert !1.eql?(1.second) end + def test_instance_of + assert !1.minute.instance_of?(Fixnum) + assert !2.days.instance_of?(Fixnum) + end + def test_inspect assert_equal '0 seconds', 0.seconds.inspect assert_equal '1 month', 1.month.inspect -- cgit v1.2.3