Sha256: 692ecde6d62fa38626d3795dea03728ca9e44532752d0c674dbb024142aedfe1

Contents?: true

Size: 1.28 KB

Versions: 30

Compression:

Stored size: 1.28 KB

Contents

require 'helper'

class TestRepeaterDayName < TestCase

  def setup
    @now = Time.local(2006, 8, 16, 14, 0, 0, 0)
  end

  def test_match
    token = Chronic::Token.new('saturday')
    repeater = Chronic::Repeater.scan_for_day_names(token)
    assert_equal Chronic::RepeaterDayName, repeater.class
    assert_equal :saturday, repeater.type

    token = Chronic::Token.new('sunday')
    repeater = Chronic::Repeater.scan_for_day_names(token)
    assert_equal Chronic::RepeaterDayName, repeater.class
    assert_equal :sunday, repeater.type
  end

  def test_next_future
    mondays = Chronic::RepeaterDayName.new(:monday)
    mondays.start = @now

    span = mondays.next(:future)

    assert_equal Time.local(2006, 8, 21), span.begin
    assert_equal Time.local(2006, 8, 22), span.end

    span = mondays.next(:future)

    assert_equal Time.local(2006, 8, 28), span.begin
    assert_equal Time.local(2006, 8, 29), span.end
  end

  def test_next_past
    mondays = Chronic::RepeaterDayName.new(:monday)
    mondays.start = @now

    span = mondays.next(:past)

    assert_equal Time.local(2006, 8, 14), span.begin
    assert_equal Time.local(2006, 8, 15), span.end

    span = mondays.next(:past)

    assert_equal Time.local(2006, 8, 7), span.begin
    assert_equal Time.local(2006, 8, 8), span.end
  end

end

Version data entries

30 entries across 30 versions & 7 rubygems

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