rss 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +38 -0
- data/README.md +11 -11
- data/lib/rss/itunes.rb +10 -1
- data/lib/rss/maker/itunes.rb +2 -0
- data/lib/rss/rss.rb +43 -15
- data/lib/rss/utils.rb +0 -18
- data/lib/rss/version.rb +1 -1
- data/lib/rss/xml-stylesheet.rb +3 -4
- data/lib/rss/xml.rb +3 -2
- data/lib/rss.rb +11 -11
- metadata +7 -101
- data/Gemfile +0 -6
- data/Rakefile +0 -15
- data/rss.gemspec +0 -30
- data/test/dot.png +0 -0
- data/test/rss-assertions.rb +0 -2116
- data/test/rss-testcase.rb +0 -479
- data/test/run-test.rb +0 -15
- data/test/test_1.0.rb +0 -308
- data/test/test_2.0.rb +0 -412
- data/test/test_accessor.rb +0 -104
- data/test/test_atom.rb +0 -684
- data/test/test_content.rb +0 -105
- data/test/test_dublincore.rb +0 -270
- data/test/test_image.rb +0 -215
- data/test/test_inherit.rb +0 -41
- data/test/test_itunes.rb +0 -360
- data/test/test_maker_0.9.rb +0 -477
- data/test/test_maker_1.0.rb +0 -519
- data/test/test_maker_2.0.rb +0 -758
- data/test/test_maker_atom_entry.rb +0 -394
- data/test/test_maker_atom_feed.rb +0 -455
- data/test/test_maker_content.rb +0 -48
- data/test/test_maker_dc.rb +0 -150
- data/test/test_maker_image.rb +0 -63
- data/test/test_maker_itunes.rb +0 -488
- data/test/test_maker_slash.rb +0 -38
- data/test/test_maker_sy.rb +0 -45
- data/test/test_maker_taxo.rb +0 -82
- data/test/test_maker_trackback.rb +0 -42
- data/test/test_maker_xml-stylesheet.rb +0 -84
- data/test/test_parser.rb +0 -122
- data/test/test_parser_1.0.rb +0 -529
- data/test/test_parser_2.0.rb +0 -123
- data/test/test_parser_atom_entry.rb +0 -164
- data/test/test_parser_atom_feed.rb +0 -277
- data/test/test_setup_maker_0.9.rb +0 -247
- data/test/test_setup_maker_1.0.rb +0 -551
- data/test/test_setup_maker_2.0.rb +0 -309
- data/test/test_setup_maker_atom_entry.rb +0 -410
- data/test/test_setup_maker_atom_feed.rb +0 -446
- data/test/test_setup_maker_itunes.rb +0 -146
- data/test/test_setup_maker_slash.rb +0 -39
- data/test/test_slash.rb +0 -65
- data/test/test_syndication.rb +0 -126
- data/test/test_taxonomy.rb +0 -173
- data/test/test_to_s.rb +0 -701
- data/test/test_trackback.rb +0 -136
- data/test/test_xml-stylesheet.rb +0 -109
data/test/test_parser_1.0.rb
DELETED
@@ -1,529 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/1.0"
|
5
|
-
require "rss/dublincore"
|
6
|
-
|
7
|
-
module RSS
|
8
|
-
class TestParser10 < TestCase
|
9
|
-
def test_RDF
|
10
|
-
assert_ns("", RDF::URI) do
|
11
|
-
Parser.parse(<<-EOR)
|
12
|
-
#{make_xmldecl}
|
13
|
-
<RDF/>
|
14
|
-
EOR
|
15
|
-
end
|
16
|
-
|
17
|
-
assert_ns("", RDF::URI) do
|
18
|
-
Parser.parse(<<-EOR)
|
19
|
-
#{make_xmldecl}
|
20
|
-
<RDF xmlns="hoge"/>
|
21
|
-
EOR
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_ns("rdf", RDF::URI) do
|
25
|
-
Parser.parse(<<-EOR)
|
26
|
-
#{make_xmldecl}
|
27
|
-
<rdf:RDF xmlns:rdf="hoge"/>
|
28
|
-
EOR
|
29
|
-
end
|
30
|
-
|
31
|
-
assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
|
32
|
-
#{make_xmldecl}
|
33
|
-
<rdf:RDF xmlns:rdf="#{RSS::RDF::URI}"/>
|
34
|
-
EOR
|
35
|
-
|
36
|
-
assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
|
37
|
-
#{make_xmldecl}
|
38
|
-
<RDF xmlns="#{RSS::RDF::URI}"/>
|
39
|
-
EOR
|
40
|
-
|
41
|
-
assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
|
42
|
-
#{make_xmldecl}
|
43
|
-
<RDF xmlns="#{RSS::RDF::URI}"/>
|
44
|
-
EOR
|
45
|
-
|
46
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
47
|
-
#{make_channel}
|
48
|
-
EOR
|
49
|
-
|
50
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
51
|
-
#{make_channel}
|
52
|
-
#{make_image}
|
53
|
-
EOR
|
54
|
-
|
55
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
56
|
-
#{make_channel}
|
57
|
-
#{make_textinput}
|
58
|
-
EOR
|
59
|
-
|
60
|
-
assert_too_much_tag("image", "RDF") do
|
61
|
-
Parser.parse(make_RDF(<<-EOR))
|
62
|
-
#{make_channel}
|
63
|
-
#{make_image}
|
64
|
-
#{make_image}
|
65
|
-
#{make_item}
|
66
|
-
#{make_textinput}
|
67
|
-
EOR
|
68
|
-
end
|
69
|
-
|
70
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
71
|
-
#{make_channel}
|
72
|
-
#{make_item}
|
73
|
-
#{make_image}
|
74
|
-
#{make_textinput}
|
75
|
-
EOR
|
76
|
-
|
77
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
78
|
-
#{make_channel}
|
79
|
-
#{make_item}
|
80
|
-
#{make_textinput}
|
81
|
-
#{make_image}
|
82
|
-
EOR
|
83
|
-
|
84
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
85
|
-
#{make_channel}
|
86
|
-
#{make_image}
|
87
|
-
#{make_item}
|
88
|
-
EOR
|
89
|
-
|
90
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
91
|
-
#{make_channel}
|
92
|
-
#{make_image}
|
93
|
-
#{make_item}
|
94
|
-
#{make_textinput}
|
95
|
-
EOR
|
96
|
-
|
97
|
-
1.step(15, 3) do |i|
|
98
|
-
rss = make_RDF() do
|
99
|
-
res = make_channel
|
100
|
-
i.times { res << make_item }
|
101
|
-
res
|
102
|
-
end
|
103
|
-
assert_parse(rss, :nothing_raised)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_undefined_entity
|
108
|
-
return unless RSS::Parser.default_parser.raise_for_undefined_entity?
|
109
|
-
assert_parse(make_RDF(<<-EOR), :raises, RSS::NotWellFormedError)
|
110
|
-
#{make_channel}
|
111
|
-
#{make_image}
|
112
|
-
<item rdf:about="#{RDF_ABOUT}">
|
113
|
-
<title>#{TITLE_VALUE} &UNKNOWN_ENTITY;</title>
|
114
|
-
<link>#{LINK_VALUE}</link>
|
115
|
-
<description>#{DESCRIPTION_VALUE}</description>
|
116
|
-
</item>
|
117
|
-
#{make_textinput}
|
118
|
-
EOR
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_channel
|
122
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "channel", "rdf:about")
|
123
|
-
<channel />
|
124
|
-
EOR
|
125
|
-
|
126
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "channel")
|
127
|
-
<channel rdf:about="http://example.com/"/>
|
128
|
-
EOR
|
129
|
-
|
130
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "channel")
|
131
|
-
<channel rdf:about="http://example.com/">
|
132
|
-
<title>hoge</title>
|
133
|
-
</channel>
|
134
|
-
EOR
|
135
|
-
|
136
|
-
assert_parse(make_RDF(<<EOR), :missing_tag, "description", "channel")
|
137
|
-
<channel rdf:about="http://example.com/">
|
138
|
-
<title>hoge</title>
|
139
|
-
<link>http://example.com/</link>
|
140
|
-
</channel>
|
141
|
-
EOR
|
142
|
-
|
143
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
|
144
|
-
<channel rdf:about="http://example.com/">
|
145
|
-
<title>hoge</title>
|
146
|
-
<link>http://example.com/</link>
|
147
|
-
<description>hogehoge</description>
|
148
|
-
</channel>
|
149
|
-
EOR
|
150
|
-
|
151
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "rdf:resource")
|
152
|
-
<channel rdf:about="http://example.com/">
|
153
|
-
<title>hoge</title>
|
154
|
-
<link>http://example.com/</link>
|
155
|
-
<description>hogehoge</description>
|
156
|
-
<image/>
|
157
|
-
</channel>
|
158
|
-
EOR
|
159
|
-
|
160
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
|
161
|
-
<channel rdf:about="http://example.com/">
|
162
|
-
<title>hoge</title>
|
163
|
-
<link>http://example.com/</link>
|
164
|
-
<description>hogehoge</description>
|
165
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
166
|
-
</channel>
|
167
|
-
EOR
|
168
|
-
|
169
|
-
rss = make_RDF(<<-EOR)
|
170
|
-
<channel rdf:about="http://example.com/">
|
171
|
-
<title>hoge</title>
|
172
|
-
<link>http://example.com/</link>
|
173
|
-
<description>hogehoge</description>
|
174
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
175
|
-
<items/>
|
176
|
-
</channel>
|
177
|
-
EOR
|
178
|
-
|
179
|
-
assert_missing_tag("Seq", "items") do
|
180
|
-
Parser.parse(rss)
|
181
|
-
end
|
182
|
-
|
183
|
-
assert_missing_tag("item", "RDF") do
|
184
|
-
Parser.parse(rss, false).validate
|
185
|
-
end
|
186
|
-
|
187
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
188
|
-
<channel rdf:about="http://example.com/">
|
189
|
-
<title>hoge</title>
|
190
|
-
<link>http://example.com/</link>
|
191
|
-
<description>hogehoge</description>
|
192
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
193
|
-
<items>
|
194
|
-
<rdf:Seq>
|
195
|
-
</rdf:Seq>
|
196
|
-
</items>
|
197
|
-
</channel>
|
198
|
-
EOR
|
199
|
-
|
200
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "rdf:resource")
|
201
|
-
<channel rdf:about="http://example.com/">
|
202
|
-
<title>hoge</title>
|
203
|
-
<link>http://example.com/</link>
|
204
|
-
<description>hogehoge</description>
|
205
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
206
|
-
<items>
|
207
|
-
<rdf:Seq>
|
208
|
-
</rdf:Seq>
|
209
|
-
</items>
|
210
|
-
<textinput/>
|
211
|
-
</channel>
|
212
|
-
EOR
|
213
|
-
|
214
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
215
|
-
<channel rdf:about="http://example.com/">
|
216
|
-
<title>hoge</title>
|
217
|
-
<link>http://example.com/</link>
|
218
|
-
<description>hogehoge</description>
|
219
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
220
|
-
<items>
|
221
|
-
<rdf:Seq>
|
222
|
-
</rdf:Seq>
|
223
|
-
</items>
|
224
|
-
<textinput rdf:resource="http://example.com/search" />
|
225
|
-
</channel>
|
226
|
-
EOR
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_rdf_li
|
230
|
-
rss = make_RDF(<<-EOR)
|
231
|
-
<channel rdf:about="http://example.com/">
|
232
|
-
<title>hoge</title>
|
233
|
-
<link>http://example.com/</link>
|
234
|
-
<description>hogehoge</description>
|
235
|
-
<image rdf:resource="http://example.com/hoge.png" />
|
236
|
-
<items>
|
237
|
-
<rdf:Seq>
|
238
|
-
<rdf:li \#{rdf_li_attr}/>
|
239
|
-
</rdf:Seq>
|
240
|
-
</items>
|
241
|
-
<textinput rdf:resource="http://example.com/search" />
|
242
|
-
</channel>
|
243
|
-
#{make_item}
|
244
|
-
EOR
|
245
|
-
|
246
|
-
source = Proc.new do |rdf_li_attr|
|
247
|
-
eval(%Q[%Q[#{rss}]], binding)
|
248
|
-
end
|
249
|
-
|
250
|
-
attr = %q[resource="http://example.com/hoge"]
|
251
|
-
assert_parse(source.call(attr), :nothing_raised)
|
252
|
-
|
253
|
-
attr = %q[rdf:resource="http://example.com/hoge"]
|
254
|
-
assert_parse(source.call(attr), :nothing_raised)
|
255
|
-
|
256
|
-
assert_parse(source.call(""), :missing_attribute, "li", "resource")
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_image
|
260
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "rdf:about")
|
261
|
-
#{make_channel}
|
262
|
-
<image>
|
263
|
-
</image>
|
264
|
-
EOR
|
265
|
-
|
266
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "image")
|
267
|
-
#{make_channel}
|
268
|
-
<image rdf:about="http://example.com/hoge.png">
|
269
|
-
</image>
|
270
|
-
EOR
|
271
|
-
|
272
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "url", "image")
|
273
|
-
#{make_channel}
|
274
|
-
<image rdf:about="http://example.com/hoge.png">
|
275
|
-
<title>hoge</title>
|
276
|
-
</image>
|
277
|
-
EOR
|
278
|
-
|
279
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "image")
|
280
|
-
#{make_channel}
|
281
|
-
<image rdf:about="http://example.com/hoge.png">
|
282
|
-
<title>hoge</title>
|
283
|
-
<url>http://example.com/hoge.png</url>
|
284
|
-
</image>
|
285
|
-
EOR
|
286
|
-
|
287
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
|
288
|
-
#{make_channel}
|
289
|
-
<image rdf:about="http://example.com/hoge.png">
|
290
|
-
<title>hoge</title>
|
291
|
-
<url>http://example.com/hoge.png</url>
|
292
|
-
<link>http://example.com/</link>
|
293
|
-
</image>
|
294
|
-
EOR
|
295
|
-
|
296
|
-
rss = make_RDF(<<-EOR)
|
297
|
-
#{make_channel}
|
298
|
-
<image rdf:about="http://example.com/hoge.png">
|
299
|
-
<link>http://example.com/</link>
|
300
|
-
<url>http://example.com/hoge.png</url>
|
301
|
-
<title>hoge</title>
|
302
|
-
</image>
|
303
|
-
EOR
|
304
|
-
|
305
|
-
assert_missing_tag("item", "RDF") do
|
306
|
-
Parser.parse(rss)
|
307
|
-
end
|
308
|
-
|
309
|
-
assert_missing_tag("item", "RDF") do
|
310
|
-
Parser.parse(rss, false).validate
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
def test_item
|
315
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "item", "rdf:about")
|
316
|
-
#{make_channel}
|
317
|
-
#{make_image}
|
318
|
-
<item>
|
319
|
-
</item>
|
320
|
-
EOR
|
321
|
-
|
322
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "item")
|
323
|
-
#{make_channel}
|
324
|
-
#{make_image}
|
325
|
-
<item rdf:about="http://example.com/hoge.html">
|
326
|
-
</item>
|
327
|
-
EOR
|
328
|
-
|
329
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "item")
|
330
|
-
#{make_channel}
|
331
|
-
#{make_image}
|
332
|
-
<item rdf:about="http://example.com/hoge.html">
|
333
|
-
<title>hoge</title>
|
334
|
-
</item>
|
335
|
-
EOR
|
336
|
-
|
337
|
-
assert_too_much_tag("title", "item") do
|
338
|
-
Parser.parse(make_RDF(<<-EOR))
|
339
|
-
#{make_channel}
|
340
|
-
#{make_image}
|
341
|
-
<item rdf:about="http://example.com/hoge.html">
|
342
|
-
<title>hoge</title>
|
343
|
-
<title>hoge</title>
|
344
|
-
<link>http://example.com/hoge.html</link>
|
345
|
-
</item>
|
346
|
-
EOR
|
347
|
-
end
|
348
|
-
|
349
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
350
|
-
#{make_channel}
|
351
|
-
#{make_image}
|
352
|
-
<item rdf:about="http://example.com/hoge.html">
|
353
|
-
<title>hoge</title>
|
354
|
-
<link>http://example.com/hoge.html</link>
|
355
|
-
</item>
|
356
|
-
EOR
|
357
|
-
|
358
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
359
|
-
#{make_channel}
|
360
|
-
#{make_image}
|
361
|
-
<item rdf:about="http://example.com/hoge.html">
|
362
|
-
<title>hoge</title>
|
363
|
-
<link>http://example.com/hoge.html</link>
|
364
|
-
<description>hogehoge</description>
|
365
|
-
</item>
|
366
|
-
EOR
|
367
|
-
end
|
368
|
-
|
369
|
-
def test_textinput
|
370
|
-
assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "rdf:about")
|
371
|
-
#{make_channel}
|
372
|
-
#{make_image}
|
373
|
-
#{make_item}
|
374
|
-
<textinput>
|
375
|
-
</textinput>
|
376
|
-
EOR
|
377
|
-
|
378
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "textinput")
|
379
|
-
#{make_channel}
|
380
|
-
#{make_image}
|
381
|
-
#{make_item}
|
382
|
-
<textinput rdf:about="http://example.com/search.html">
|
383
|
-
</textinput>
|
384
|
-
EOR
|
385
|
-
|
386
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "description", "textinput")
|
387
|
-
#{make_channel}
|
388
|
-
#{make_image}
|
389
|
-
#{make_item}
|
390
|
-
<textinput rdf:about="http://example.com/search.html">
|
391
|
-
<title>hoge</title>
|
392
|
-
</textinput>
|
393
|
-
EOR
|
394
|
-
|
395
|
-
assert_too_much_tag("title", "textinput") do
|
396
|
-
Parser.parse(make_RDF(<<-EOR))
|
397
|
-
#{make_channel}
|
398
|
-
#{make_image}
|
399
|
-
#{make_item}
|
400
|
-
<textinput rdf:about="http://example.com/search.html">
|
401
|
-
<title>hoge</title>
|
402
|
-
<title>hoge</title>
|
403
|
-
<description>hogehoge</description>
|
404
|
-
</textinput>
|
405
|
-
EOR
|
406
|
-
end
|
407
|
-
|
408
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "name", "textinput")
|
409
|
-
#{make_channel}
|
410
|
-
#{make_image}
|
411
|
-
#{make_item}
|
412
|
-
<textinput rdf:about="http://example.com/search.html">
|
413
|
-
<title>hoge</title>
|
414
|
-
<description>hogehoge</description>
|
415
|
-
</textinput>
|
416
|
-
EOR
|
417
|
-
|
418
|
-
assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "textinput")
|
419
|
-
#{make_channel}
|
420
|
-
#{make_image}
|
421
|
-
#{make_item}
|
422
|
-
<textinput rdf:about="http://example.com/search.html">
|
423
|
-
<title>hoge</title>
|
424
|
-
<description>hogehoge</description>
|
425
|
-
<name>key</name>
|
426
|
-
</textinput>
|
427
|
-
EOR
|
428
|
-
|
429
|
-
assert_parse(make_RDF(<<-EOR), :nothing_raised)
|
430
|
-
#{make_channel}
|
431
|
-
#{make_image}
|
432
|
-
#{make_item}
|
433
|
-
<textinput rdf:about="http://example.com/search.html">
|
434
|
-
<title>hoge</title>
|
435
|
-
<description>hogehoge</description>
|
436
|
-
<name>key</name>
|
437
|
-
<link>http://example.com/search.html</link>
|
438
|
-
</textinput>
|
439
|
-
EOR
|
440
|
-
end
|
441
|
-
|
442
|
-
def test_ignore
|
443
|
-
name = "a"
|
444
|
-
rss = make_RDF(<<-EOR)
|
445
|
-
#{make_channel}
|
446
|
-
#{make_item}
|
447
|
-
<#{name}/>
|
448
|
-
EOR
|
449
|
-
assert_not_expected_tag(name, ::RSS::URI, "RDF") do
|
450
|
-
Parser.parse(rss, true, false)
|
451
|
-
end
|
452
|
-
|
453
|
-
uri = ""
|
454
|
-
name = "a"
|
455
|
-
rss = make_RDF(<<-EOR)
|
456
|
-
#{make_channel}
|
457
|
-
#{make_item}
|
458
|
-
<#{name} xmlns=""/>
|
459
|
-
EOR
|
460
|
-
assert_parse(rss, :nothing_raised)
|
461
|
-
assert_not_expected_tag(name, uri, "RDF") do
|
462
|
-
Parser.parse(rss, true, false)
|
463
|
-
end
|
464
|
-
|
465
|
-
uri = "http://example.com/"
|
466
|
-
name = "a"
|
467
|
-
rss = make_RDF(<<-EOR)
|
468
|
-
#{make_channel}
|
469
|
-
#{make_item}
|
470
|
-
<x:#{name} xmlns:x="#{uri}"/>
|
471
|
-
EOR
|
472
|
-
assert_parse(rss, :nothing_raised)
|
473
|
-
assert_not_expected_tag(name, uri, "RDF") do
|
474
|
-
Parser.parse(rss, true, false)
|
475
|
-
end
|
476
|
-
|
477
|
-
uri = ::RSS::URI
|
478
|
-
name = "a"
|
479
|
-
rss = make_RDF(<<-EOR)
|
480
|
-
#{make_channel}
|
481
|
-
#{make_item}
|
482
|
-
#{make_image("<#{name}/>")}
|
483
|
-
EOR
|
484
|
-
assert_parse(rss, :nothing_raised)
|
485
|
-
assert_not_expected_tag(name, uri, "image") do
|
486
|
-
Parser.parse(rss, true, false)
|
487
|
-
end
|
488
|
-
|
489
|
-
uri = CONTENT_URI
|
490
|
-
name = "encoded"
|
491
|
-
elem = "<#{name} xmlns='#{uri}'/>"
|
492
|
-
rss = make_RDF(<<-EOR)
|
493
|
-
#{make_channel}
|
494
|
-
#{make_item}
|
495
|
-
#{make_image(elem)}
|
496
|
-
EOR
|
497
|
-
assert_parse(rss, :nothing_raised)
|
498
|
-
assert_not_expected_tag(name, uri, "image") do
|
499
|
-
Parser.parse(rss, true, false)
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
def test_unknown_duplicated_element
|
504
|
-
xmlns = {"test" => "http://localhost/test"}
|
505
|
-
assert_parse(make_RDF(<<-EOR, xmlns), :nothing_raised)
|
506
|
-
#{make_channel("<test:string/>")}
|
507
|
-
#{make_item}
|
508
|
-
#{make_image}
|
509
|
-
EOR
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_unknown_case_insensitive_duplicated_element
|
513
|
-
xmlns = {
|
514
|
-
"foaf" => "http://xmlns.com/foaf/0.1/",
|
515
|
-
"dc" => "http://purl.org/dc/elements/1.1/",
|
516
|
-
}
|
517
|
-
assert_parse(make_RDF(<<-EOR, xmlns), :nothing_raised)
|
518
|
-
#{make_channel}
|
519
|
-
#{make_item}
|
520
|
-
#{make_image}
|
521
|
-
<foaf:Image rdf:about="http://example.com/myself.png">
|
522
|
-
<dc:title>Myself</dc:title>
|
523
|
-
<dc:link>http://example.com/</dc:link>
|
524
|
-
</foaf:Image>
|
525
|
-
EOR
|
526
|
-
end
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
data/test/test_parser_2.0.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/2.0"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestParser20 < TestCase
|
8
|
-
def test_rss20
|
9
|
-
assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss")
|
10
|
-
EOR
|
11
|
-
|
12
|
-
assert_parse(make_rss20(<<-EOR), :nothing_raised)
|
13
|
-
#{make_channel20("")}
|
14
|
-
EOR
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_cloud20
|
18
|
-
attrs = [
|
19
|
-
["domain", CLOUD_DOMAIN],
|
20
|
-
["port", CLOUD_PORT],
|
21
|
-
["path", CLOUD_PATH],
|
22
|
-
["registerProcedure", CLOUD_REGISTER_PROCEDURE],
|
23
|
-
["protocol", CLOUD_PROTOCOL],
|
24
|
-
]
|
25
|
-
|
26
|
-
(attrs.size + 1).times do |i|
|
27
|
-
missing_attr = attrs[i]
|
28
|
-
if missing_attr
|
29
|
-
meth = :missing_attribute
|
30
|
-
args = ["cloud", missing_attr[0]]
|
31
|
-
else
|
32
|
-
meth = :nothing_raised
|
33
|
-
args = []
|
34
|
-
end
|
35
|
-
|
36
|
-
cloud_attrs = []
|
37
|
-
attrs.each_with_index do |attr, j|
|
38
|
-
unless i == j
|
39
|
-
cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_parse(make_rss20(<<-EOR), meth, *args)
|
44
|
-
#{make_channel20(%Q[<cloud #{cloud_attrs.join("\n")}/>])}
|
45
|
-
EOR
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_source20
|
50
|
-
assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url")
|
51
|
-
#{make_channel20(make_item20(%Q[<source>Example</source>]))}
|
52
|
-
EOR
|
53
|
-
|
54
|
-
assert_parse(make_rss20(<<-EOR), :nothing_raised)
|
55
|
-
#{make_channel20(make_item20(%Q[<source url="http://example.com/" />]))}
|
56
|
-
EOR
|
57
|
-
|
58
|
-
assert_parse(make_rss20(<<-EOR), :nothing_raised)
|
59
|
-
#{make_channel20(make_item20(%Q[<source url="http://example.com/">Example</source>]))}
|
60
|
-
EOR
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_enclosure20
|
64
|
-
attrs = [
|
65
|
-
["url", ENCLOSURE_URL],
|
66
|
-
["length", ENCLOSURE_LENGTH],
|
67
|
-
["type", ENCLOSURE_TYPE],
|
68
|
-
]
|
69
|
-
|
70
|
-
(attrs.size + 1).times do |i|
|
71
|
-
missing_attr = attrs[i]
|
72
|
-
if missing_attr
|
73
|
-
meth = :missing_attribute
|
74
|
-
args = ["enclosure", missing_attr[0]]
|
75
|
-
else
|
76
|
-
meth = :nothing_raised
|
77
|
-
args = []
|
78
|
-
end
|
79
|
-
|
80
|
-
enclosure_attrs = []
|
81
|
-
attrs.each_with_index do |attr, j|
|
82
|
-
unless i == j
|
83
|
-
enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_parse(make_rss20(<<-EOR), meth, *args)
|
88
|
-
#{make_channel20(%Q[
|
89
|
-
#{make_item20(%Q[
|
90
|
-
<enclosure
|
91
|
-
#{enclosure_attrs.join("\n")} />
|
92
|
-
])}
|
93
|
-
])}
|
94
|
-
EOR
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_category20
|
99
|
-
values = [nil, CATEGORY_DOMAIN]
|
100
|
-
values.each do |value|
|
101
|
-
domain = ""
|
102
|
-
domain << %Q[domain="#{value}"] if value
|
103
|
-
|
104
|
-
["", "Example Text"].each do |text|
|
105
|
-
rss_src = make_rss20(<<-EOR)
|
106
|
-
#{make_channel20(%Q[
|
107
|
-
#{make_item20(%Q[
|
108
|
-
<category #{domain}>#{text}</category>
|
109
|
-
])}
|
110
|
-
])}
|
111
|
-
EOR
|
112
|
-
assert_parse(rss_src, :nothing_raised)
|
113
|
-
|
114
|
-
rss = RSS::Parser.parse(rss_src)
|
115
|
-
category = rss.items.last.categories.first
|
116
|
-
assert_equal(value, category.domain)
|
117
|
-
assert_equal(text, category.content)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|