Merge branch 'gem'
[fuzed.git] / helloworld / vendor / gems / chronic-0.2.2 / test / test_RepeaterMonth.rb
blobd0609c5f07d16db0fec58ac098bf8c8c38a1a3fb
1 require 'chronic'
2 require 'test/unit'
4 class TestRepeaterMonth < Test::Unit::TestCase
5   
6   def setup
7     # Wed Aug 16 14:00:00 2006
8     @now = Time.local(2006, 8, 16, 14, 0, 0, 0)
9   end
10   
11   def test_offset_by
12     # future
13     
14     time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :future)
15     assert_equal Time.local(2006, 9, 16, 14), time
16     
17     time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 5, :future)
18     assert_equal Time.local(2007, 1, 16, 14), time
19     
20     # past
21     
22     time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :past)
23     assert_equal Time.local(2006, 7, 16, 14), time
24     
25     time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 10, :past)
26     assert_equal Time.local(2005, 10, 16, 14), time
27   end
28   
29   def test_offset
30     # future
31     
32     span = Chronic::Span.new(@now, @now + 60)
33     offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :future)
34     
35     assert_equal Time.local(2006, 9, 16, 14), offset_span.begin
36     assert_equal Time.local(2006, 9, 16, 14, 1), offset_span.end
37     
38    # past
39    
40    span = Chronic::Span.new(@now, @now + 60)
41    offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :past)
42    
43    assert_equal Time.local(2006, 7, 16, 14), offset_span.begin
44    assert_equal Time.local(2006, 7, 16, 14, 1), offset_span.end
45   end
46   
47 end