Sha256: 472fd7d3e9cfff3eec52163163421934b722f90385a07c1740bdeb4ff1379cfb
Contents?: true
Size: 1.86 KB
Versions: 28
Compression:
Stored size: 1.86 KB
Contents
require 'chronic' require 'test/unit' class TestRepeaterYear < Test::Unit::TestCase def setup @now = Time.local(2006, 8, 16, 14, 0, 0, 0) end def test_next_future years = Chronic::RepeaterYear.new(:year) years.start = @now next_year = years.next(:future) assert_equal Time.local(2007, 1, 1), next_year.begin assert_equal Time.local(2008, 1, 1), next_year.end next_next_year = years.next(:future) assert_equal Time.local(2008, 1, 1), next_next_year.begin assert_equal Time.local(2009, 1, 1), next_next_year.end end def test_next_past years = Chronic::RepeaterYear.new(:year) years.start = @now last_year = years.next(:past) assert_equal Time.local(2005, 1, 1), last_year.begin assert_equal Time.local(2006, 1, 1), last_year.end last_last_year = years.next(:past) assert_equal Time.local(2004, 1, 1), last_last_year.begin assert_equal Time.local(2005, 1, 1), last_last_year.end end def test_this years = Chronic::RepeaterYear.new(:year) years.start = @now this_year = years.this(:future) assert_equal Time.local(2006, 8, 17), this_year.begin assert_equal Time.local(2007, 1, 1), this_year.end this_year = years.this(:past) assert_equal Time.local(2006, 1, 1), this_year.begin assert_equal Time.local(2006, 8, 16), this_year.end end def test_offset span = Chronic::Span.new(@now, @now + 1) offset_span = Chronic::RepeaterYear.new(:year).offset(span, 3, :future) assert_equal Time.local(2009, 8, 16, 14), offset_span.begin assert_equal Time.local(2009, 8, 16, 14, 0, 1), offset_span.end offset_span = Chronic::RepeaterYear.new(:year).offset(span, 10, :past) assert_equal Time.local(1996, 8, 16, 14), offset_span.begin assert_equal Time.local(1996, 8, 16, 14, 0, 1), offset_span.end end end
Version data entries
28 entries across 28 versions & 16 rubygems