diff options
author | Peter West <source@petewest.org> | 2014-11-03 16:34:44 +0000 |
---|---|---|
committer | Peter West <source@petewest.org> | 2014-11-03 16:34:44 +0000 |
commit | 2e085f67d4132ac8e01dae5a4428014f51fd4829 (patch) | |
tree | 01adc8610c4de645a0a2282088a4a473b46616ae /activesupport/test/core_ext | |
parent | af9702c015caba73fa99782360b123a1debe6d81 (diff) | |
download | rails-2e085f67d4132ac8e01dae5a4428014f51fd4829.tar.gz rails-2e085f67d4132ac8e01dae5a4428014f51fd4829.tar.bz2 rails-2e085f67d4132ac8e01dae5a4428014f51fd4829.zip |
Delegate comparison operator to value
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 5a2af7f943..5a7b624ae1 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -200,4 +200,16 @@ class DurationTest < ActiveSupport::TestCase def test_hash assert_equal 1.minute.hash, 60.seconds.hash end + + def test_comparable + assert_equal(-1, (0.seconds <=> 1.second)) + assert_equal(-1, (1.second <=> 1.minute)) + assert_equal(-1, (1 <=> 1.minute)) + assert_equal(0, (0.seconds <=> 0.seconds)) + assert_equal(0, (0.seconds <=> 0.minutes)) + assert_equal(0, (1.second <=> 1.second)) + assert_equal(1, (1.second <=> 0.second)) + assert_equal(1, (1.minute <=> 1.second)) + assert_equal(1, (61 <=> 1.minute)) + end end |