Sha256: a85e33537a45f7551ae95943d4aa9ce668d77c62b955ecdb4dbd65cdc63a5217

Contents?: true

Size: 1.89 KB

Versions: 30

Compression:

Stored size: 1.89 KB

Contents

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

Version data entries

30 entries across 30 versions & 7 rubygems

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