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
|
require 'helper'
class TestRepeaterSeason < Test::Unit::TestCase
def setup
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
end
def test_next_future
seasons = Chronic::RepeaterSeason.new(:season)
seasons.start = @now
next_season = seasons.next(:future)
assert_equal Time.local(2006, 9, 23), next_season.begin
assert_equal Time.local(2006, 12, 21), next_season.end
end
def test_next_past
seasons = Chronic::RepeaterSeason.new(:season)
seasons.start = @now
last_season = seasons.next(:past)
assert_equal Time.local(2006, 3, 20), last_season.begin
assert_equal Time.local(2006, 6, 20), last_season.end
end
def test_this
seasons = Chronic::RepeaterSeason.new(:season)
seasons.start = @now
this_season = seasons.this(:future)
assert_equal Time.local(2006, 8, 17), this_season.begin
assert_equal Time.local(2006, 9, 22), this_season.end
this_season = seasons.this(:past)
assert_equal Time.local(2006, 6, 21), this_season.begin
assert_equal Time.local(2006, 8, 16), this_season.end
end
end
|