Sha256: 6c389345c0090079386381bbffae44948306e3b0f30c218d3dedc2cc38e62605

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

require 'helper'

class TestRepeaterMonth < 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

    time = Chronic::RepeaterMonth.new(:month).offset_by(Time.local(2010, 3, 29), 1, :past)
    assert_equal 2, time.month
    assert_equal 28, time.day
  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

30 entries across 30 versions & 7 rubygems

Version Path
gitlab-chronic-0.10.6 test/test_repeater_month.rb
gitlab-chronic-0.10.5 test/test_repeater_month.rb
gitlab-chronic-0.10.4 test/test_repeater_month.rb
gitlab-chronic-0.10.3 test/test_repeater_month.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/chronic-0.10.2/test/test_repeater_month.rb
chronic-mmlac-0.10.2.1 test/test_repeater_month.rb
chronic-0.10.2 test/test_repeater_month.rb
chronic-0.10.1 test/test_repeater_month.rb
chronic-0.10.0 test/test_repeater_month.rb
chronic-0.9.1 test/test_repeater_month.rb
chronic-0.9.0 test/test_repeater_month.rb
Hokkaido-0.1.5 chronic/test/test_repeater_month.rb
Hokkaido-0.1.4 chronic/test/test_repeater_month.rb
Hokkaido-0.1.3 chronic/test/test_repeater_month.rb
Hokkaido-0.1.2 chronic/test/test_repeater_month.rb
Hokkaido-0.1.1 chronic/test/test_repeater_month.rb
Hokkaido-0.1.0 chronic/test/test_repeater_month.rb
Hokkaido-0.0.9 chronic/test/test_repeater_month.rb
Hokkaido-0.0.6 chronic/test/test_repeater_month.rb
Hokkaido-0.0.5 chronic/test/test_repeater_month.rb