Sha256: 6caf89b289cbb8a2afdc2ca0dc6c941c0c45430a958dced6fd824b1ad3f3a773

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')

require 'test/unit'
require 'icalendar'

require 'date'

class TestCalendar < Test::Unit::TestCase
  # Generate a calendar using the raw api, and then spit it out
  # as a string.  Parse the string and make sure everything matches up.
  def test_raw_generation    
    # Create a fresh calendar
    cal = Icalendar::Calendar.new
    
    cal.calscale = "GREGORIAN"
    cal.version = "3.2"
    cal.prodid = "test-prodid"
    
    # Now generate the string and then parse it so we can verify 
    # that everything was set, generated and parsed correctly.
    calString = cal.to_ical

    cals = Icalendar::Parser.new(calString).parse
    
    cal2 = cals.first
    assert_equal("GREGORIAN", cal2.calscale)
    assert_equal("3.2", cal2.version)
    assert_equal("test-prodid", cal2.prodid)
  end

  def test_block_creation
    cal = Icalendar::Calendar.new
    cal.event do
      dtend "19970903T190000Z"
      summary "This is my summary"
    end
    
    event = cal.event
    event.dtend = "19970903T190000Z"
    event.summary = "This is my summary"

    ev = cal.events.each do |ev|
      assert_equal("19970903T190000Z", ev.dtend)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
icalendar-0.95 test/calendar_test.rb