Sha256: 96ee31a5e89c1c41d5fd5fe0c9f16ec5af81475f20fe4705a7736715343c9c6c

Contents?: true

Size: 1.82 KB

Versions: 21

Compression:

Stored size: 1.82 KB

Contents

require 'helper'

class TestRepeaterTime < 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
    t = Chronic::RepeaterTime.new('4:00')
    t.start = @now

    assert_equal Time.local(2006, 8, 16, 16), t.next(:future).begin
    assert_equal Time.local(2006, 8, 17, 4), t.next(:future).begin

    t = Chronic::RepeaterTime.new('13:00')
    t.start = @now

    assert_equal Time.local(2006, 8, 17, 13), t.next(:future).begin
    assert_equal Time.local(2006, 8, 18, 13), t.next(:future).begin

    t = Chronic::RepeaterTime.new('0400')
    t.start = @now

    assert_equal Time.local(2006, 8, 17, 4), t.next(:future).begin
    assert_equal Time.local(2006, 8, 18, 4), t.next(:future).begin
  end

  def test_next_past
    t = Chronic::RepeaterTime.new('4:00')
    t.start = @now

    assert_equal Time.local(2006, 8, 16, 4), t.next(:past).begin
    assert_equal Time.local(2006, 8, 15, 16), t.next(:past).begin

    t = Chronic::RepeaterTime.new('13:00')
    t.start = @now

    assert_equal Time.local(2006, 8, 16, 13), t.next(:past).begin
    assert_equal Time.local(2006, 8, 15, 13), t.next(:past).begin
  end

  def test_type
    t1 = Chronic::RepeaterTime.new('4')
    assert_equal 14_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('14')
    assert_equal 50_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('4:00')
    assert_equal 14_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('4:30')
    assert_equal 16_200, t1.type.time

    t1 = Chronic::RepeaterTime.new('1400')
    assert_equal 50_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('0400')
    assert_equal 14_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('04')
    assert_equal 14_400, t1.type.time

    t1 = Chronic::RepeaterTime.new('400')
    assert_equal 14_400, t1.type.time
  end

end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
chronic-0.9.1 test/test_repeater_time.rb
chronic-0.9.0 test/test_repeater_time.rb
Hokkaido-0.1.5 chronic/test/test_repeater_time.rb
Hokkaido-0.1.4 chronic/test/test_repeater_time.rb
Hokkaido-0.1.3 chronic/test/test_repeater_time.rb
Hokkaido-0.1.2 chronic/test/test_repeater_time.rb
Hokkaido-0.1.1 chronic/test/test_repeater_time.rb
Hokkaido-0.1.0 chronic/test/test_repeater_time.rb
Hokkaido-0.0.9 chronic/test/test_repeater_time.rb
Hokkaido-0.0.6 chronic/test/test_repeater_time.rb
Hokkaido-0.0.5 chronic/test/test_repeater_time.rb
Hokkaido-0.0.4 chronic/test/test_repeater_time.rb
chronic-0.8.0 test/test_repeater_time.rb
chronic-0.7.0 test/test_repeater_time.rb
chronic_2001-0.1.5 test/test_repeater_time.rb
chronic_2001-0.1.4 test/test_repeater_time.rb
chronic_2001-0.1.3 test/test_repeater_time.rb
chronic_2001-0.1.2 test/test_repeater_time.rb
chronic_2001-0.1.1 test/test_repeater_time.rb
chronic_2001-0.1.0 test/test_repeater_time.rb