Sha256: 6c3ae9f804446dc9c44f82fa89f4483fa4d3a36858ad7a5f53754cc44cfb1f78

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Droom::RecurrenceRule do
  
  describe "date-limited rule" do
    before do 
      @rule = FactoryGirl.create(:date_limited)
    end
    
    it "should be bounded" do
      @rule.unbounded?.should be_false
    end

    it "should report the right basis" do
      @rule.basis.should == 'limit'
    end

    it "should describe itself correctly" do
      @rule.to_s.should == "weekly until 24 February 2009"
    end
  end

  describe "count-limited rule" do
    before do 
      @rule = FactoryGirl.create(:count_limited)
    end
    
    it "should be bounded" do
      @rule.unbounded?.should be_false
    end

    it "should report the right basis" do
      @rule.basis.should == 'count'
    end

    it "should describe itself correctly" do
      @rule.to_s.should == "every 2 months, 12 times"
    end
  end

  describe "unlimited rule" do
    before do 
      @rule = FactoryGirl.create(:unlimited)
    end
    
    it "should not be bounded" do
      @rule.unbounded?.should be_true
    end

    it "should report no basis" do
      @rule.basis.should be_nil
    end
    
    it "should describe itself correctly" do
      @rule.to_s.should == "every 2 days, indefinitely"
    end
  end

  describe "imported rule" do
    before do 
      @rule = Droom::RecurrenceRule.from("FREQ=DAILY;INTERVAL=1;UNTIL=20090228")
    end
    
    it "should be bounded" do
      @rule.unbounded?.should be_false
    end

    it "should report the right basis" do
      @rule.basis.should == 'limit'
    end

    it "should have the right limiting date" do
      @rule.limiting_date.should == DateTime.civil(2009, 2, 28)
    end
    
    it "should describe itself correctly" do
      @rule.to_s.should == "daily until 28 February 2009"
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
droom-0.4.3 spec/models/droom/recurrence_rule_spec.rb
droom-0.4.2 spec/models/droom/recurrence_rule_spec.rb
droom-0.4.1 spec/models/droom/recurrence_rule_spec.rb
droom-0.2.1 spec/models/droom/recurrence_rule_spec.rb