Permalink
Browse files

Added tests for RepeaterMinute

  • Loading branch information...
1 parent a9ad71d commit 180e44763ac36d9ee4cdc350f90900f1517a5b73 Brian Browning committed Nov 14, 2008
Showing with 35 additions and 0 deletions.
  1. +35 −0 test/test_RepeaterMinute.rb
@@ -0,0 +1,35 @@
+require 'chronic'
+require 'test/unit'
+
+class TestRepeaterMinute < Test::Unit::TestCase
+
+ def setup
+ @now = Time.local(2008, 6, 25, 7, 15, 30, 0)
+ end
+
+ def test_next_future
+ minutes = Chronic::RepeaterMinute.new(:minute)
+ minutes.start = @now
+
+ next_minute = minutes.next(:future)
+ assert_equal Time.local(2008, 6, 25, 7, 16), next_minute.begin
+ assert_equal Time.local(2008, 6, 25, 7, 17), next_minute.end
+
+ next_next_minute = minutes.next(:future)
+ assert_equal Time.local(2008, 6, 25, 7, 17), next_next_minute.begin
+ assert_equal Time.local(2008, 6, 25, 7, 18), next_next_minute.end
+ end
+
+ def test_next_past
+ minutes = Chronic::RepeaterMinute.new(:minute)
+ minutes.start = @now
+
+ prev_minute = minutes.next(:past)
+ assert_equal Time.local(2008, 6, 25, 7, 14), prev_minute.begin
+ assert_equal Time.local(2008, 6, 25, 7, 15), prev_minute.end
+
+ prev_prev_minute = minutes.next(:past)
+ assert_equal Time.local(2008, 6, 25, 7, 13), prev_prev_minute.begin
+ assert_equal Time.local(2008, 6, 25, 7, 14), prev_prev_minute.end
+ end
+end

0 comments on commit 180e447

Please sign in to comment.