From 3c0ff00cfbcc4fe7db2336b2c9d857801b8517bd Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Fri, 26 Mar 2010 12:46:25 -0400 Subject: [PATCH] Allow count to be 0 --- lib/ice_cube/rule.rb | 2 +- spec/examples/ice_cube_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ice_cube/rule.rb b/lib/ice_cube/rule.rb index 61da8cfe..dfce1157 100644 --- a/lib/ice_cube/rule.rb +++ b/lib/ice_cube/rule.rb @@ -55,7 +55,7 @@ def until(until_date) # set the number of occurrences after which this rule is no longer effective def count(count) - raise ArgumentError.new('Argument must be a positive integer') unless Integer(count) && count > 0 #todo - maybe allow count to be 0 + raise ArgumentError.new('Argument must be a positive integer') unless Integer(count) && count >= 0 @occurrence_count = count self end diff --git a/spec/examples/ice_cube_spec.rb b/spec/examples/ice_cube_spec.rb index f62d3815..3b2e25c5 100644 --- a/spec/examples/ice_cube_spec.rb +++ b/spec/examples/ice_cube_spec.rb @@ -107,4 +107,11 @@ dates.each { |date| date.sec == 30 } end + it 'ensure that when count on a rule is set to 0, 0 occurrences come back' do + start_date = DAY + schedule = Schedule.new(start_date) + schedule.add_recurrence_rule Rule.daily.count(0) + schedule.all_occurrences.should == [] + end + end