|
500 | 500 | occs.should == [t0] |
501 | 501 | end |
502 | 502 |
|
503 | | - it 'should include long occurrences starting before and ending after' do |
| 503 | + it 'should not find occurrence with duration ending on start time' do |
504 | 504 | t0 = Time.utc(2015, 10, 1, 12, 00) |
505 | 505 | schedule = IceCube::Schedule.new(t0, :duration => IceCube::ONE_HOUR) |
506 | | - schedule.occurs_between?(t0 + IceCube::ONE_HOUR, t0 + 2 * IceCube::ONE_HOUR, true).should be_true |
| 506 | + schedule.occurs_between?(t0 + IceCube::ONE_HOUR, t0 + 2 * IceCube::ONE_HOUR, true).should be_false |
507 | 507 | end |
508 | 508 |
|
509 | 509 | it 'should quickly fetch a future time from a recurring schedule' do |
|
518 | 518 | timing.should < 0.1 |
519 | 519 | occ.should == [t1] |
520 | 520 | end |
| 521 | + |
| 522 | + it 'should not include occurrence ending on start time' do |
| 523 | + t0 = Time.utc(2015, 10, 1, 10, 00) |
| 524 | + schedule = IceCube::Schedule.new(t0, :duration => IceCube::ONE_HOUR / 2) |
| 525 | + schedule.add_recurrence_rule IceCube::Rule.minutely(30).count(6) |
| 526 | + third_occ = schedule.next_occurrence(t0 + IceCube::ONE_HOUR, true) |
| 527 | + third_occ.should == t0 + IceCube::ONE_HOUR |
| 528 | + end |
521 | 529 |
|
522 | 530 | end |
523 | 531 |
|
|
527 | 535 | t0 = Time.utc(2013, 5, 18, 12, 34) |
528 | 536 | schedule = IceCube::Schedule.new(t0) |
529 | 537 | schedule.add_recurrence_rule IceCube::Rule.daily |
530 | | - previous = schedule.previous_occurrence(t0 + 2 * ONE_DAY) |
531 | | - previous.should == t0 + ONE_DAY |
| 538 | + previous = schedule.previous_occurrence(t0 + 2 * IceCube::ONE_DAY) |
| 539 | + previous.should == t0 + IceCube::ONE_DAY |
532 | 540 | end |
533 | 541 |
|
534 | 542 | it 'returns nil given the start time' do |
|
555 | 563 | t0 = Time.utc(2013, 5, 18, 12, 34) |
556 | 564 | schedule = IceCube::Schedule.new(t0) |
557 | 565 | schedule.add_recurrence_rule IceCube::Rule.daily |
558 | | - previous = schedule.previous_occurrences(2, t0 + 3 * ONE_DAY) |
559 | | - previous.should == [t0 + ONE_DAY, t0 + 2 * ONE_DAY] |
| 566 | + previous = schedule.previous_occurrences(2, t0 + 3 * IceCube::ONE_DAY) |
| 567 | + previous.should == [t0 + IceCube::ONE_DAY, t0 + 2 * IceCube::ONE_DAY] |
560 | 568 | end |
561 | 569 |
|
562 | 570 | it 'limits the returned occurrences to a given count' do |
563 | 571 | t0 = Time.utc(2013, 5, 18, 12, 34) |
564 | 572 | schedule = IceCube::Schedule.new(t0) |
565 | 573 | schedule.add_recurrence_rule IceCube::Rule.daily |
566 | | - previous = schedule.previous_occurrences(999, t0 + 2 * ONE_DAY) |
567 | | - previous.should == [t0, t0 + ONE_DAY] |
| 574 | + previous = schedule.previous_occurrences(999, t0 + 2 * IceCube::ONE_DAY) |
| 575 | + previous.should == [t0, t0 + IceCube::ONE_DAY] |
568 | 576 | end |
569 | 577 |
|
570 | 578 | it 'returns empty array given the start time' do |
|
601 | 609 | t1 = Time.utc(2013, 5, 31, 12, 34) |
602 | 610 | schedule = IceCube::Schedule.new(t0) |
603 | 611 | schedule.add_recurrence_rule IceCube::Rule.daily.until(t1 + 1) |
604 | | - schedule.last(2).should == [t1 - ONE_DAY, t1] |
| 612 | + schedule.last(2).should == [t1 - IceCube::ONE_DAY, t1] |
605 | 613 | end |
606 | 614 |
|
607 | 615 | it 'raises an error for a non-terminating schedule' do |
|
0 commit comments