From 8da16ad2cd6433cf37ee57a6845e1999b87bc333 Mon Sep 17 00:00:00 2001 From: Andrew Vit Date: Tue, 12 Feb 2013 00:13:51 -0800 Subject: [PATCH] Make schedules easier to set up Fixes #146 --- lib/ice_cube/schedule.rb | 1 + spec/examples/schedule_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/ice_cube/schedule.rb b/lib/ice_cube/schedule.rb index 4b971926..3c9fa0ff 100644 --- a/lib/ice_cube/schedule.rb +++ b/lib/ice_cube/schedule.rb @@ -21,6 +21,7 @@ def initialize(start_time = nil, options = {}) self.end_time = options[:end_time] if options[:end_time] @all_recurrence_rules = [] @all_exception_rules = [] + yield self if block_given? end # Set start_time diff --git a/spec/examples/schedule_spec.rb b/spec/examples/schedule_spec.rb index 07e06ca6..f2641136 100644 --- a/spec/examples/schedule_spec.rb +++ b/spec/examples/schedule_spec.rb @@ -4,6 +4,14 @@ include IceCube + it 'yields itself for configuration' do + t1 = Time.utc(2013, 2, 12, 12, 34 ,56) + schedule = IceCube::Schedule.new do |s| + s.start_time = t1 + end + schedule.start_time.should == t1 + end + describe :duration do it 'should be based on end_time' do