Merge branch 'gem'
[fuzed.git] / helloworld / vendor / gems / chronic-0.2.2 / test / test_RepeaterDayName.rb
blob8e119db30469d16371159386dac89298f8e3dafb
1 require 'chronic'
2 require 'test/unit'
4 class TestRepeaterDayName < Test::Unit::TestCase
5   
6   def setup
7     @now = Time.local(2006, 8, 16, 14, 0, 0, 0)
8   end
9   
10   def test_match
11     token = Chronic::Token.new('saturday')
12     repeater = Chronic::Repeater.scan_for_day_names(token)
13     assert_equal Chronic::RepeaterDayName, repeater.class
14     assert_equal :saturday, repeater.type
15     
16     token = Chronic::Token.new('sunday')
17     repeater = Chronic::Repeater.scan_for_day_names(token)
18     assert_equal Chronic::RepeaterDayName, repeater.class
19     assert_equal :sunday, repeater.type
20   end
22   def test_next_future
23     mondays = Chronic::RepeaterDayName.new(:monday)
24     mondays.start = @now
25     
26     span = mondays.next(:future)
27     
28     assert_equal Time.local(2006, 8, 21), span.begin
29     assert_equal Time.local(2006, 8, 22), span.end 
31     span = mondays.next(:future)
32     
33     assert_equal Time.local(2006, 8, 28), span.begin
34     assert_equal Time.local(2006, 8, 29), span.end
35   end
36   
37   def test_next_past
38     mondays = Chronic::RepeaterDayName.new(:monday)
39     mondays.start = @now
40     
41     span = mondays.next(:past)
42     
43     assert_equal Time.local(2006, 8, 14), span.begin
44     assert_equal Time.local(2006, 8, 15), span.end 
46     span = mondays.next(:past)
47     
48     assert_equal Time.local(2006, 8, 7), span.begin
49     assert_equal Time.local(2006, 8, 8), span.end
50   end
51   
52 end