feedtools 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -0
- data/lib/feed_tools.rb +721 -209
- data/rakefile +1 -1
- data/test/cdf_test.rb +121 -0
- data/test/helper_test.rb +3 -1
- data/test/rss_test.rb +480 -52
- metadata +3 -2
data/rakefile
CHANGED
data/test/cdf_test.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'feed_tools'
|
3
|
+
|
4
|
+
class CdfTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
FeedTools.tidy_enabled = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_feed_title
|
10
|
+
feed = FeedTools::Feed.new
|
11
|
+
feed.xml_data = <<-FEED
|
12
|
+
<CHANNEL>
|
13
|
+
<TITLE>Example Title</TITLE>
|
14
|
+
</CHANNEL>
|
15
|
+
FEED
|
16
|
+
assert_equal("Example Title", feed.title)
|
17
|
+
assert_equal(false, feed.bozo?)
|
18
|
+
feed = FeedTools::Feed.open(
|
19
|
+
'http://feedparser.org/tests/wellformed/cdf/channel_title.xml')
|
20
|
+
assert_equal("Example feed", feed.title)
|
21
|
+
assert_equal(false, feed.bozo?)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_feed_description
|
25
|
+
feed = FeedTools::Feed.open(
|
26
|
+
'http://feedparser.org/tests/wellformed/cdf/' +
|
27
|
+
'channel_abstract_map_description.xml')
|
28
|
+
assert_equal("Example description", feed.description)
|
29
|
+
assert_equal(false, feed.bozo?)
|
30
|
+
feed = FeedTools::Feed.open(
|
31
|
+
'http://feedparser.org/tests/wellformed/cdf/' +
|
32
|
+
'channel_abstract_map_tagline.xml')
|
33
|
+
assert_equal("Example description", feed.tagline)
|
34
|
+
assert_equal(false, feed.bozo?)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_feed_href
|
38
|
+
feed = FeedTools::Feed.new
|
39
|
+
feed.xml_data = <<-FEED
|
40
|
+
<CHANNEL HREF="http://www.example.com/">
|
41
|
+
</CHANNEL>
|
42
|
+
FEED
|
43
|
+
assert_equal("http://www.example.com/", feed.link)
|
44
|
+
assert_equal(false, feed.bozo?)
|
45
|
+
feed = FeedTools::Feed.open(
|
46
|
+
'http://feedparser.org/tests/wellformed/cdf/channel_href_map_link.xml')
|
47
|
+
assert_equal("http://www.example.org/", feed.link)
|
48
|
+
assert_equal(false, feed.bozo?)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_feed_links
|
52
|
+
# TODO
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_feed_images
|
56
|
+
feed = FeedTools::Feed.new
|
57
|
+
feed.xml_data = <<-FEED
|
58
|
+
<CHANNEL>
|
59
|
+
<LOGO HREF="http://www.example.com/exampleicon.gif" STYLE="ICON" />
|
60
|
+
<LOGO HREF="http://www.example.com/exampleimage.gif" STYLE="IMAGE" />
|
61
|
+
</CHANNEL>
|
62
|
+
FEED
|
63
|
+
assert_equal("http://www.example.com/exampleicon.gif", feed.images[0].url)
|
64
|
+
assert_equal("icon", feed.images[0].style)
|
65
|
+
assert_equal("http://www.example.com/exampleimage.gif", feed.images[1].url)
|
66
|
+
assert_equal("image", feed.images[1].style)
|
67
|
+
assert_equal(false, feed.bozo?)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_feed_item_title
|
71
|
+
feed = FeedTools::Feed.open(
|
72
|
+
'http://feedparser.org/tests/wellformed/cdf/item_title.xml')
|
73
|
+
assert_equal("Example item", feed.items.first.title)
|
74
|
+
assert_equal(false, feed.bozo?)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_feed_item_description
|
78
|
+
feed = FeedTools::Feed.open(
|
79
|
+
'http://feedparser.org/tests/wellformed/cdf/' +
|
80
|
+
'item_abstract_map_description.xml')
|
81
|
+
assert_equal("Example description", feed.items.first.description)
|
82
|
+
assert_equal(false, feed.bozo?)
|
83
|
+
feed = FeedTools::Feed.open(
|
84
|
+
'http://feedparser.org/tests/wellformed/cdf/' +
|
85
|
+
'item_abstract_map_summary.xml')
|
86
|
+
assert_equal("Example description", feed.items.first.summary)
|
87
|
+
assert_equal(false, feed.bozo?)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_feed_item_href
|
91
|
+
feed = FeedTools::Feed.open(
|
92
|
+
'http://feedparser.org/tests/wellformed/cdf/item_href_map_link.xml')
|
93
|
+
assert_equal("http://www.example.org/", feed.items.first.link)
|
94
|
+
assert_equal(false, feed.bozo?)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_feed_item_links
|
98
|
+
# TODO
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_feed_item_images
|
102
|
+
feed = FeedTools::Feed.new
|
103
|
+
feed.xml_data = <<-FEED
|
104
|
+
<CHANNEL>
|
105
|
+
<ITEM HREF="http://www.example.com/item">
|
106
|
+
<LOGO HREF="http://www.example.com/exampleicon.gif" STYLE="ICON" />
|
107
|
+
<LOGO HREF="http://www.example.com/exampleimage.gif" STYLE="IMAGE" />
|
108
|
+
</ITEM>
|
109
|
+
</CHANNEL>
|
110
|
+
FEED
|
111
|
+
assert_equal("http://www.example.com/item",
|
112
|
+
feed.items.first.link)
|
113
|
+
assert_equal("http://www.example.com/exampleicon.gif",
|
114
|
+
feed.items.first.images[0].url)
|
115
|
+
assert_equal("icon", feed.items.first.images[0].style)
|
116
|
+
assert_equal("http://www.example.com/exampleimage.gif",
|
117
|
+
feed.items.first.images[1].url)
|
118
|
+
assert_equal("image", feed.items.first.images[1].style)
|
119
|
+
assert_equal(false, feed.bozo?)
|
120
|
+
end
|
121
|
+
end
|
data/test/helper_test.rb
CHANGED
data/test/rss_test.rb
CHANGED
@@ -29,11 +29,16 @@ class RssTest < Test::Unit::TestCase
|
|
29
29
|
'http://feedparser.org/tests/wellformed/rss/channel_title_lt.xml')
|
30
30
|
assert_equal("1 < 2", feed.title)
|
31
31
|
assert_equal(false, feed.bozo?)
|
32
|
+
feed = FeedTools::Feed.open(
|
33
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_title.xml')
|
34
|
+
assert_equal("Example title", feed.title)
|
35
|
+
assert_equal(false, feed.bozo?)
|
32
36
|
end
|
33
37
|
|
34
38
|
def test_feed_description
|
35
39
|
feed = FeedTools::Feed.open(
|
36
40
|
'http://feedparser.org/tests/wellformed/rss/channel_description.xml')
|
41
|
+
assert_equal(nil, feed.title)
|
37
42
|
assert_equal("Example description", feed.description)
|
38
43
|
assert_equal(false, feed.bozo?)
|
39
44
|
feed = FeedTools::Feed.open(
|
@@ -59,6 +64,13 @@ class RssTest < Test::Unit::TestCase
|
|
59
64
|
assert_equal(false, feed.bozo?)
|
60
65
|
end
|
61
66
|
|
67
|
+
def test_feed_link
|
68
|
+
feed = FeedTools::Feed.open(
|
69
|
+
'http://feedparser.org/tests/wellformed/rss/channel_link.xml')
|
70
|
+
assert_equal('http://example.com/', feed.link)
|
71
|
+
assert_equal(false, feed.bozo?)
|
72
|
+
end
|
73
|
+
|
62
74
|
def test_feed_generator
|
63
75
|
feed = FeedTools::Feed.open(
|
64
76
|
'http://feedparser.org/tests/wellformed/rss/channel_generator.xml')
|
@@ -80,58 +92,6 @@ class RssTest < Test::Unit::TestCase
|
|
80
92
|
assert_equal(false, feed.bozo?)
|
81
93
|
end
|
82
94
|
|
83
|
-
def test_item_content
|
84
|
-
feed = FeedTools::Feed.open(
|
85
|
-
'http://feedparser.org/tests/wellformed/rss/item_content_encoded.xml')
|
86
|
-
assert_equal('<p>Example content</p>', feed.entries.first.content)
|
87
|
-
assert_equal(false, feed.bozo?)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_item_description
|
91
|
-
feed = FeedTools::Feed.open(
|
92
|
-
'http://feedparser.org/tests/wellformed/rss/item_description.xml')
|
93
|
-
assert_equal('Example description', feed.entries.first.description)
|
94
|
-
assert_equal(false, feed.bozo?)
|
95
|
-
feed = FeedTools::Feed.open(
|
96
|
-
'http://feedparser.org/tests/wellformed/rss/' +
|
97
|
-
'item_description_escaped_markup.xml')
|
98
|
-
assert_equal('<p>Example description</p>', feed.entries.first.description)
|
99
|
-
assert_equal(false, feed.bozo?)
|
100
|
-
feed = FeedTools::Feed.open(
|
101
|
-
'http://feedparser.org/tests/wellformed/rss/' +
|
102
|
-
'item_description_map_summary.xml')
|
103
|
-
assert_equal('Example description', feed.entries.first.description)
|
104
|
-
assert_equal(false, feed.bozo?)
|
105
|
-
feed = FeedTools::Feed.open(
|
106
|
-
'http://feedparser.org/tests/wellformed/rss/' +
|
107
|
-
'item_description_naked_markup.xml')
|
108
|
-
assert_equal('<p>Example description</p>', feed.entries.first.description)
|
109
|
-
assert_equal(false, feed.bozo?)
|
110
|
-
feed = FeedTools::Feed.open(
|
111
|
-
'http://feedparser.org/tests/wellformed/rss/' +
|
112
|
-
'item_description_not_a_doctype.xml')
|
113
|
-
assert_equal('<!\' <a href="foo">', feed.entries.first.description)
|
114
|
-
assert_equal(false, feed.bozo?)
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_item_guid
|
118
|
-
feed = FeedTools::Feed.open(
|
119
|
-
'http://feedparser.org/tests/wellformed/rss/item_guid.xml')
|
120
|
-
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
121
|
-
assert_equal(false, feed.bozo?)
|
122
|
-
feed = FeedTools::Feed.open(
|
123
|
-
'http://feedparser.org/tests/wellformed/rss/' +
|
124
|
-
'item_guid_conflict_link.xml')
|
125
|
-
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
126
|
-
assert_equal('http://link.example.com/', feed.entries.first.link)
|
127
|
-
assert_equal(false, feed.bozo?)
|
128
|
-
feed = FeedTools::Feed.open(
|
129
|
-
'http://feedparser.org/tests/wellformed/rss/item_guid_guidislink.xml')
|
130
|
-
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
131
|
-
assert_equal('http://guid.example.com/', feed.entries.first.link)
|
132
|
-
assert_equal(false, feed.bozo?)
|
133
|
-
end
|
134
|
-
|
135
95
|
def test_feed_author
|
136
96
|
feed = FeedTools::Feed.open(
|
137
97
|
'http://feedparser.org/tests/wellformed/rss/channel_author.xml')
|
@@ -186,6 +146,21 @@ class RssTest < Test::Unit::TestCase
|
|
186
146
|
assert_equal("me@example.com", feed.author.email)
|
187
147
|
assert_equal(nil, feed.author.url)
|
188
148
|
assert_equal(false, feed.bozo?)
|
149
|
+
feed = FeedTools::Feed.open(
|
150
|
+
'http://feedparser.org/tests/wellformed/rss/channel_managingEditor.xml')
|
151
|
+
assert_equal("Example editor", feed.author.raw)
|
152
|
+
assert_equal("Example editor", feed.author.name)
|
153
|
+
assert_equal(nil, feed.author.email)
|
154
|
+
assert_equal(nil, feed.author.url)
|
155
|
+
assert_equal(false, feed.bozo?)
|
156
|
+
feed = FeedTools::Feed.open(
|
157
|
+
'http://feedparser.org/tests/wellformed/rss' +
|
158
|
+
'/channel_managingEditor_map_author_detail_email.xml')
|
159
|
+
assert_equal("Example editor (me@example.com)", feed.author.raw)
|
160
|
+
assert_equal("Example editor", feed.author.name)
|
161
|
+
assert_equal("me@example.com", feed.author.email)
|
162
|
+
assert_equal(nil, feed.author.url)
|
163
|
+
assert_equal(false, feed.bozo?)
|
189
164
|
end
|
190
165
|
|
191
166
|
def test_feed_publisher
|
@@ -204,6 +179,68 @@ class RssTest < Test::Unit::TestCase
|
|
204
179
|
assert_equal("me@example.com", feed.publisher.email)
|
205
180
|
assert_equal(nil, feed.publisher.url)
|
206
181
|
assert_equal(false, feed.bozo?)
|
182
|
+
feed = FeedTools::Feed.open(
|
183
|
+
'http://feedparser.org/tests/wellformed/rss/channel_webMaster.xml')
|
184
|
+
assert_equal("Example editor", feed.publisher.raw)
|
185
|
+
assert_equal("Example editor", feed.publisher.name)
|
186
|
+
assert_equal(nil, feed.publisher.email)
|
187
|
+
assert_equal(nil, feed.publisher.url)
|
188
|
+
assert_equal(false, feed.bozo?)
|
189
|
+
feed = FeedTools::Feed.open(
|
190
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
191
|
+
'channel_webMaster_email.xml')
|
192
|
+
assert_equal("Example editor (me@example.com)", feed.publisher.raw)
|
193
|
+
assert_equal("Example editor", feed.publisher.name)
|
194
|
+
assert_equal("me@example.com", feed.publisher.email)
|
195
|
+
assert_equal(nil, feed.publisher.url)
|
196
|
+
assert_equal(false, feed.bozo?)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_feed_categories
|
200
|
+
feed = FeedTools::Feed.open(
|
201
|
+
'http://feedparser.org/tests/wellformed/rss/channel_category.xml')
|
202
|
+
assert_equal(1, feed.categories.size)
|
203
|
+
assert_equal("Example category", feed.categories.first.value)
|
204
|
+
assert_equal(false, feed.bozo?)
|
205
|
+
feed = FeedTools::Feed.open(
|
206
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
207
|
+
'channel_category_domain.xml')
|
208
|
+
assert_equal(1, feed.categories.size)
|
209
|
+
assert_equal("Example category", feed.categories.first.value)
|
210
|
+
assert_equal("http://www.example.com/", feed.categories.first.domain)
|
211
|
+
assert_equal(false, feed.bozo?)
|
212
|
+
feed = FeedTools::Feed.open(
|
213
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
214
|
+
'channel_category_multiple.xml')
|
215
|
+
assert_equal(2, feed.categories.size)
|
216
|
+
assert_equal("Example category 1", feed.categories[0].value)
|
217
|
+
assert_equal("http://www.example.com/1", feed.categories[0].domain)
|
218
|
+
assert_equal("Example category 2", feed.categories[1].value)
|
219
|
+
assert_equal("http://www.example.com/2", feed.categories[1].domain)
|
220
|
+
assert_equal(false, feed.bozo?)
|
221
|
+
feed = FeedTools::Feed.open(
|
222
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
223
|
+
'channel_category_multiple_2.xml')
|
224
|
+
assert_equal(2, feed.categories.size)
|
225
|
+
assert_equal("Example category 1", feed.categories[0].value)
|
226
|
+
assert_equal(nil, feed.categories[0].domain)
|
227
|
+
assert_equal("Example category 2", feed.categories[1].value)
|
228
|
+
assert_equal(nil, feed.categories[1].domain)
|
229
|
+
assert_equal(false, feed.bozo?)
|
230
|
+
feed = FeedTools::Feed.open(
|
231
|
+
'http://feedparser.org/tests/wellformed/rss/channel_dc_subject.xml')
|
232
|
+
assert_equal(1, feed.categories.size)
|
233
|
+
assert_equal("Example category", feed.categories.first.value)
|
234
|
+
assert_equal(false, feed.bozo?)
|
235
|
+
feed = FeedTools::Feed.open(
|
236
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
237
|
+
'channel_dc_subject_multiple.xml')
|
238
|
+
assert_equal(2, feed.categories.size)
|
239
|
+
assert_equal("Example category 1", feed.categories[0].value)
|
240
|
+
assert_equal(nil, feed.categories[0].domain)
|
241
|
+
assert_equal("Example category 2", feed.categories[1].value)
|
242
|
+
assert_equal(nil, feed.categories[1].domain)
|
243
|
+
assert_equal(false, feed.bozo?)
|
207
244
|
end
|
208
245
|
|
209
246
|
def test_feed_copyright
|
@@ -227,4 +264,395 @@ class RssTest < Test::Unit::TestCase
|
|
227
264
|
assert_equal("xml-rpc", feed.cloud.protocol)
|
228
265
|
assert_equal(false, feed.bozo?)
|
229
266
|
end
|
267
|
+
|
268
|
+
def test_feed_time_to_live
|
269
|
+
feed = FeedTools::Feed.open(
|
270
|
+
'http://feedparser.org/tests/wellformed/rss/channel_ttl.xml')
|
271
|
+
assert_equal(1.hour, feed.time_to_live)
|
272
|
+
assert_equal(false, feed.bozo?)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_feed_images
|
276
|
+
feed = FeedTools::Feed.open(
|
277
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
278
|
+
'channel_image_description.xml')
|
279
|
+
assert_equal("Sample image", feed.images.first.title)
|
280
|
+
assert_equal("Available in Netscape RSS 0.91",
|
281
|
+
feed.images.first.description)
|
282
|
+
assert_equal("http://example.org/url", feed.images.first.url)
|
283
|
+
assert_equal("http://example.org/link", feed.images.first.link)
|
284
|
+
assert_equal(80, feed.images.first.width)
|
285
|
+
assert_equal(15, feed.images.first.height)
|
286
|
+
assert_equal(false, feed.bozo?)
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_feed_text_input
|
290
|
+
feed = FeedTools::Feed.open(
|
291
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
292
|
+
'channel_textInput_description.xml')
|
293
|
+
assert_equal("Real title", feed.title)
|
294
|
+
assert_equal("Real description", feed.description)
|
295
|
+
assert_equal("textInput title", feed.text_input.title)
|
296
|
+
assert_equal("textInput description", feed.text_input.description)
|
297
|
+
assert_equal(nil, feed.text_input.link)
|
298
|
+
assert_equal(nil, feed.text_input.name)
|
299
|
+
assert_equal(false, feed.bozo?)
|
300
|
+
feed = FeedTools::Feed.open(
|
301
|
+
'http://feedparser.org/tests/wellformed/rss/channel_textInput_link.xml')
|
302
|
+
assert_equal("http://channel.example.com/", feed.link)
|
303
|
+
assert_equal("http://textinput.example.com/", feed.text_input.link)
|
304
|
+
assert_equal(nil, feed.text_input.title)
|
305
|
+
assert_equal(nil, feed.text_input.description)
|
306
|
+
assert_equal(nil, feed.text_input.name)
|
307
|
+
assert_equal(false, feed.bozo?)
|
308
|
+
feed = FeedTools::Feed.open(
|
309
|
+
'http://feedparser.org/tests/wellformed/rss/channel_textInput_name.xml')
|
310
|
+
assert_equal("textinput name", feed.text_input.name)
|
311
|
+
assert_equal(nil, feed.text_input.title)
|
312
|
+
assert_equal(nil, feed.text_input.description)
|
313
|
+
assert_equal(nil, feed.text_input.link)
|
314
|
+
assert_equal(false, feed.bozo?)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_item_title
|
318
|
+
feed = FeedTools::Feed.open(
|
319
|
+
'http://feedparser.org/tests/wellformed/rss/item_title.xml')
|
320
|
+
assert_equal("Item 1 title", feed.items.first.title)
|
321
|
+
assert_equal(nil, feed.items.first.description)
|
322
|
+
assert_equal(false, feed.bozo?)
|
323
|
+
feed = FeedTools::Feed.open(
|
324
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_title.xml')
|
325
|
+
assert_equal("Example title", feed.items.first.title)
|
326
|
+
assert_equal(nil, feed.items.first.description)
|
327
|
+
assert_equal(false, feed.bozo?)
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_item_description
|
331
|
+
feed = FeedTools::Feed.open(
|
332
|
+
'http://feedparser.org/tests/wellformed/rss/item_description.xml')
|
333
|
+
assert_equal('Example description', feed.entries.first.description)
|
334
|
+
assert_equal(nil, feed.entries.first.title)
|
335
|
+
assert_equal(false, feed.bozo?)
|
336
|
+
feed = FeedTools::Feed.open(
|
337
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
338
|
+
'item_description_escaped_markup.xml')
|
339
|
+
assert_equal('<p>Example description</p>', feed.entries.first.description)
|
340
|
+
assert_equal(nil, feed.entries.first.title)
|
341
|
+
assert_equal(false, feed.bozo?)
|
342
|
+
feed = FeedTools::Feed.open(
|
343
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
344
|
+
'item_description_map_summary.xml')
|
345
|
+
assert_equal('Example description', feed.entries.first.description)
|
346
|
+
assert_equal(nil, feed.entries.first.title)
|
347
|
+
assert_equal(false, feed.bozo?)
|
348
|
+
feed = FeedTools::Feed.open(
|
349
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
350
|
+
'item_description_naked_markup.xml')
|
351
|
+
assert_equal('<p>Example description</p>', feed.entries.first.description)
|
352
|
+
assert_equal(nil, feed.entries.first.title)
|
353
|
+
assert_equal(false, feed.bozo?)
|
354
|
+
feed = FeedTools::Feed.open(
|
355
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
356
|
+
'item_description_not_a_doctype.xml')
|
357
|
+
assert_equal('<!\' <a href="foo">', feed.entries.first.description)
|
358
|
+
assert_equal(nil, feed.entries.first.title)
|
359
|
+
assert_equal(false, feed.bozo?)
|
360
|
+
feed = FeedTools::Feed.open(
|
361
|
+
'http://feedparser.org/tests/wellformed/rss/item_content_encoded.xml')
|
362
|
+
assert_equal('<p>Example content</p>', feed.entries.first.content)
|
363
|
+
assert_equal(nil, feed.entries.first.title)
|
364
|
+
assert_equal(false, feed.bozo?)
|
365
|
+
feed = FeedTools::Feed.open(
|
366
|
+
'http://feedparser.org/tests/wellformed/rss/item_fullitem.xml')
|
367
|
+
assert_equal('<p>Example content</p>', feed.entries.first.content)
|
368
|
+
assert_equal(nil, feed.entries.first.title)
|
369
|
+
assert_equal(false, feed.bozo?)
|
370
|
+
feed = FeedTools::Feed.open(
|
371
|
+
'http://feedparser.org/tests/wellformed/rss/item_xhtml_body.xml')
|
372
|
+
assert_equal('<p>Example content</p>', feed.entries.first.description)
|
373
|
+
assert_equal(nil, feed.entries.first.title)
|
374
|
+
assert_equal(false, feed.bozo?)
|
375
|
+
end
|
376
|
+
|
377
|
+
def test_item_link
|
378
|
+
feed = FeedTools::Feed.open(
|
379
|
+
'http://feedparser.org/tests/wellformed/rss/item_link.xml')
|
380
|
+
assert_equal('http://example.com/', feed.entries.first.link)
|
381
|
+
assert_equal(nil, feed.entries.first.title)
|
382
|
+
assert_equal(nil, feed.entries.first.description)
|
383
|
+
assert_equal(false, feed.bozo?)
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_item_guid
|
387
|
+
feed = FeedTools::Feed.open(
|
388
|
+
'http://feedparser.org/tests/wellformed/rss/item_guid.xml')
|
389
|
+
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
390
|
+
assert_equal(false, feed.bozo?)
|
391
|
+
feed = FeedTools::Feed.open(
|
392
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
393
|
+
'item_guid_conflict_link.xml')
|
394
|
+
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
395
|
+
assert_equal('http://link.example.com/', feed.entries.first.link)
|
396
|
+
assert_equal(false, feed.bozo?)
|
397
|
+
feed = FeedTools::Feed.open(
|
398
|
+
'http://feedparser.org/tests/wellformed/rss/item_guid_guidislink.xml')
|
399
|
+
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
400
|
+
assert_equal('http://guid.example.com/', feed.entries.first.link)
|
401
|
+
assert_equal(false, feed.bozo?)
|
402
|
+
feed = FeedTools::Feed.open(
|
403
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
404
|
+
'item_guid_isPermaLink_map_link.xml')
|
405
|
+
assert_equal('http://guid.example.com/', feed.entries.first.guid)
|
406
|
+
assert_equal('http://guid.example.com/', feed.entries.first.link)
|
407
|
+
assert_equal(false, feed.bozo?)
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_item_author
|
411
|
+
feed = FeedTools::Feed.open(
|
412
|
+
'http://feedparser.org/tests/wellformed/rss/item_author.xml')
|
413
|
+
assert_equal("Example editor", feed.items.first.author.raw)
|
414
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
415
|
+
assert_equal(nil, feed.items.first.author.email)
|
416
|
+
assert_equal(nil, feed.items.first.author.url)
|
417
|
+
assert_equal(false, feed.bozo?)
|
418
|
+
feed = FeedTools::Feed.open(
|
419
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
420
|
+
'item_author_map_author_detail_email.xml')
|
421
|
+
assert_equal("Example editor (me@example.com)",
|
422
|
+
feed.items.first.author.raw)
|
423
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
424
|
+
assert_equal("me@example.com", feed.items.first.author.email)
|
425
|
+
assert_equal(nil, feed.items.first.author.url)
|
426
|
+
assert_equal(false, feed.bozo?)
|
427
|
+
feed = FeedTools::Feed.open(
|
428
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_author.xml')
|
429
|
+
assert_equal("Example editor", feed.items.first.author.raw)
|
430
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
431
|
+
assert_equal(nil, feed.items.first.author.email)
|
432
|
+
assert_equal(nil, feed.items.first.author.url)
|
433
|
+
assert_equal(false, feed.bozo?)
|
434
|
+
feed = FeedTools::Feed.open(
|
435
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
436
|
+
'item_dc_author_map_author_detail_email.xml')
|
437
|
+
assert_equal("Example editor (me@example.com)",
|
438
|
+
feed.items.first.author.raw)
|
439
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
440
|
+
assert_equal("me@example.com", feed.items.first.author.email)
|
441
|
+
assert_equal(nil, feed.items.first.author.url)
|
442
|
+
assert_equal(false, feed.bozo?)
|
443
|
+
feed = FeedTools::Feed.open(
|
444
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_creator.xml')
|
445
|
+
assert_equal("Example editor", feed.items.first.author.raw)
|
446
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
447
|
+
assert_equal(nil, feed.items.first.author.email)
|
448
|
+
assert_equal(nil, feed.items.first.author.url)
|
449
|
+
assert_equal(false, feed.bozo?)
|
450
|
+
feed = FeedTools::Feed.open(
|
451
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
452
|
+
'item_dc_creator_map_author_detail_email.xml')
|
453
|
+
assert_equal("Example editor (me@example.com)",
|
454
|
+
feed.items.first.author.raw)
|
455
|
+
assert_equal("Example editor", feed.items.first.author.name)
|
456
|
+
assert_equal("me@example.com", feed.items.first.author.email)
|
457
|
+
assert_equal(nil, feed.items.first.author.url)
|
458
|
+
assert_equal(false, feed.bozo?)
|
459
|
+
end
|
460
|
+
|
461
|
+
def test_item_publisher
|
462
|
+
feed = FeedTools::Feed.open(
|
463
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_publisher.xml')
|
464
|
+
assert_equal("Example editor", feed.items.first.publisher.raw)
|
465
|
+
assert_equal("Example editor", feed.items.first.publisher.name)
|
466
|
+
assert_equal(nil, feed.items.first.publisher.email)
|
467
|
+
assert_equal(nil, feed.items.first.publisher.url)
|
468
|
+
assert_equal(false, feed.bozo?)
|
469
|
+
feed = FeedTools::Feed.open(
|
470
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
471
|
+
'item_dc_publisher_email.xml')
|
472
|
+
assert_equal("Example editor (me@example.com)", feed.items.first.publisher.raw)
|
473
|
+
assert_equal("Example editor", feed.items.first.publisher.name)
|
474
|
+
assert_equal("me@example.com", feed.items.first.publisher.email)
|
475
|
+
assert_equal(nil, feed.items.first.publisher.url)
|
476
|
+
assert_equal(false, feed.bozo?)
|
477
|
+
end
|
478
|
+
|
479
|
+
def test_item_categories
|
480
|
+
feed = FeedTools::Feed.open(
|
481
|
+
'http://feedparser.org/tests/wellformed/rss/item_category.xml')
|
482
|
+
assert_equal(1, feed.items.first.categories.size)
|
483
|
+
assert_equal("Example category", feed.items.first.categories.first.value)
|
484
|
+
assert_equal(false, feed.bozo?)
|
485
|
+
feed = FeedTools::Feed.open(
|
486
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
487
|
+
'item_category_domain.xml')
|
488
|
+
assert_equal(1, feed.items.first.categories.size)
|
489
|
+
assert_equal("Example category", feed.items.first.categories.first.value)
|
490
|
+
assert_equal("http://www.example.com/",
|
491
|
+
feed.items.first.categories.first.domain)
|
492
|
+
assert_equal(false, feed.bozo?)
|
493
|
+
feed = FeedTools::Feed.open(
|
494
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
495
|
+
'item_category_multiple.xml')
|
496
|
+
assert_equal(2, feed.items.first.categories.size)
|
497
|
+
assert_equal("Example category 1",
|
498
|
+
feed.items.first.categories[0].value)
|
499
|
+
assert_equal("http://www.example.com/1",
|
500
|
+
feed.items.first.categories[0].domain)
|
501
|
+
assert_equal("Example category 2",
|
502
|
+
feed.items.first.categories[1].value)
|
503
|
+
assert_equal("http://www.example.com/2",
|
504
|
+
feed.items.first.categories[1].domain)
|
505
|
+
assert_equal(false, feed.bozo?)
|
506
|
+
feed = FeedTools::Feed.open(
|
507
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
508
|
+
'item_category_multiple_2.xml')
|
509
|
+
assert_equal(2, feed.items.first.categories.size)
|
510
|
+
assert_equal("Example category 1",
|
511
|
+
feed.items.first.categories[0].value)
|
512
|
+
assert_equal(nil, feed.items.first.categories[0].domain)
|
513
|
+
assert_equal("Example category 2",
|
514
|
+
feed.items.first.categories[1].value)
|
515
|
+
assert_equal(nil, feed.items.first.categories[1].domain)
|
516
|
+
assert_equal(false, feed.bozo?)
|
517
|
+
feed = FeedTools::Feed.open(
|
518
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_subject.xml')
|
519
|
+
assert_equal(1, feed.items.first.categories.size)
|
520
|
+
assert_equal("Example category", feed.items.first.categories.first.value)
|
521
|
+
assert_equal(false, feed.bozo?)
|
522
|
+
feed = FeedTools::Feed.open(
|
523
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
524
|
+
'item_dc_subject_multiple.xml')
|
525
|
+
assert_equal(2, feed.items.first.categories.size)
|
526
|
+
assert_equal("Example category 1", feed.items.first.categories[0].value)
|
527
|
+
assert_equal(nil, feed.items.first.categories[0].domain)
|
528
|
+
assert_equal("Example category 2", feed.items.first.categories[1].value)
|
529
|
+
assert_equal(nil, feed.items.first.categories[1].domain)
|
530
|
+
assert_equal(false, feed.bozo?)
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_item_copyright
|
534
|
+
feed = FeedTools::Feed.open(
|
535
|
+
'http://feedparser.org/tests/wellformed/rss/item_dc_rights.xml')
|
536
|
+
assert_equal("Example copyright", feed.items.first.copyright)
|
537
|
+
assert_equal(false, feed.bozo?)
|
538
|
+
end
|
539
|
+
|
540
|
+
def test_item_comments
|
541
|
+
feed = FeedTools::Feed.open(
|
542
|
+
'http://feedparser.org/tests/wellformed/rss/item_comments.xml')
|
543
|
+
assert_equal("http://example.com/", feed.items.first.comments)
|
544
|
+
assert_equal(false, feed.bozo?)
|
545
|
+
end
|
546
|
+
|
547
|
+
def test_item_enclosures
|
548
|
+
feed = FeedTools::Feed.open(
|
549
|
+
'http://feedparser.org/tests/wellformed/rss/item_enclosure_length.xml')
|
550
|
+
assert_equal("http://example.com/", feed.items.first.link)
|
551
|
+
assert_equal("http://example.com/",
|
552
|
+
feed.items.first.enclosures[0].link)
|
553
|
+
assert_equal(100000, feed.items.first.enclosures[0].file_size)
|
554
|
+
assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
|
555
|
+
assert_equal(nil, feed.items.first.title)
|
556
|
+
assert_equal(nil, feed.items.first.description)
|
557
|
+
assert_equal(false, feed.bozo?)
|
558
|
+
feed = FeedTools::Feed.open(
|
559
|
+
'http://feedparser.org/tests/wellformed/rss/' +
|
560
|
+
'item_enclosure_multiple.xml')
|
561
|
+
assert_equal("http://example.com/", feed.items.first.link)
|
562
|
+
assert_equal("http://example.com/1",
|
563
|
+
feed.items.first.enclosures[0].link)
|
564
|
+
assert_equal(100000, feed.items.first.enclosures[0].file_size)
|
565
|
+
assert_equal("image/jpeg", feed.items.first.enclosures[0].type)
|
566
|
+
assert_equal("http://example.com/2",
|
567
|
+
feed.items.first.enclosures[1].link)
|
568
|
+
assert_equal(200000, feed.items.first.enclosures[1].file_size)
|
569
|
+
assert_equal("image/gif", feed.items.first.enclosures[1].type)
|
570
|
+
assert_equal(nil, feed.items.first.title)
|
571
|
+
assert_equal(nil, feed.items.first.description)
|
572
|
+
assert_equal(false, feed.bozo?)
|
573
|
+
end
|
574
|
+
|
575
|
+
def test_item_source
|
576
|
+
feed = FeedTools::Feed.open(
|
577
|
+
'http://feedparser.org/tests/wellformed/rss/item_source.xml')
|
578
|
+
assert_equal("http://example.com/", feed.items.first.source.url)
|
579
|
+
assert_equal("Example source", feed.items.first.source.value)
|
580
|
+
assert_equal(false, feed.bozo?)
|
581
|
+
end
|
582
|
+
|
583
|
+
# This doesn't *really* test much since FeedTools isn't a namespace
|
584
|
+
# aware parser yet. Mostly it just verifies that switching namepaces
|
585
|
+
# doesn't make the feeds unreadable.
|
586
|
+
def test_namespaces
|
587
|
+
feed = FeedTools::Feed.open(
|
588
|
+
'http://feedparser.org/tests/wellformed/rss/rss_namespace_1.xml')
|
589
|
+
assert_equal("Example description", feed.description)
|
590
|
+
assert_equal(nil, feed.title)
|
591
|
+
assert_equal(false, feed.bozo?)
|
592
|
+
feed = FeedTools::Feed.open(
|
593
|
+
'http://feedparser.org/tests/wellformed/rss/rss_namespace_2.xml')
|
594
|
+
assert_equal("Example description", feed.description)
|
595
|
+
assert_equal(nil, feed.title)
|
596
|
+
assert_equal(false, feed.bozo?)
|
597
|
+
feed = FeedTools::Feed.open(
|
598
|
+
'http://feedparser.org/tests/wellformed/rss/rss_namespace_3.xml')
|
599
|
+
assert_equal("Example description", feed.description)
|
600
|
+
assert_equal(nil, feed.title)
|
601
|
+
assert_equal(false, feed.bozo?)
|
602
|
+
feed = FeedTools::Feed.open(
|
603
|
+
'http://feedparser.org/tests/wellformed/rss/rss_namespace_4.xml')
|
604
|
+
assert_equal("Example description", feed.description)
|
605
|
+
assert_equal(nil, feed.title)
|
606
|
+
assert_equal(false, feed.bozo?)
|
607
|
+
feed = FeedTools::Feed.open(
|
608
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_090.xml')
|
609
|
+
assert_equal("rss", feed.feed_type)
|
610
|
+
assert_equal(0.9, feed.feed_version)
|
611
|
+
assert_equal(false, feed.bozo?)
|
612
|
+
feed = FeedTools::Feed.open(
|
613
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_091_netscape.xml')
|
614
|
+
assert_equal("rss", feed.feed_type)
|
615
|
+
assert_equal(0.91, feed.feed_version)
|
616
|
+
assert_equal(false, feed.bozo?)
|
617
|
+
feed = FeedTools::Feed.open(
|
618
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_091_userland.xml')
|
619
|
+
assert_equal("rss", feed.feed_type)
|
620
|
+
assert_equal(0.91, feed.feed_version)
|
621
|
+
assert_equal(false, feed.bozo?)
|
622
|
+
feed = FeedTools::Feed.open(
|
623
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_092.xml')
|
624
|
+
assert_equal("rss", feed.feed_type)
|
625
|
+
assert_equal(0.92, feed.feed_version)
|
626
|
+
assert_equal(false, feed.bozo?)
|
627
|
+
feed = FeedTools::Feed.open(
|
628
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_093.xml')
|
629
|
+
assert_equal("rss", feed.feed_type)
|
630
|
+
assert_equal(0.93, feed.feed_version)
|
631
|
+
assert_equal(false, feed.bozo?)
|
632
|
+
feed = FeedTools::Feed.open(
|
633
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_094.xml')
|
634
|
+
assert_equal("rss", feed.feed_type)
|
635
|
+
assert_equal(0.94, feed.feed_version)
|
636
|
+
assert_equal(false, feed.bozo?)
|
637
|
+
feed = FeedTools::Feed.open(
|
638
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_20.xml')
|
639
|
+
assert_equal("rss", feed.feed_type)
|
640
|
+
assert_equal(2.0, feed.feed_version)
|
641
|
+
assert_equal(false, feed.bozo?)
|
642
|
+
feed = FeedTools::Feed.open(
|
643
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_201.xml')
|
644
|
+
assert_equal("rss", feed.feed_type)
|
645
|
+
assert_equal(2.0, feed.feed_version)
|
646
|
+
assert_equal(false, feed.bozo?)
|
647
|
+
feed = FeedTools::Feed.open(
|
648
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_21.xml')
|
649
|
+
assert_equal("rss", feed.feed_type)
|
650
|
+
assert_equal(2.0, feed.feed_version)
|
651
|
+
assert_equal(false, feed.bozo?)
|
652
|
+
feed = FeedTools::Feed.open(
|
653
|
+
'http://feedparser.org/tests/wellformed/rss/rss_version_missing.xml')
|
654
|
+
assert_equal("rss", feed.feed_type)
|
655
|
+
assert_equal(nil, feed.feed_version)
|
656
|
+
assert_equal(false, feed.bozo?)
|
657
|
+
end
|
230
658
|
end
|