-
Notifications
You must be signed in to change notification settings - Fork 461
/
test_repeater_fortnight.rb
62 lines (46 loc) · 1.89 KB
/
test_repeater_fortnight.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require 'helper'
class TestRepeaterFortnight < TestCase
def setup
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
end
def test_next_future
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
fortnights.start = @now
next_fortnight = fortnights.next(:future)
assert_equal Time.local(2006, 8, 20), next_fortnight.begin
assert_equal Time.local(2006, 9, 3), next_fortnight.end
next_next_fortnight = fortnights.next(:future)
assert_equal Time.local(2006, 9, 3), next_next_fortnight.begin
assert_equal Time.local(2006, 9, 17), next_next_fortnight.end
end
def test_next_past
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
fortnights.start = @now
last_fortnight = fortnights.next(:past)
assert_equal Time.local(2006, 7, 30), last_fortnight.begin
assert_equal Time.local(2006, 8, 13), last_fortnight.end
last_last_fortnight = fortnights.next(:past)
assert_equal Time.local(2006, 7, 16), last_last_fortnight.begin
assert_equal Time.local(2006, 7, 30), last_last_fortnight.end
end
def test_this_future
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
fortnights.start = @now
this_fortnight = fortnights.this(:future)
assert_equal Time.local(2006, 8, 16, 15), this_fortnight.begin
assert_equal Time.local(2006, 8, 27), this_fortnight.end
end
def test_this_past
fortnights = Chronic::RepeaterFortnight.new(:fortnight)
fortnights.start = @now
this_fortnight = fortnights.this(:past)
assert_equal Time.local(2006, 8, 13, 0), this_fortnight.begin
assert_equal Time.local(2006, 8, 16, 14), this_fortnight.end
end
def test_offset
span = Chronic::Span.new(@now, @now + 1)
offset_span = Chronic::RepeaterWeek.new(:week).offset(span, 3, :future)
assert_equal Time.local(2006, 9, 6, 14), offset_span.begin
assert_equal Time.local(2006, 9, 6, 14, 0, 1), offset_span.end
end
end