test/time_1_test.rb in rufus-scheduler-1.0.3 vs test/time_1_test.rb in rufus-scheduler-1.0.4

- old
+ new

@@ -34,25 +34,42 @@ tts 30 * 24 * 3600 + 1, "4w2d1s" end def test_1 - tts 30 * 24 * 3600 + 1, "1M1s", true + tts 30 * 24 * 3600 + 1, "1M1s", { :months => true } end def test_2 tts 0.120 + 30 * 24 * 3600 + 1, "4w2d1s120" tts 0.130, "130" + tts 61.127, "1m", { :drop_seconds => true } end + def test_3 + + tdh 0, {} + tdh 0.128, { :ms => 128 } + tdh 60.127, { :m => 1, :ms => 127 } + tdh 61.127, { :m => 1, :s => 1, :ms => 127 } + tdh 61.127, { :m => 1 }, { :drop_seconds => true } + end + protected - def tts (seconds, time_string, months=false) + def tts (seconds, time_string, options={}) assert_equal( time_string, - Rufus::to_time_string(seconds, months), + Rufus::to_time_string(seconds, options), "#{seconds} seconds did not map to '#{time_string}'") + end + + def tdh (seconds, time_hash, options={}) + + assert_equal( + time_hash, + Rufus::to_duration_hash(seconds, options)) end end