From cc45a1068f7920454d6d3a1cdabf844f17417908 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 19 May 2010 23:43:39 -0400 Subject: [PATCH] 1.day should respond_to kind_of too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4656 state:resolved] Signed-off-by: José Valim --- activesupport/lib/active_support/duration.rb | 1 + activesupport/test/core_ext/duration_test.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index db5afb5324dc3..cd0d66a4825e6 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -38,6 +38,7 @@ def -@ #:nodoc: def is_a?(klass) #:nodoc: Duration == klass || value.is_a?(klass) end + alias :kind_of? :is_a? # Returns true if other is also a Duration instance with the # same value, or if other == value. diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 05f529dc7dcc0..710c221fac296 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -5,6 +5,7 @@ class DurationTest < ActiveSupport::TestCase def test_is_a d = 1.day assert d.is_a?(ActiveSupport::Duration) + assert_kind_of ActiveSupport::Duration, d assert_kind_of Numeric, d assert_kind_of Fixnum, d assert !d.is_a?(Hash)