Sha256: d388f15545063452589cff0b8adb77b8c301b2379ac98c5aac3043f8e6b9bc6e

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe RiCal::RequiredTimezones::RequiredTimezone do

  before(:each) do
    @tzid = "America/New_York"
    @it = RiCal::RequiredTimezones::RequiredTimezone.new(@tzid)
  end

  it "should have the right timezone" do
    @it.timezone.identifier.should == @tzid
  end

  it "should set the first_time to the first date_time added" do
    dt1 = dt_prop(DateTime.parse("Mar 22, 2009 10:48"))
    @it.add_datetime(dt1)
    @it.first_time.should == dt1
  end

  it "should set the first_time to the earliest time added" do
    dt1 = dt_prop(DateTime.parse("Mar 22, 2009 10:48"))
    dt2 = dt_prop(DateTime.parse("Mar 22, 2009 9:00"))
    dt3 = dt_prop(DateTime.parse("Mar 22, 2009 10:00"))
    @it.add_datetime(dt1)
    @it.add_datetime(dt2)
    @it.add_datetime(dt3)
    @it.first_time.should == dt2
  end

  it "should set the last_time to the first date_time added" do
    dt1 = dt_prop(DateTime.parse("Mar 22, 2009 10:48"))
    @it.add_datetime(dt1)
    @it.last_time.should == dt1
  end

  it "should set the first_time to the earliest time added" do
    dt1 = dt_prop(DateTime.parse("Mar 22, 2009 10:48"))
    dt2 = dt_prop(DateTime.parse("Mar 22, 2009 9:00"))
    dt3 = dt_prop(DateTime.parse("Mar 22, 2009 10:00"))
    @it.add_datetime(dt1)
    @it.add_datetime(dt2)
    @it.add_datetime(dt3)
    @it.last_time.should == dt1
  end
end

describe RiCal::RequiredTimezones do
  before(:each) do
    @it = RiCal::RequiredTimezones.new
  end
  
  def localtime_and_zone(date_time, tzid = "US/Eastern")
    [dt_prop(DateTime.parse(date_time), tzid), tzid]
  end
  

  it "should create a RequiredTimezone for each new timezone presented" do
    @it.add_datetime(*localtime_and_zone("Mar 22, 2009 1:00"))
    @it.add_datetime(*localtime_and_zone("Apr 16, 2008 12:00", "US/Central"))
    @it.add_datetime(*localtime_and_zone("Apr 16, 2008 12:00"))
    @it.required_zones.map {|zone| zone.tzid}.sort.should == ["US/Central", "US/Eastern"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friflaj_ri_cal-0.9.0 spec/ri_cal/required_timezones_spec.rb