aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-10 22:49:45 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-10 22:49:45 +0000
commit14ed815b1c0098f1f7132d0a5a7e22088849c30e (patch)
tree8361bf69b543bb47300d4beb875d80f5e5d97177 /activesupport/test
parentebf424061dba2454b3e1d746e2515b10e76a5be8 (diff)
downloadrails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.tar.gz
rails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.tar.bz2
rails-14ed815b1c0098f1f7132d0a5a7e22088849c30e.zip
Added Fixnum#ago/until, Fixnum#since/from_now #450 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@371 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/fixnum_ext_test.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/activesupport/test/core_ext/fixnum_ext_test.rb b/activesupport/test/core_ext/fixnum_ext_test.rb
index 4014ad07d0..12ef69596d 100644
--- a/activesupport/test/core_ext/fixnum_ext_test.rb
+++ b/activesupport/test/core_ext/fixnum_ext_test.rb
@@ -2,15 +2,22 @@ require 'test/unit'
require File.dirname(__FILE__) + '/../../lib/core_ext/fixnum_ext'
class FixnumExtTest < Test::Unit::TestCase
- def test_time_units
- expected = {
+ def setup
+ @now = Time.now
+ @seconds = {
1.minute => 60,
10.minutes => 600,
1.hour + 15.minutes => 4500,
2.days + 4.hours + 30.minutes => 189000,
5.years + 1.month + 1.fortnight => 161481600
}
+ end
- expected.each { |actual, expected| assert_equal expected, actual }
+ def test_time_units
+ @seconds.each do |actual, expected|
+ assert_equal expected, actual
+ assert_equal expected.since(@now), @now + actual
+ assert_equal expected.until(@now), @now - actual
+ end
end
-end \ No newline at end of file
+end