rubyredrick-ri_cal 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +122 -0
  3. data/README.txt +271 -0
  4. data/Rakefile +31 -0
  5. data/bin/ri_cal +8 -0
  6. data/component_attributes/alarm.yml +10 -0
  7. data/component_attributes/calendar.yml +4 -0
  8. data/component_attributes/component_property_defs.yml +180 -0
  9. data/component_attributes/event.yml +45 -0
  10. data/component_attributes/freebusy.yml +16 -0
  11. data/component_attributes/journal.yml +35 -0
  12. data/component_attributes/timezone.yml +3 -0
  13. data/component_attributes/timezone_period.yml +11 -0
  14. data/component_attributes/todo.yml +46 -0
  15. data/copyrights.txt +2 -0
  16. data/docs/draft-ietf-calsify-2446bis-08.txt +7280 -0
  17. data/docs/draft-ietf-calsify-rfc2445bis-09.txt +10416 -0
  18. data/docs/incrementers.txt +7 -0
  19. data/docs/rfc2445.pdf +0 -0
  20. data/lib/ri_cal/component/alarm.rb +22 -0
  21. data/lib/ri_cal/component/calendar.rb +199 -0
  22. data/lib/ri_cal/component/event.rb +30 -0
  23. data/lib/ri_cal/component/freebusy.rb +19 -0
  24. data/lib/ri_cal/component/journal.rb +22 -0
  25. data/lib/ri_cal/component/t_z_info_timezone.rb +124 -0
  26. data/lib/ri_cal/component/timezone/daylight_period.rb +26 -0
  27. data/lib/ri_cal/component/timezone/standard_period.rb +24 -0
  28. data/lib/ri_cal/component/timezone/timezone_period.rb +54 -0
  29. data/lib/ri_cal/component/timezone.rb +193 -0
  30. data/lib/ri_cal/component/todo.rb +26 -0
  31. data/lib/ri_cal/component.rb +224 -0
  32. data/lib/ri_cal/core_extensions/array/conversions.rb +15 -0
  33. data/lib/ri_cal/core_extensions/array.rb +7 -0
  34. data/lib/ri_cal/core_extensions/date/conversions.rb +27 -0
  35. data/lib/ri_cal/core_extensions/date.rb +13 -0
  36. data/lib/ri_cal/core_extensions/date_time/conversions.rb +27 -0
  37. data/lib/ri_cal/core_extensions/date_time.rb +13 -0
  38. data/lib/ri_cal/core_extensions/object/conversions.rb +20 -0
  39. data/lib/ri_cal/core_extensions/object.rb +8 -0
  40. data/lib/ri_cal/core_extensions/string/conversions.rb +32 -0
  41. data/lib/ri_cal/core_extensions/string.rb +8 -0
  42. data/lib/ri_cal/core_extensions/time/calculations.rb +153 -0
  43. data/lib/ri_cal/core_extensions/time/conversions.rb +27 -0
  44. data/lib/ri_cal/core_extensions/time/week_day_predicates.rb +88 -0
  45. data/lib/ri_cal/core_extensions/time.rb +11 -0
  46. data/lib/ri_cal/core_extensions.rb +6 -0
  47. data/lib/ri_cal/invalid_timezone_identifer.rb +20 -0
  48. data/lib/ri_cal/occurrence_enumerator.rb +172 -0
  49. data/lib/ri_cal/parser.rb +138 -0
  50. data/lib/ri_cal/properties/alarm.rb +390 -0
  51. data/lib/ri_cal/properties/calendar.rb +164 -0
  52. data/lib/ri_cal/properties/event.rb +1526 -0
  53. data/lib/ri_cal/properties/freebusy.rb +594 -0
  54. data/lib/ri_cal/properties/journal.rb +1240 -0
  55. data/lib/ri_cal/properties/timezone.rb +151 -0
  56. data/lib/ri_cal/properties/timezone_period.rb +416 -0
  57. data/lib/ri_cal/properties/todo.rb +1562 -0
  58. data/lib/ri_cal/property_value/array.rb +19 -0
  59. data/lib/ri_cal/property_value/cal_address.rb +12 -0
  60. data/lib/ri_cal/property_value/date.rb +119 -0
  61. data/lib/ri_cal/property_value/date_time/additive_methods.rb +43 -0
  62. data/lib/ri_cal/property_value/date_time/time_machine.rb +180 -0
  63. data/lib/ri_cal/property_value/date_time/timezone_support.rb +65 -0
  64. data/lib/ri_cal/property_value/date_time.rb +324 -0
  65. data/lib/ri_cal/property_value/duration.rb +106 -0
  66. data/lib/ri_cal/property_value/geo.rb +12 -0
  67. data/lib/ri_cal/property_value/integer.rb +13 -0
  68. data/lib/ri_cal/property_value/occurrence_list.rb +82 -0
  69. data/lib/ri_cal/property_value/period.rb +63 -0
  70. data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +98 -0
  71. data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +77 -0
  72. data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +149 -0
  73. data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +54 -0
  74. data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +32 -0
  75. data/lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb +794 -0
  76. data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +132 -0
  77. data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +61 -0
  78. data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +34 -0
  79. data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +50 -0
  80. data/lib/ri_cal/property_value/recurrence_rule/validations.rb +126 -0
  81. data/lib/ri_cal/property_value/recurrence_rule.rb +146 -0
  82. data/lib/ri_cal/property_value/text.rb +41 -0
  83. data/lib/ri_cal/property_value/uri.rb +12 -0
  84. data/lib/ri_cal/property_value/utc_offset.rb +34 -0
  85. data/lib/ri_cal/property_value.rb +110 -0
  86. data/lib/ri_cal/required_timezones.rb +56 -0
  87. data/lib/ri_cal/time_with_floating_timezone.rb +59 -0
  88. data/lib/ri_cal.rb +134 -0
  89. data/ri_cal.gemspec +47 -0
  90. data/sample_ical_files/from_ical_dot_app/test1.ics +38 -0
  91. data/script/console +10 -0
  92. data/script/destroy +14 -0
  93. data/script/generate +14 -0
  94. data/script/txt2html +71 -0
  95. data/spec/ri_cal/component/alarm_spec.rb +13 -0
  96. data/spec/ri_cal/component/calendar_spec.rb +55 -0
  97. data/spec/ri_cal/component/event_spec.rb +157 -0
  98. data/spec/ri_cal/component/freebusy_spec.rb +13 -0
  99. data/spec/ri_cal/component/journal_spec.rb +13 -0
  100. data/spec/ri_cal/component/t_z_info_timezone_spec.rb +37 -0
  101. data/spec/ri_cal/component/timezone_spec.rb +155 -0
  102. data/spec/ri_cal/component/todo_spec.rb +61 -0
  103. data/spec/ri_cal/component_spec.rb +212 -0
  104. data/spec/ri_cal/core_extensions/time/calculations_spec.rb +189 -0
  105. data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +46 -0
  106. data/spec/ri_cal/occurrence_enumerator_spec.rb +218 -0
  107. data/spec/ri_cal/parser_spec.rb +304 -0
  108. data/spec/ri_cal/property_value/date_spec.rb +22 -0
  109. data/spec/ri_cal/property_value/date_time_spec.rb +448 -0
  110. data/spec/ri_cal/property_value/duration_spec.rb +80 -0
  111. data/spec/ri_cal/property_value/period_spec.rb +50 -0
  112. data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +22 -0
  113. data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1815 -0
  114. data/spec/ri_cal/property_value/text_spec.rb +14 -0
  115. data/spec/ri_cal/property_value/utc_offset_spec.rb +49 -0
  116. data/spec/ri_cal/property_value_spec.rb +111 -0
  117. data/spec/ri_cal/required_timezones_spec.rb +68 -0
  118. data/spec/ri_cal_spec.rb +54 -0
  119. data/spec/spec.opts +4 -0
  120. data/spec/spec_helper.rb +24 -0
  121. data/tasks/ri_cal.rake +403 -0
  122. data/tasks/spec.rake +35 -0
  123. metadata +201 -0
@@ -0,0 +1,304 @@
1
+ #- ©2009 Rick DeNatale
2
+ #- All rights reserved
3
+
4
+ require File.join(File.dirname(__FILE__), %w[.. spec_helper])
5
+
6
+ describe RiCal::Parser do
7
+
8
+ def self.describe_property(entity_name, prop_name, params, value, type = RiCal::PropertyValue::Text)
9
+ describe_named_property(entity_name, prop_name, prop_name, params, value, false, type)
10
+ end
11
+
12
+ def self.describe_multi_property(entity_name, prop_name, params, value, type = RiCal::PropertyValue::Text)
13
+ describe_named_property(entity_name, prop_name, prop_name, params, value, true, type)
14
+ end
15
+
16
+ def self.describe_named_property(entity_name, prop_text, prop_name, params, value, multi, type = RiCal::PropertyValue::Text)
17
+ ruby_value_name = prop_name.tr("-", "_").downcase
18
+ ruby_prop_name = "#{prop_text.tr('-', '_').downcase}_property"
19
+ expected_ruby_value = type.convert(nil, value).ruby_value
20
+ describe "#{prop_name} with value of #{value.inspect}" do
21
+ parse_input = params.inject("BEGIN:#{entity_name.upcase}\n#{prop_text.upcase}") { |pi, assoc| "#{pi};#{assoc[0]}=#{assoc[1]}"}
22
+ parse_input = "#{parse_input}:#{value.to_rfc2445_string}\nEND:#{entity_name.upcase}"
23
+
24
+ it "should parse an event with an #{prop_text.upcase} property" do
25
+ lambda {RiCal::Parser.parse(StringIO.new(parse_input))}.should_not raise_error
26
+ end
27
+
28
+ describe "property characteristics" do
29
+ before(:each) do
30
+ @entity = RiCal::Parser.parse(StringIO.new(parse_input)).first
31
+ @prop = @entity.send(ruby_prop_name.to_sym)
32
+ if multi && Array === @prop
33
+ @prop = @prop.first
34
+ end
35
+ end
36
+
37
+ it "should be a #{type.name}" do
38
+ @prop.class.should == type
39
+ end
40
+
41
+ it "should have the right value" do
42
+ @prop.value.should == value
43
+ end
44
+
45
+ it "should make the value accessible directly" do
46
+ val = @entity.send(ruby_value_name)
47
+ val = val.first if multi && Array === val
48
+ val.should == expected_ruby_value
49
+ end
50
+
51
+ it "should have the right parameters" do
52
+ params.each do | key, value |
53
+ @prop.params[key].should == value
54
+ end
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+
61
+ describe ".next_line" do
62
+ it "should return line by line" do
63
+ RiCal::Parser.new(StringIO.new("abc\ndef")).next_line.should == "abc"
64
+ end
65
+
66
+ it "should combine lines" do
67
+ RiCal::Parser.new(StringIO.new("abc\n def\n ghi")).next_line.should == "abcdef ghi"
68
+ end
69
+ end
70
+
71
+ describe ".separate_line" do
72
+
73
+ before(:each) do
74
+ @parser = RiCal::Parser.new
75
+ end
76
+
77
+ it "should return a hash" do
78
+ @parser.separate_line("abc;x=y;z=1,2:value").should be_kind_of(Hash)
79
+ end
80
+
81
+ it "should find the name" do
82
+ @parser.separate_line("abc;x=y;z=1,2:value")[:name].should == "abc"
83
+ end
84
+
85
+ it "should find the parameters" do
86
+ @parser.separate_line("abc;x=y;z=1,2:value")[:params].should == {"x" => "y","z" => "1,2"}
87
+ end
88
+
89
+ it "should find the value" do
90
+ @parser.separate_line("abc;x=y;z=1,2:value")[:value].should == "value"
91
+ end
92
+ end
93
+
94
+ describe ".parse" do
95
+
96
+ it "should reject a file which doesn't start with BEGIN" do
97
+ parser = RiCal::Parser.new(StringIO.new("END:VCALENDAR"))
98
+ lambda {parser.parse}.should raise_error
99
+ end
100
+
101
+ describe "parsing an event" do
102
+ it "should parse an event" do
103
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VEVENT"))
104
+ RiCal::Component::Event.should_receive(:from_parser).with(parser, nil)
105
+ parser.parse
106
+ end
107
+
108
+ it "should parse an event and return a Event" do
109
+ cal = RiCal::Parser.parse(StringIO.new("BEGIN:VEVENT\nEND:VEVENT")).first
110
+ cal.should be_kind_of(RiCal::Component::Event)
111
+ end
112
+
113
+ #RFC 2445 section 4.8.1.1 pp 77
114
+ describe_multi_property("VEVENT", "ATTACH", {"FMTTYPE" => "application/postscript"}, "FMTTYPE=application/postscript:ftp//xyzCorp.com/put/reports/r-960812.ps", RiCal::PropertyValue::Uri)
115
+
116
+ #RFC 2445 section 4.8.1.2 pp 78
117
+ describe_multi_property("VEVENT", "CATEGORIES", {"LANGUAGE" => "us-EN"}, %w{APPOINTMENT EDUCATION}, RiCal::PropertyValue::Array)
118
+
119
+ #RFC 2445 section 4.8.1.3 pp 79
120
+ describe_named_property("VEVENT", "CLASS", "security_class", {"X-FOO" => "BAR"}, "PUBLIC", false)
121
+
122
+ #RFC 2445 section 4.8.1.4 pp 80
123
+ describe_multi_property("VEVENT", "COMMENT", {"X-FOO" => "BAR"}, "Event comment")
124
+
125
+ #RFC 2445 section 4.8.1.5 pp 81
126
+ describe_property("VEVENT", "DESCRIPTION", {"X-FOO" => "BAR"}, "Event description")
127
+
128
+ #RFC 2445 section 4.8.1.6 pp 82
129
+ describe_property("VEVENT", "GEO", {"X-FOO" => "BAR"}, "37.386013;-122.082932", RiCal::PropertyValue::Geo)
130
+
131
+ #RFC 2445 section 4.8.1.7 pp 84
132
+ describe_property("VEVENT", "LOCATION", {"ALTREP" => "\"http://xyzcorp.com/conf-rooms/f123.vcf\""}, "Conference Room - F123, Bldg. 002")
133
+
134
+ #RFC 2445 section 4.8.1.8 PERCENT-COMPLETE does not apply to Events
135
+
136
+ #RFC 2445 section 4.8.1.9 pp 84
137
+ describe_property("VEVENT", "PRIORITY", {"X-FOO" => "BAR"}, 1, RiCal::PropertyValue::Integer)
138
+
139
+ #RFC 2445 section 4.8.1.10 pp 87
140
+ describe_multi_property("VEVENT", "RESOURCES", {"X-FOO" => "BAR"}, %w{Easel Projector VCR}, RiCal::PropertyValue::Array)
141
+
142
+ #RFC 2445 section 4.8.1.11 pp 88
143
+ describe_property("VEVENT", "STATUS", {"X-FOO" => "BAR"}, "CONFIRMED")
144
+
145
+ #RFC 2445 section 4.8.1.12 pp 89
146
+ describe_property("VEVENT", "SUMMARY", {"X-FOO" => "BAR"}, "Department Party")
147
+
148
+ #RFC 2445 section 4.8.2.1 COMPLETED does not apply to Events
149
+
150
+ #RFC 2445 section 4.8.2.2 DTEND p91
151
+ describe_property("VEVENT", "DTEND", {"X-FOO" => "BAR"}, "19970714", RiCal::PropertyValue::Date)
152
+ describe_property("VEVENT", "DTEND", {"X-FOO" => "BAR"}, "19970714T235959Z", RiCal::PropertyValue::DateTime)
153
+
154
+ #RFC 2445 section 4.8.2.3 DUE does not apply to Events
155
+
156
+ #RFC 2445 section 4.8.2.4 DTSTART p93
157
+ describe_property("VEVENT", "DTSTART", {"X-FOO" => "BAR"}, "19970714", RiCal::PropertyValue::Date)
158
+ describe_property("VEVENT", "DTSTART", {"X-FOO" => "BAR"}, "19970714T235959Z", RiCal::PropertyValue::DateTime)
159
+
160
+ #RFC 2445 section 4.8.2.5 DURATION p94
161
+ describe_property("VEVENT", "DURATION", {"X-FOO" => "BAR"}, "19970714", RiCal::PropertyValue::Duration)
162
+
163
+ #RFC 2445 section 4.8.2.6 FREEBUSY does not apply to Events
164
+
165
+ #RFC 2445 section 4.8.2.4 TRANSP p93
166
+ describe_property("VEVENT", "TRANSP", {"X-FOO" => "BAR"}, "OPAQUE")
167
+ #TO-DO need to spec that values are constrained to OPAQUE and TRANSPARENT
168
+ # and that this property can be specified at most once
169
+
170
+ #RFC 2445 section 4.8.4.1 ATTENDEE p102
171
+ describe_multi_property("VEVENT", "ATTENDEE", {"X-FOO" => "BAR"}, "MAILTO:jane_doe@host.com", RiCal::PropertyValue::CalAddress)
172
+ #TO-DO need to handle param values
173
+
174
+ #RFC 2445 section 4.8.4.2 CONTACT p104
175
+ describe_multi_property("VEVENT", "CONTACT", {"X-FOO" => "BAR"}, "Contact info")
176
+
177
+ #RFC 2445 section 4.8.4.3 ORGANIZER p106
178
+ describe_property("VEVENT", "ORGANIZER", {"X-FOO" => "BAR", "CN" => "John Smith"}, "MAILTO:jsmith@host1.com", RiCal::PropertyValue::CalAddress)
179
+ #TO-DO need to handle param values
180
+
181
+ #RFC 2445 section 4.8.4.4 RECURRENCE-ID p107
182
+ describe_property("VEVENT", "RECURRENCE-ID", {"X-FOO" => "BAR", "VALUE" => "DATE"}, "19970714", RiCal::PropertyValue::Date)
183
+ describe_property("VEVENT", "RECURRENCE-ID", {"X-FOO" => "BAR", "VALUE" => "DATE-TIME"}, "19970714T235959Z", RiCal::PropertyValue::DateTime)
184
+ #TO-DO need to handle parameters
185
+
186
+ #RFC 2445 section 4.8.4.5 RELATED-TO p109
187
+ describe_multi_property("VEVENT", "RELATED-TO", {"X-FOO" => "BAR"}, "<jsmith.part7.19960817T083000.xyzMail@host3.com")
188
+
189
+ #RFC 2445 section 4.8.4.6 URL p110
190
+ describe_property("VEVENT", "URL", {"X-FOO" => "BAR"}, "http://abc.com/pub/calendars/jsmith/mytime.ics", RiCal::PropertyValue::Uri)
191
+
192
+ #RFC 2445 section 4.8.4.7 UID p111
193
+ describe_property("VEVENT", "UID", {"X-FOO" => "BAR"}, "19960401T080045Z-4000F192713-0052@host1.com")
194
+
195
+ #RFC 2445 section 4.8.5.1 EXDATE p112
196
+ describe_multi_property("VEVENT", "EXDATE", {"X-FOO" => "BAR"}, %w{19960402T010000Z 19960403T010000Z 19960404T010000Z}, RiCal::PropertyValue::OccurrenceList)
197
+
198
+ #RFC 2445 section 4.8.5.2 EXRULE p114
199
+ describe_multi_property("VEVENT", "EXRULE", {"X-FOO" => "BAR"}, "FREQ=DAILY;COUNT=10", RiCal::PropertyValue::RecurrenceRule)
200
+
201
+ #RFC 2445 section 4.8.5.3 RDATE p115
202
+ describe_multi_property("VEVENT", "RDATE", {"X-FOO" => "BAR"}, %w{19960402T010000Z 19960403T010000Z 19960404T010000Z}, RiCal::PropertyValue::OccurrenceList)
203
+
204
+ #RFC 2445 section 4.8.5.2 RRULE p117
205
+ describe_multi_property("VEVENT", "RRULE", {"X-FOO" => "BAR"}, "FREQ=DAILY;COUNT=10", RiCal::PropertyValue::RecurrenceRule)
206
+
207
+ #RFC 2445 section 4.8.7.1 CREATED p129
208
+ describe_property("VEVENT", "CREATED", {"X-FOO" => "BAR"}, "19960329T133000Z", RiCal::PropertyValue::DateTime)
209
+
210
+ #RFC 2445 section 4.8.7.2 DTSTAMP p129
211
+ describe_property("VEVENT", "DTSTAMP", {"X-FOO" => "BAR"}, "19971210T080000Z", RiCal::PropertyValue::DateTime)
212
+
213
+ #RFC 2445 section 4.8.7.3 LAST-MODIFIED p131
214
+ describe_property("VEVENT", "LAST-MODIFIED", {"X-FOO" => "BAR"}, "19960817T133000Z", RiCal::PropertyValue::DateTime)
215
+
216
+ #RFC 2445 section 4.8.7.3 SEQUENCE p131
217
+ describe_property("VEVENT", "SEQUENCE", {"X-FOO" => "BAR"}, 2, RiCal::PropertyValue::Integer)
218
+
219
+ #RFC 2445 section 4.8.8.2 REQUEST-STATUS p131
220
+ describe_multi_property("VEVENT", "REQUEST-STATUS", {"X-FOO" => "BAR"}, "2.0;Success")
221
+ end
222
+
223
+ describe "parsing a calendar" do
224
+
225
+ it "should parse a calendar" do
226
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VCALENDAR"))
227
+ RiCal::Component::Calendar.should_receive(:from_parser).with(parser, nil)
228
+ parser.parse
229
+ end
230
+
231
+ it "should parse a calendar and return an array of 1 Calendar" do
232
+ cal = RiCal::Parser.parse(StringIO.new("BEGIN:VCALENDAR\nEND:VCALENDAR")).first
233
+ cal.should be_kind_of(RiCal::Component::Calendar)
234
+ end
235
+
236
+ # RFC 2445, section 4.6 section 4.7.1, pp 73-74
237
+ describe_property("VCALENDAR", "CALSCALE", {"X-FOO" => "Y"}, "GREGORIAN")
238
+
239
+ # RFC 2445, section 4.6 section 4.7.2, pp 74-75
240
+ describe_named_property("VCALENDAR", "METHOD", 'icalendar_method', {"X-FOO" => "Y"}, "REQUEST", false)
241
+
242
+ # RFC 2445, section 4.6, pp 51-52, section 4.7.3, p 75-76
243
+ describe_property("VCALENDAR", "PRODID", {"X-FOO" => "Y"}, "-//ABC CORPORATION//NONSGML/ My Product//EN")
244
+
245
+ # RFC 2445, section 4.6, pp 51-52, section 4.7.3, p 75-76
246
+ describe_property("VCALENDAR", "VERSION", {"X-FOO" => "Y"}, "2.0")
247
+
248
+
249
+ # RFC2445 p 51
250
+ it "should parse a calendar with an X property" do
251
+ lambda {RiCal::Parser.parse(StringIO.new("BEGIN:VCALENDAR\nX-PROP;X-FOO=Y:BAR\nEND:VCALENDAR"))}.should_not raise_error
252
+ end
253
+
254
+ describe 'the X property' do
255
+ before(:each) do
256
+ @x_props = RiCal::Parser.parse(StringIO.new("BEGIN:VCALENDAR\nX-PROP;X-FOO=Y:BAR\nEND:VCALENDAR")).first.x_properties
257
+ @x_prop = @x_props["X-PROP"]
258
+ end
259
+
260
+ it "should be a PropertyValue::Text" do
261
+ @x_prop.should be_kind_of(RiCal::PropertyValue::Text)
262
+ end
263
+
264
+ it "should have the right value" do
265
+ @x_prop.value.should == "BAR"
266
+ end
267
+
268
+ it "should have the right parameters" do
269
+ @x_prop.params.should == {"X-FOO" => "Y"}
270
+ end
271
+ end
272
+ end
273
+
274
+ it "should parse a to-do" do
275
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VTODO"))
276
+ RiCal::Component::Todo.should_receive(:from_parser).with(parser, nil)
277
+ parser.parse
278
+ end
279
+
280
+ it "should parse a journal entry" do
281
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VJOURNAL"))
282
+ RiCal::Component::Journal.should_receive(:from_parser).with(parser, nil)
283
+ parser.parse
284
+ end
285
+
286
+ it "should parse a free/busy component" do
287
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VFREEBUSY"))
288
+ RiCal::Component::Freebusy.should_receive(:from_parser).with(parser, nil)
289
+ parser.parse
290
+ end
291
+
292
+ it "should parse a timezone component" do
293
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VTIMEZONE"))
294
+ RiCal::Component::Timezone.should_receive(:from_parser).with(parser, nil)
295
+ parser.parse
296
+ end
297
+
298
+ it "should parse an alarm component" do
299
+ parser = RiCal::Parser.new(StringIO.new("BEGIN:VALARM"))
300
+ RiCal::Component::Alarm.should_receive(:from_parser).with(parser, nil)
301
+ parser.parse
302
+ end
303
+ end
304
+ end
@@ -0,0 +1,22 @@
1
+ #- ©2009 Rick DeNatale
2
+ #- All rights reserved
3
+
4
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
+
6
+ describe RiCal::PropertyValue::Date do
7
+ describe ".advance" do
8
+ it "should advance by one week if passed :days => 7" do
9
+ dt1 = RiCal::PropertyValue::Date.new(nil, :value => "20050131")
10
+ dt2 = RiCal::PropertyValue::Date.new(nil, :value => "20050207")
11
+ dt1.advance(:days => 7).should == dt2
12
+ end
13
+
14
+ describe ".==" do
15
+ it "should return true for two instances representing the same date" do
16
+ dt1 = RiCal::PropertyValue::Date.new(nil, :value => DateTime.parse("20050131T010000"))
17
+ dt2 = RiCal::PropertyValue::Date.new(nil, :value => DateTime.parse("20050131T010001"))
18
+ dt1.should == dt2
19
+ end
20
+ end
21
+ end
22
+ end