Merge branch 'gem'
[fuzed.git] / helloworld / vendor / gems / chronic-0.2.2 / test / test_RepeaterFortnight.rb
blobcb80c43cfee49d77d08c8946364a51fc5647059b
1 require 'chronic'
2 require 'test/unit'
4 class TestRepeaterFortnight < Test::Unit::TestCase
5   
6   def setup
7     @now = Time.local(2006, 8, 16, 14, 0, 0, 0)
8   end
10   def test_next_future
11     fortnights = Chronic::RepeaterFortnight.new(:fortnight)
12     fortnights.start = @now
13     
14     next_fortnight = fortnights.next(:future)
15     assert_equal Time.local(2006, 8, 20), next_fortnight.begin
16     assert_equal Time.local(2006, 9, 3), next_fortnight.end
17     
18     next_next_fortnight = fortnights.next(:future)
19     assert_equal Time.local(2006, 9, 3), next_next_fortnight.begin
20     assert_equal Time.local(2006, 9, 17), next_next_fortnight.end
21   end
22   
23   def test_next_past
24     fortnights = Chronic::RepeaterFortnight.new(:fortnight)
25     fortnights.start = @now
26     
27     last_fortnight = fortnights.next(:past)
28     assert_equal Time.local(2006, 7, 30), last_fortnight.begin
29     assert_equal Time.local(2006, 8, 13), last_fortnight.end
30     
31     last_last_fortnight = fortnights.next(:past)
32     assert_equal Time.local(2006, 7, 16), last_last_fortnight.begin
33     assert_equal Time.local(2006, 7, 30), last_last_fortnight.end
34   end
35   
36   def test_this_future
37     fortnights = Chronic::RepeaterFortnight.new(:fortnight)
38     fortnights.start = @now
39     
40     this_fortnight = fortnights.this(:future)
41     assert_equal Time.local(2006, 8, 16, 15), this_fortnight.begin
42     assert_equal Time.local(2006, 8, 27), this_fortnight.end
43   end
44   
45   def test_this_past
46     fortnights = Chronic::RepeaterFortnight.new(:fortnight)
47     fortnights.start = @now
48     
49     this_fortnight = fortnights.this(:past)
50     assert_equal Time.local(2006, 8, 13, 0), this_fortnight.begin
51     assert_equal Time.local(2006, 8, 16, 14), this_fortnight.end
52   end
53   
54   def test_offset
55     span = Chronic::Span.new(@now, @now + 1)
56     
57     offset_span = Chronic::RepeaterWeek.new(:week).offset(span, 3, :future)
58     
59     assert_equal Time.local(2006, 9, 6, 14), offset_span.begin
60     assert_equal Time.local(2006, 9, 6, 14, 0, 1), offset_span.end
61   end
62   
63 end