File: test_repeater_minute.rb

package info (click to toggle)
ruby-chronic 0.10.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: ruby: 4,557; makefile: 9; sh: 8
file content (34 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'helper'

class TestRepeaterMinute < TestCase

  def setup
    @now = Time.local(2008, 6, 25, 7, 15, 30, 0)
  end

  def test_next_future
    minutes = Chronic::RepeaterMinute.new(:minute)
    minutes.start = @now

    next_minute = minutes.next(:future)
    assert_equal Time.local(2008, 6, 25, 7, 16), next_minute.begin
    assert_equal Time.local(2008, 6, 25, 7, 17), next_minute.end

    next_next_minute = minutes.next(:future)
    assert_equal Time.local(2008, 6, 25, 7, 17), next_next_minute.begin
    assert_equal Time.local(2008, 6, 25, 7, 18), next_next_minute.end
  end

  def test_next_past
    minutes = Chronic::RepeaterMinute.new(:minute)
    minutes.start = @now

    prev_minute = minutes.next(:past)
    assert_equal Time.local(2008, 6, 25, 7, 14), prev_minute.begin
    assert_equal Time.local(2008, 6, 25, 7, 15), prev_minute.end

    prev_prev_minute = minutes.next(:past)
    assert_equal Time.local(2008, 6, 25, 7, 13), prev_prev_minute.begin
    assert_equal Time.local(2008, 6, 25, 7, 14), prev_prev_minute.end
  end
end