From c51db4d7ababd6f1c341d2808a298865ee449313 Mon Sep 17 00:00:00 2001 From: gbuesing Date: Mon, 13 Oct 2008 20:18:56 -0500 Subject: Enhance testing for fractional days and weeks. Update changelog. --- activesupport/test/core_ext/duration_test.rb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'activesupport/test/core_ext/duration_test.rb') diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index d1b15fd2ef..80cc6d25d3 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -30,21 +30,17 @@ class DurationTest < Test::Unit::TestCase end end - uses_mocha 'TestDurationSinceAndAgoWithCurrentTime' do - def test_fractional_weeks - Time.stubs(:now).returns Time.local(2000) - - assert_in_delta((24 * 7 * 1.5).hours, 1.5.weeks, 2 ** -20) - assert_in_delta((24 * 7 * 1.7).hours, 1.7.weeks, 2 ** -20) - end - - def test_fractional_days - Time.stubs(:now).returns Time.local(2000) + def test_fractional_weeks + assert_equal (86400 * 7) * 1.5, 1.5.weeks + assert_equal (86400 * 7) * 1.7, 1.7.weeks + end - assert_in_delta((24 * 1.5).hours, 1.5.days, 2 ** -20) - assert_in_delta((24 * 1.7).hours, 1.7.days, 2 ** -20) - end + def test_fractional_days + assert_equal 86400 * 1.5, 1.5.days + assert_equal 86400 * 1.7, 1.7.days + end + uses_mocha 'TestDurationSinceAndAgoWithCurrentTime' do def test_since_and_ago_with_fractional_days Time.stubs(:now).returns Time.local(2000) # since -- cgit v1.2.3