Sha256: c50179ee1987ba1849685c2411803731129a426b75d65b4361a0d321b510009d

Contents?: true

Size: 1.55 KB

Versions: 28

Compression:

Stored size: 1.55 KB

Contents

require 'chronic'
require 'test/unit'

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

Version data entries

28 entries across 28 versions & 16 rubygems

Version Path
blakechambers-chronic-0.3.0.2 test/test_RepeaterMonthName.rb
evaryont-chronic-0.3.0.2 test/test_RepeaterMonthName.rb
jdl-chronic-0.3.0.1 test/test_RepeaterMonthName.rb
lmarlow-chronic-0.3.0.1 test/test_RepeaterMonthName.rb
mojombo-chronic-0.3.0 test/test_RepeaterMonthName.rb
moorage-chronic-0.3.0 test/test_RepeaterMonthName.rb
rgm-chronic-0.3.1 test/test_RepeaterMonthName.rb
sethwalker-chronic-0.3.0 test/test_RepeaterMonthName.rb
jdl-chronic-0.3.0.2 test/test_RepeaterMonthName.rb
hank-chronic-0.3.12 test/test_RepeaterMonthName.rb
pangel-chronic-0.3.11 test/test_RepeaterMonthName.rb
pangel-chronic-0.3.10 test/test_RepeaterMonthName.rb
aaronh-chronic-0.3.9 test/test_RepeaterMonthName.rb
philrosenstein-chronic-0.3.9 test/test_RepeaterMonthName.rb
clio-chronic-0.3.9 test/test_RepeaterMonthName.rb
caleb-chronic-0.3.0 test/test_RepeaterMonthName.rb
pyrat-chronic-0.3.1 test/test_RepeaterMonthName.rb
chronic-0.1.1 test/test_RepeaterMonthName.rb
chronic-0.1.0 test/test_RepeaterMonthName.rb
chronic-0.1.6 test/test_RepeaterMonthName.rb