Sha256: 647014c8e12e1eda26c491dcfce472fa4237162832997b8009933da4a9a14c5d

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 KB

Contents

require 'helper'

class TestRepeaterWeekday < TestCase

  def setup
    @now = Time.local(2007, 6, 11, 14, 0, 0, 0) # Mon
  end

  def test_next_future
    weekdays = Chronic::RepeaterWeekday.new(:weekday)
    weekdays.start = @now

    next1_weekday = weekdays.next(:future) # Tues
    assert_equal Time.local(2007, 6, 12), next1_weekday.begin
    assert_equal Time.local(2007, 6, 13), next1_weekday.end

    next2_weekday = weekdays.next(:future) # Wed
    assert_equal Time.local(2007, 6, 13), next2_weekday.begin
    assert_equal Time.local(2007, 6, 14), next2_weekday.end

    next3_weekday = weekdays.next(:future) # Thurs
    assert_equal Time.local(2007, 6, 14), next3_weekday.begin
    assert_equal Time.local(2007, 6, 15), next3_weekday.end

    next4_weekday = weekdays.next(:future) # Fri
    assert_equal Time.local(2007, 6, 15), next4_weekday.begin
    assert_equal Time.local(2007, 6, 16), next4_weekday.end

    next5_weekday = weekdays.next(:future) # Mon
    assert_equal Time.local(2007, 6, 18), next5_weekday.begin
    assert_equal Time.local(2007, 6, 19), next5_weekday.end
  end

  def test_next_past
    weekdays = Chronic::RepeaterWeekday.new(:weekday)
    weekdays.start = @now

    last1_weekday = weekdays.next(:past) # Fri
    assert_equal Time.local(2007, 6, 8), last1_weekday.begin
    assert_equal Time.local(2007, 6, 9), last1_weekday.end

    last2_weekday = weekdays.next(:past) # Thurs
    assert_equal Time.local(2007, 6, 7), last2_weekday.begin
    assert_equal Time.local(2007, 6, 8), last2_weekday.end
  end

  def test_offset
    span = Chronic::Span.new(@now, @now + 1)

    offset_span = Chronic::RepeaterWeekday.new(:weekday).offset(span, 5, :future)

    assert_equal Time.local(2007, 6, 18, 14), offset_span.begin
    assert_equal Time.local(2007, 6, 18, 14, 0, 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_weekday.rb
gitlab-chronic-0.10.5 test/test_repeater_weekday.rb
gitlab-chronic-0.10.4 test/test_repeater_weekday.rb
gitlab-chronic-0.10.3 test/test_repeater_weekday.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/chronic-0.10.2/test/test_repeater_weekday.rb
chronic-mmlac-0.10.2.1 test/test_repeater_weekday.rb
chronic-0.10.2 test/test_repeater_weekday.rb
chronic-0.10.1 test/test_repeater_weekday.rb
chronic-0.10.0 test/test_repeater_weekday.rb
chronic-0.9.1 test/test_repeater_weekday.rb
chronic-0.9.0 test/test_repeater_weekday.rb
Hokkaido-0.1.5 chronic/test/test_repeater_weekday.rb
Hokkaido-0.1.4 chronic/test/test_repeater_weekday.rb
Hokkaido-0.1.3 chronic/test/test_repeater_weekday.rb
Hokkaido-0.1.2 chronic/test/test_repeater_weekday.rb
Hokkaido-0.1.1 chronic/test/test_repeater_weekday.rb
Hokkaido-0.1.0 chronic/test/test_repeater_weekday.rb
Hokkaido-0.0.9 chronic/test/test_repeater_weekday.rb
Hokkaido-0.0.6 chronic/test/test_repeater_weekday.rb
Hokkaido-0.0.5 chronic/test/test_repeater_weekday.rb