Sha256: 508f1a253bbb4b95bfe938fe1a3b3a4ba8f2b13ad74458f1709b41bb8f630c77

Contents?: true

Size: 1.31 KB

Versions: 28

Compression:

Stored size: 1.31 KB

Contents

require 'chronic'
require 'test/unit'

class TestRepeaterMonth < 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_offset_by
    # future
    
    time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :future)
    assert_equal Time.local(2006, 9, 16, 14), time
    
    time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 5, :future)
    assert_equal Time.local(2007, 1, 16, 14), time
    
    # past
    
    time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 1, :past)
    assert_equal Time.local(2006, 7, 16, 14), time
    
    time = Chronic::RepeaterMonth.new(:month).offset_by(@now, 10, :past)
    assert_equal Time.local(2005, 10, 16, 14), time
  end
  
  def test_offset
    # future
    
    span = Chronic::Span.new(@now, @now + 60)
    offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :future)
    
    assert_equal Time.local(2006, 9, 16, 14), offset_span.begin
    assert_equal Time.local(2006, 9, 16, 14, 1), offset_span.end
    
   # past
   
   span = Chronic::Span.new(@now, @now + 60)
   offset_span = Chronic::RepeaterMonth.new(:month).offset(span, 1, :past)
   
   assert_equal Time.local(2006, 7, 16, 14), offset_span.begin
   assert_equal Time.local(2006, 7, 16, 14, 1), offset_span.end
  end
  
end

Version data entries

28 entries across 28 versions & 16 rubygems

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