Sha256: 994868f9e2df4f5a38bba9264543b5f1b4422e3902ad56452db026cd633fe18f

Contents?: true

Size: 995 Bytes

Versions: 9

Compression:

Stored size: 995 Bytes

Contents

require "test_helper"


class MonthlyEnumeratorTest < ActiveSupport::TestCase
  include Hiccup
  
  
  context "with a complex schedule" do
    setup do
      @schedule = Schedule.new({
        :kind => :monthly,
        :monthly_pattern => [
          [1, "Sunday"],
          [2, "Saturday"],
          [2, "Sunday"],
          [3, "Sunday"],
          [4, "Saturday"],
          [4, "Sunday"],
          [5, "Sunday"] ],
        start_date: Date.new(2005, 1, 8)
      })
    end
    
    context "when enumerating backward" do
      
      should "return the most-recent date prior to the start_date, NOT the earliest date in the month" do
        # Start with a date in the middle of the month
        # More than one date prior to the seed date, yet
        # after the first of the month.
        date = Date.new(2013, 10, 15)
        enumerator = @schedule.enumerator.new(@schedule, date)
        assert_equal Date.new(2013, 10, 13), enumerator.prev
      end
      
    end
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hiccup-0.5.11 test/monthly_enumerator_test.rb
hiccup-0.5.10 test/monthly_enumerator_test.rb
hiccup-0.5.9 test/monthly_enumerator_test.rb
hiccup-0.5.8 test/monthly_enumerator_test.rb
hiccup-0.5.7 test/monthly_enumerator_test.rb
hiccup-0.5.6 test/monthly_enumerator_test.rb
hiccup-0.5.5 test/monthly_enumerator_test.rb
hiccup-0.5.4 test/monthly_enumerator_test.rb
hiccup-0.5.3 test/monthly_enumerator_test.rb