Sha256: 2ebdbf7d0ea67eecb9816ec54b808195e2b7130646f38a8106a3f976a3fe819a
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), "..", "lib") require 'date' require 'test/unit' require 'icalendar' class TestComponent < Test::Unit::TestCase # Create a calendar with an event for each test. def setup @cal = Icalendar::Calendar.new @event = Icalendar::Event.new end def test_add_component @cal.add_component @event assert_equal(@cal.events.size, 1) end def test_ical_property # No alias but it does have a prop_name assert_equal(@event.ip_class?, false) @event.ip_class = "PRIVATE" assert_equal(@event.ip_class?, true) assert_equal(@event.ip_class, "PRIVATE") # Check that both dtstart and its alias start work correctly date = DateTime.new(2005, 02, 05, 23, 24, 25) @event.dtend = date assert_equal(@event.dtend.year, date.year) date2 = DateTime.new(2005, 02, 05, 23, 24, 26) @event.end = date2 assert_equal(@event.end.year, date2.year) end def test_ical_multi_property # Query assert_equal(@event.comments?, false) @event.comments = [] assert_equal(@event.comments?, true) # Should return an empty array, rather than nil assert_equal(@event.comments.size, 0) # Add and remove @event.add_comment "c1" @event.add_comment "c2" assert_equal(@event.comments.size, 2) assert_equal(@event.comments, ["c1", "c2"]) @event.remove_comment "c1" assert_equal(@event.comments, ["c2"]) # Set & get whole array foo = ["as", "df"] @event.comments = foo assert_equal(@event.comments, foo) foo = ["asdf", "qwer"] @event.comments(foo) assert_equal(@event.comments, foo) # Error cases assert_raise(ArgumentError) { @event.comments("asdf") } end def test_bad_args # Single property assert_raise(NotImplementedError) do @event.ip_class = {} end # Multi property assert_raise(NotImplementedError) do @event.comments = [{}] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
icalendar-0.96.2 | test/component_test.rb |
icalendar-0.96.3 | test/component_test.rb |
icalendar-0.96.4 | test/component_test.rb |