1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
require 'helper'
class TestRepeaterMonthName < Test::Unit::TestCase
def setup
# Wed Aug 16 14:00:00 2006
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
end
def test_next
# future
mays = Chronic::RepeaterMonthName.new(:may)
mays.start = @now
next_may = mays.next(:future)
assert_equal Time.local(2007, 5), next_may.begin
assert_equal Time.local(2007, 6), next_may.end
next_next_may = mays.next(:future)
assert_equal Time.local(2008, 5), next_next_may.begin
assert_equal Time.local(2008, 6), next_next_may.end
decembers = Chronic::RepeaterMonthName.new(:december)
decembers.start = @now
next_december = decembers.next(:future)
assert_equal Time.local(2006, 12), next_december.begin
assert_equal Time.local(2007, 1), next_december.end
# past
mays = Chronic::RepeaterMonthName.new(:may)
mays.start = @now
assert_equal Time.local(2006, 5), mays.next(:past).begin
assert_equal Time.local(2005, 5), mays.next(:past).begin
end
def test_this
octobers = Chronic::RepeaterMonthName.new(:october)
octobers.start = @now
this_october = octobers.this(:future)
assert_equal Time.local(2006, 10, 1), this_october.begin
assert_equal Time.local(2006, 11, 1), this_october.end
aprils = Chronic::RepeaterMonthName.new(:april)
aprils.start = @now
this_april = aprils.this(:past)
assert_equal Time.local(2006, 4, 1), this_april.begin
assert_equal Time.local(2006, 5, 1), this_april.end
end
end
|