0
@@ -563,16 +563,71 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
0
assert_nothing_raised { Time.now.xmlschema }
0
- uses_mocha 'past?, today? and future?' do
0
- def test_past_today_future
0
- Date.stubs(:current).returns(Date.civil(2000, 1, 1))
0
- Time.stubs(:current).returns(Time.local(2000, 1, 1, 1, 0, 1))
0
- t1, t2 = Time.local(2000, 1, 1, 1, 0, 0), Time.local(2000, 1, 1, 1, 0, 2)
0
+ uses_mocha 'Test Time past?, today? and future?' do
0
+ def test_today_with_time_local
0
+ Date.stubs(:current).returns(Date.new(2000, 1, 1))
0
+ assert_equal false, Time.local(1999,12,31,23,59,59).today?
0
+ assert_equal true, Time.local(2000,1,1,0).today?
0
+ assert_equal true, Time.local(2000,1,1,23,59,59).today?
0
+ assert_equal false, Time.local(2000,1,2,0).today?
0
+ def test_today_with_time_utc
0
+ Date.stubs(:current).returns(Date.new(2000, 1, 1))
0
+ assert_equal false, Time.utc(1999,12,31,23,59,59).today?
0
+ assert_equal true, Time.utc(2000,1,1,0).today?
0
+ assert_equal true, Time.utc(2000,1,1,23,59,59).today?
0
+ assert_equal false, Time.utc(2000,1,2,0).today?
0
+ def test_past_with_time_current_as_time_local
0
+ with_env_tz 'US/Eastern' do
0
+ Time.stubs(:current).returns(Time.local(2005,2,10,15,30,45))
0
+ assert_equal true, Time.local(2005,2,10,15,30,44).past?
0
+ assert_equal false, Time.local(2005,2,10,15,30,45).past?
0
+ assert_equal false, Time.local(2005,2,10,15,30,46).past?
0
+ assert_equal true, Time.utc(2005,2,10,20,30,44).past?
0
+ assert_equal false, Time.utc(2005,2,10,20,30,45).past?
0
+ assert_equal false, Time.utc(2005,2,10,20,30,46).past?
0
+ def test_past_with_time_current_as_time_with_zone
0
+ with_env_tz 'US/Eastern' do
0
+ twz = Time.utc(2005,2,10,15,30,45).in_time_zone('Central Time (US & Canada)')
0
+ Time.stubs(:current).returns(twz)
0
+ assert_equal true, Time.local(2005,2,10,10,30,44).past?
0
+ assert_equal false, Time.local(2005,2,10,10,30,45).past?
0
+ assert_equal false, Time.local(2005,2,10,10,30,46).past?
0
+ assert_equal true, Time.utc(2005,2,10,15,30,44).past?
0
+ assert_equal false, Time.utc(2005,2,10,15,30,45).past?
0
+ assert_equal false, Time.utc(2005,2,10,15,30,46).past?
0
+ def test_future_with_time_current_as_time_local
0
+ with_env_tz 'US/Eastern' do
0
+ Time.stubs(:current).returns(Time.local(2005,2,10,15,30,45))
0
+ assert_equal false, Time.local(2005,2,10,15,30,44).future?
0
+ assert_equal false, Time.local(2005,2,10,15,30,45).future?
0
+ assert_equal true, Time.local(2005,2,10,15,30,46).future?
0
+ assert_equal false, Time.utc(2005,2,10,20,30,44).future?
0
+ assert_equal false, Time.utc(2005,2,10,20,30,45).future?
0
+ assert_equal true, Time.utc(2005,2,10,20,30,46).future?
0
+ def test_future_with_time_current_as_time_with_zone
0
+ with_env_tz 'US/Eastern' do
0
+ twz = Time.utc(2005,2,10,15,30,45).in_time_zone('Central Time (US & Canada)')
0
+ Time.stubs(:current).returns(twz)
0
+ assert_equal false, Time.local(2005,2,10,10,30,44).future?
0
+ assert_equal false, Time.local(2005,2,10,10,30,45).future?
0
+ assert_equal true, Time.local(2005,2,10,10,30,46).future?
0
+ assert_equal false, Time.utc(2005,2,10,15,30,44).future?
0
+ assert_equal false, Time.utc(2005,2,10,15,30,45).future?
0
+ assert_equal true, Time.utc(2005,2,10,15,30,46).future?