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_maker_2.0.rb
DELETED
@@ -1,758 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative "rss-testcase"
|
3
|
-
|
4
|
-
require "rss/maker"
|
5
|
-
|
6
|
-
module RSS
|
7
|
-
class TestMaker20 < TestCase
|
8
|
-
def test_supported?
|
9
|
-
assert(RSS::Maker.supported?("2.0"))
|
10
|
-
assert(RSS::Maker.supported?("rss2.0"))
|
11
|
-
assert(!RSS::Maker.supported?("2.2"))
|
12
|
-
assert(!RSS::Maker.supported?("rss2.2"))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_find_class
|
16
|
-
assert_equal(RSS::Maker::RSS20, RSS::Maker["2.0"])
|
17
|
-
assert_equal(RSS::Maker::RSS20, RSS::Maker["rss2.0"])
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_rss
|
21
|
-
assert_raise(LocalJumpError) do
|
22
|
-
RSS::Maker.make("2.0")
|
23
|
-
end
|
24
|
-
|
25
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
26
|
-
setup_dummy_channel(maker)
|
27
|
-
end
|
28
|
-
assert_equal("2.0", rss.rss_version)
|
29
|
-
|
30
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
31
|
-
setup_dummy_channel(maker)
|
32
|
-
|
33
|
-
maker.encoding = "EUC-JP"
|
34
|
-
end
|
35
|
-
assert_equal("2.0", rss.rss_version)
|
36
|
-
assert_equal("EUC-JP", rss.encoding)
|
37
|
-
|
38
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
39
|
-
setup_dummy_channel(maker)
|
40
|
-
|
41
|
-
maker.standalone = "yes"
|
42
|
-
end
|
43
|
-
assert_equal("2.0", rss.rss_version)
|
44
|
-
assert_equal("yes", rss.standalone)
|
45
|
-
|
46
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
47
|
-
setup_dummy_channel(maker)
|
48
|
-
|
49
|
-
maker.encoding = "EUC-JP"
|
50
|
-
maker.standalone = "yes"
|
51
|
-
end
|
52
|
-
assert_equal("2.0", rss.rss_version)
|
53
|
-
assert_equal("EUC-JP", rss.encoding)
|
54
|
-
assert_equal("yes", rss.standalone)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_channel
|
58
|
-
title = "fugafuga"
|
59
|
-
link = "http://hoge.com"
|
60
|
-
description = "fugafugafugafuga"
|
61
|
-
language = "ja"
|
62
|
-
copyright = "foo"
|
63
|
-
managingEditor = "bar"
|
64
|
-
webMaster = "web master"
|
65
|
-
rating = '(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))'
|
66
|
-
docs = "http://foo.com/doc"
|
67
|
-
skipDays = [
|
68
|
-
"Sunday",
|
69
|
-
"Monday",
|
70
|
-
]
|
71
|
-
skipHours = [
|
72
|
-
"0",
|
73
|
-
"13",
|
74
|
-
]
|
75
|
-
pubDate = Time.now
|
76
|
-
lastBuildDate = Time.now
|
77
|
-
categories = [
|
78
|
-
"Nespapers",
|
79
|
-
"misc",
|
80
|
-
]
|
81
|
-
generator = "RSS Maker"
|
82
|
-
ttl = "60"
|
83
|
-
|
84
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
85
|
-
maker.channel.title = title
|
86
|
-
maker.channel.link = link
|
87
|
-
maker.channel.description = description
|
88
|
-
maker.channel.language = language
|
89
|
-
maker.channel.copyright = copyright
|
90
|
-
maker.channel.managingEditor = managingEditor
|
91
|
-
maker.channel.webMaster = webMaster
|
92
|
-
maker.channel.rating = rating
|
93
|
-
maker.channel.docs = docs
|
94
|
-
maker.channel.pubDate = pubDate
|
95
|
-
maker.channel.lastBuildDate = lastBuildDate
|
96
|
-
|
97
|
-
skipDays.each do |day|
|
98
|
-
maker.channel.skipDays.new_day do |new_day|
|
99
|
-
new_day.content = day
|
100
|
-
end
|
101
|
-
end
|
102
|
-
skipHours.each do |hour|
|
103
|
-
maker.channel.skipHours.new_hour do |new_hour|
|
104
|
-
new_hour.content = hour
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
categories.each do |category|
|
109
|
-
maker.channel.categories.new_category do |new_category|
|
110
|
-
new_category.content = category
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
maker.channel.generator = generator
|
115
|
-
maker.channel.ttl = ttl
|
116
|
-
end
|
117
|
-
channel = rss.channel
|
118
|
-
|
119
|
-
assert_equal(title, channel.title)
|
120
|
-
assert_equal(link, channel.link)
|
121
|
-
assert_equal(description, channel.description)
|
122
|
-
assert_equal(language, channel.language)
|
123
|
-
assert_equal(copyright, channel.copyright)
|
124
|
-
assert_equal(managingEditor, channel.managingEditor)
|
125
|
-
assert_equal(webMaster, channel.webMaster)
|
126
|
-
assert_equal(rating, channel.rating)
|
127
|
-
assert_equal(docs, channel.docs)
|
128
|
-
assert_equal(pubDate, channel.pubDate)
|
129
|
-
assert_equal(pubDate, channel.date)
|
130
|
-
assert_equal(lastBuildDate, channel.lastBuildDate)
|
131
|
-
|
132
|
-
skipDays.each_with_index do |day, i|
|
133
|
-
assert_equal(day, channel.skipDays.days[i].content)
|
134
|
-
end
|
135
|
-
skipHours.each_with_index do |hour, i|
|
136
|
-
assert_equal(hour.to_i, channel.skipHours.hours[i].content)
|
137
|
-
end
|
138
|
-
|
139
|
-
channel.categories.each_with_index do |category, i|
|
140
|
-
assert_equal(categories[i], category.content)
|
141
|
-
end
|
142
|
-
|
143
|
-
assert_equal(generator, channel.generator)
|
144
|
-
assert_equal(ttl.to_i, channel.ttl)
|
145
|
-
|
146
|
-
assert(channel.items.empty?)
|
147
|
-
assert_nil(channel.image)
|
148
|
-
assert_nil(channel.textInput)
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_not_valid_channel
|
152
|
-
title = "fugafuga"
|
153
|
-
link = "http://hoge.com"
|
154
|
-
description = "fugafugafugafuga"
|
155
|
-
language = "ja"
|
156
|
-
|
157
|
-
assert_not_set_error("maker.channel", %w(title)) do
|
158
|
-
RSS::Maker.make("2.0") do |maker|
|
159
|
-
# maker.channel.title = title
|
160
|
-
maker.channel.link = link
|
161
|
-
maker.channel.description = description
|
162
|
-
maker.channel.language = language
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
assert_not_set_error("maker.channel", %w(link)) do
|
167
|
-
RSS::Maker.make("2.0") do |maker|
|
168
|
-
maker.channel.title = title
|
169
|
-
# maker.channel.link = link
|
170
|
-
maker.channel.description = description
|
171
|
-
maker.channel.language = language
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
assert_not_set_error("maker.channel", %w(description)) do
|
176
|
-
RSS::Maker.make("2.0") do |maker|
|
177
|
-
maker.channel.title = title
|
178
|
-
maker.channel.link = link
|
179
|
-
# maker.channel.description = description
|
180
|
-
maker.channel.language = language
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
185
|
-
maker.channel.title = title
|
186
|
-
maker.channel.link = link
|
187
|
-
maker.channel.description = description
|
188
|
-
# maker.channel.language = language
|
189
|
-
end
|
190
|
-
assert_not_nil(rss)
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
def test_cloud
|
195
|
-
domain = "rpc.sys.com"
|
196
|
-
port = "80"
|
197
|
-
path = "/RPC2"
|
198
|
-
registerProcedure = "myCloud.rssPleaseNotify"
|
199
|
-
protocol = "xml-rpc"
|
200
|
-
|
201
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
202
|
-
setup_dummy_channel(maker)
|
203
|
-
|
204
|
-
maker.channel.cloud.domain = domain
|
205
|
-
maker.channel.cloud.port = port
|
206
|
-
maker.channel.cloud.path = path
|
207
|
-
maker.channel.cloud.registerProcedure = registerProcedure
|
208
|
-
maker.channel.cloud.protocol = protocol
|
209
|
-
end
|
210
|
-
cloud = rss.channel.cloud
|
211
|
-
assert_equal(domain, cloud.domain)
|
212
|
-
assert_equal(port.to_i, cloud.port)
|
213
|
-
assert_equal(path, cloud.path)
|
214
|
-
assert_equal(registerProcedure, cloud.registerProcedure)
|
215
|
-
assert_equal(protocol, cloud.protocol)
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_not_valid_cloud
|
219
|
-
domain = "rpc.sys.com"
|
220
|
-
port = "80"
|
221
|
-
path = "/RPC2"
|
222
|
-
registerProcedure = "myCloud.rssPleaseNotify"
|
223
|
-
protocol = "xml-rpc"
|
224
|
-
|
225
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
226
|
-
setup_dummy_channel(maker)
|
227
|
-
|
228
|
-
# maker.channel.cloud.domain = domain
|
229
|
-
maker.channel.cloud.port = port
|
230
|
-
maker.channel.cloud.path = path
|
231
|
-
maker.channel.cloud.registerProcedure = registerProcedure
|
232
|
-
maker.channel.cloud.protocol = protocol
|
233
|
-
end
|
234
|
-
assert_nil(rss.channel.cloud)
|
235
|
-
|
236
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
237
|
-
setup_dummy_channel(maker)
|
238
|
-
|
239
|
-
maker.channel.cloud.domain = domain
|
240
|
-
# maker.channel.cloud.port = port
|
241
|
-
maker.channel.cloud.path = path
|
242
|
-
maker.channel.cloud.registerProcedure = registerProcedure
|
243
|
-
maker.channel.cloud.protocol = protocol
|
244
|
-
end
|
245
|
-
assert_nil(rss.channel.cloud)
|
246
|
-
|
247
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
248
|
-
setup_dummy_channel(maker)
|
249
|
-
|
250
|
-
maker.channel.cloud.domain = domain
|
251
|
-
maker.channel.cloud.port = port
|
252
|
-
# maker.channel.cloud.path = path
|
253
|
-
maker.channel.cloud.registerProcedure = registerProcedure
|
254
|
-
maker.channel.cloud.protocol = protocol
|
255
|
-
end
|
256
|
-
assert_nil(rss.channel.cloud)
|
257
|
-
|
258
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
259
|
-
setup_dummy_channel(maker)
|
260
|
-
|
261
|
-
maker.channel.cloud.domain = domain
|
262
|
-
maker.channel.cloud.port = port
|
263
|
-
maker.channel.cloud.path = path
|
264
|
-
# maker.channel.cloud.registerProcedure = registerProcedure
|
265
|
-
maker.channel.cloud.protocol = protocol
|
266
|
-
end
|
267
|
-
assert_nil(rss.channel.cloud)
|
268
|
-
|
269
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
270
|
-
setup_dummy_channel(maker)
|
271
|
-
|
272
|
-
maker.channel.cloud.domain = domain
|
273
|
-
maker.channel.cloud.port = port
|
274
|
-
maker.channel.cloud.path = path
|
275
|
-
maker.channel.cloud.registerProcedure = registerProcedure
|
276
|
-
# maker.channel.cloud.protocol = protocol
|
277
|
-
end
|
278
|
-
assert_nil(rss.channel.cloud)
|
279
|
-
end
|
280
|
-
|
281
|
-
|
282
|
-
def test_image
|
283
|
-
title = "fugafuga"
|
284
|
-
link = "http://hoge.com"
|
285
|
-
url = "http://hoge.com/hoge.png"
|
286
|
-
width = "144"
|
287
|
-
height = "400"
|
288
|
-
description = "an image"
|
289
|
-
|
290
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
291
|
-
setup_dummy_channel(maker)
|
292
|
-
maker.channel.link = link
|
293
|
-
|
294
|
-
maker.image.title = title
|
295
|
-
maker.image.url = url
|
296
|
-
maker.image.width = width
|
297
|
-
maker.image.height = height
|
298
|
-
maker.image.description = description
|
299
|
-
end
|
300
|
-
image = rss.image
|
301
|
-
assert_equal(title, image.title)
|
302
|
-
assert_equal(link, image.link)
|
303
|
-
assert_equal(url, image.url)
|
304
|
-
assert_equal(width.to_i, image.width)
|
305
|
-
assert_equal(height.to_i, image.height)
|
306
|
-
assert_equal(description, image.description)
|
307
|
-
|
308
|
-
assert_not_set_error("maker.channel", %w(title description)) do
|
309
|
-
RSS::Maker.make("2.0") do |maker|
|
310
|
-
# setup_dummy_channel(maker)
|
311
|
-
maker.channel.link = link
|
312
|
-
|
313
|
-
maker.image.title = title
|
314
|
-
maker.image.url = url
|
315
|
-
maker.image.width = width
|
316
|
-
maker.image.height = height
|
317
|
-
maker.image.description = description
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
def test_not_valid_image
|
323
|
-
title = "fugafuga"
|
324
|
-
link = "http://hoge.com"
|
325
|
-
url = "http://hoge.com/hoge.png"
|
326
|
-
width = "144"
|
327
|
-
height = "400"
|
328
|
-
description = "an image"
|
329
|
-
|
330
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
331
|
-
setup_dummy_channel(maker)
|
332
|
-
maker.channel.link = link
|
333
|
-
|
334
|
-
# maker.image.title = title
|
335
|
-
maker.image.url = url
|
336
|
-
maker.image.width = width
|
337
|
-
maker.image.height = height
|
338
|
-
maker.image.description = description
|
339
|
-
end
|
340
|
-
assert_nil(rss.image)
|
341
|
-
|
342
|
-
assert_not_set_error("maker.channel", %w(link)) do
|
343
|
-
RSS::Maker.make("2.0") do |maker|
|
344
|
-
setup_dummy_channel(maker)
|
345
|
-
# maker.channel.link = link
|
346
|
-
maker.channel.link = nil
|
347
|
-
|
348
|
-
maker.image.title = title
|
349
|
-
maker.image.url = url
|
350
|
-
maker.image.width = width
|
351
|
-
maker.image.height = height
|
352
|
-
maker.image.description = description
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
357
|
-
setup_dummy_channel(maker)
|
358
|
-
maker.channel.link = link
|
359
|
-
|
360
|
-
maker.image.title = title
|
361
|
-
# maker.image.url = url
|
362
|
-
maker.image.width = width
|
363
|
-
maker.image.height = height
|
364
|
-
maker.image.description = description
|
365
|
-
end
|
366
|
-
assert_nil(rss.image)
|
367
|
-
end
|
368
|
-
|
369
|
-
def test_items(with_convenience_way=true)
|
370
|
-
title = "TITLE"
|
371
|
-
link = "http://hoge.com/"
|
372
|
-
description = "text hoge fuga"
|
373
|
-
author = "oprah@oxygen.net"
|
374
|
-
comments = "http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290"
|
375
|
-
pubDate = Time.now
|
376
|
-
|
377
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
378
|
-
setup_dummy_channel(maker)
|
379
|
-
end
|
380
|
-
assert(rss.channel.items.empty?)
|
381
|
-
|
382
|
-
item_size = 5
|
383
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
384
|
-
setup_dummy_channel(maker)
|
385
|
-
|
386
|
-
item_size.times do |i|
|
387
|
-
maker.items.new_item do |item|
|
388
|
-
item.title = "#{title}#{i}"
|
389
|
-
item.link = "#{link}#{i}"
|
390
|
-
item.description = "#{description}#{i}"
|
391
|
-
item.author = "#{author}#{i}"
|
392
|
-
item.comments = "#{comments}#{i}"
|
393
|
-
item.date = pubDate - i
|
394
|
-
end
|
395
|
-
end
|
396
|
-
maker.items.do_sort = true
|
397
|
-
end
|
398
|
-
assert_equal(item_size, rss.items.size)
|
399
|
-
rss.channel.items.each_with_index do |item, i|
|
400
|
-
assert_equal("#{title}#{i}", item.title)
|
401
|
-
assert_equal("#{link}#{i}", item.link)
|
402
|
-
assert_equal("#{description}#{i}", item.description)
|
403
|
-
assert_equal("#{author}#{i}", item.author)
|
404
|
-
assert_equal("#{comments}#{i}", item.comments)
|
405
|
-
assert_equal(pubDate - i, item.pubDate)
|
406
|
-
assert_equal(pubDate - i, item.date)
|
407
|
-
end
|
408
|
-
|
409
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
410
|
-
setup_dummy_channel(maker)
|
411
|
-
|
412
|
-
item_size.times do |i|
|
413
|
-
maker.items.new_item do |item|
|
414
|
-
item.title = "#{title}#{i}"
|
415
|
-
item.link = "#{link}#{i}"
|
416
|
-
item.description = "#{description}#{i}"
|
417
|
-
item.author = "#{author}#{i}"
|
418
|
-
item.comments = "#{comments}#{i}"
|
419
|
-
item.date = pubDate
|
420
|
-
end
|
421
|
-
end
|
422
|
-
maker.items.do_sort = Proc.new do |x, y|
|
423
|
-
if with_convenience_way
|
424
|
-
y.title[-1] <=> x.title[-1]
|
425
|
-
else
|
426
|
-
y.title {|t| t.content[-1]} <=> x.title {|t| t.content[-1]}
|
427
|
-
end
|
428
|
-
end
|
429
|
-
end
|
430
|
-
assert_equal(item_size, rss.items.size)
|
431
|
-
rss.channel.items.reverse.each_with_index do |item, i|
|
432
|
-
assert_equal("#{title}#{i}", item.title)
|
433
|
-
assert_equal("#{link}#{i}", item.link)
|
434
|
-
assert_equal("#{description}#{i}", item.description)
|
435
|
-
assert_equal("#{author}#{i}", item.author)
|
436
|
-
assert_equal("#{comments}#{i}", item.comments)
|
437
|
-
assert_equal(pubDate, item.pubDate)
|
438
|
-
assert_equal(pubDate, item.date)
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
def test_items_with_new_api_since_018
|
443
|
-
test_items(false)
|
444
|
-
end
|
445
|
-
|
446
|
-
def test_pubDate_without_description
|
447
|
-
title = "TITLE"
|
448
|
-
link = "http://hoge.com/"
|
449
|
-
# description = "text hoge fuga"
|
450
|
-
author = "oprah@oxygen.net"
|
451
|
-
pubDate = Time.now
|
452
|
-
|
453
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
454
|
-
setup_dummy_channel(maker)
|
455
|
-
|
456
|
-
maker.items.new_item do |item|
|
457
|
-
item.title = title
|
458
|
-
item.link = link
|
459
|
-
# item.description = description
|
460
|
-
item.author = author
|
461
|
-
item.pubDate = pubDate
|
462
|
-
end
|
463
|
-
end
|
464
|
-
assert_equal(1, rss.items.size)
|
465
|
-
rss.channel.items.each_with_index do |item, i|
|
466
|
-
assert_equal(title, item.title)
|
467
|
-
assert_equal(link, item.link)
|
468
|
-
# assert_equal(description, item.description)
|
469
|
-
assert_equal(author, item.author)
|
470
|
-
assert_equal(pubDate, item.pubDate)
|
471
|
-
assert_equal(pubDate, item.date)
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
|
-
def test_guid
|
476
|
-
isPermaLink = "true"
|
477
|
-
content = "http://inessential.com/2002/09/01.php#a2"
|
478
|
-
|
479
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
480
|
-
setup_dummy_channel(maker)
|
481
|
-
setup_dummy_item(maker)
|
482
|
-
|
483
|
-
guid = maker.items.last.guid
|
484
|
-
guid.isPermaLink = isPermaLink
|
485
|
-
guid.content = content
|
486
|
-
end
|
487
|
-
guid = rss.channel.items.last.guid
|
488
|
-
assert_equal(isPermaLink == "true", guid.isPermaLink)
|
489
|
-
assert_equal(content, guid.content)
|
490
|
-
end
|
491
|
-
|
492
|
-
def test_guid_permanent_link
|
493
|
-
content = "http://inessential.com/2002/09/01.php#a2"
|
494
|
-
|
495
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
496
|
-
setup_dummy_channel(maker)
|
497
|
-
setup_dummy_item(maker)
|
498
|
-
|
499
|
-
guid = maker.items.last.guid
|
500
|
-
assert_equal(nil, guid.permanent_link?)
|
501
|
-
assert_equal(guid.isPermaLink, guid.permanent_link?)
|
502
|
-
guid.permanent_link = true
|
503
|
-
assert_equal(true, guid.permanent_link?)
|
504
|
-
assert_equal(guid.isPermaLink, guid.permanent_link?)
|
505
|
-
guid.content = content
|
506
|
-
end
|
507
|
-
guid = rss.channel.items.last.guid
|
508
|
-
assert_equal(true, guid.isPermaLink)
|
509
|
-
assert_equal(content, guid.content)
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_guid_permanent_link_false
|
513
|
-
content = "http://inessential.com/2002/09/01.php#a2"
|
514
|
-
|
515
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
516
|
-
setup_dummy_channel(maker)
|
517
|
-
setup_dummy_item(maker)
|
518
|
-
|
519
|
-
guid = maker.items.last.guid
|
520
|
-
assert_equal(nil, guid.permanent_link?)
|
521
|
-
assert_equal(guid.isPermaLink, guid.permanent_link?)
|
522
|
-
guid.permanent_link = false
|
523
|
-
assert_equal(false, guid.permanent_link?)
|
524
|
-
assert_equal(guid.isPermaLink, guid.permanent_link?)
|
525
|
-
guid.content = content
|
526
|
-
end
|
527
|
-
guid = rss.channel.items.last.guid
|
528
|
-
assert_equal(false, guid.isPermaLink)
|
529
|
-
assert_equal(content, guid.content)
|
530
|
-
end
|
531
|
-
|
532
|
-
def test_not_valid_guid
|
533
|
-
# content = "http://inessential.com/2002/09/01.php#a2"
|
534
|
-
|
535
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
536
|
-
setup_dummy_channel(maker)
|
537
|
-
setup_dummy_item(maker)
|
538
|
-
|
539
|
-
# guid = maker.items.last.guid
|
540
|
-
# guid.content = content
|
541
|
-
end
|
542
|
-
assert_nil(rss.channel.items.last.guid)
|
543
|
-
end
|
544
|
-
|
545
|
-
def test_enclosure
|
546
|
-
url = "http://www.scripting.com/mp3s/weatherReportSuite.mp3"
|
547
|
-
length = "12216320"
|
548
|
-
type = "audio/mpeg"
|
549
|
-
|
550
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
551
|
-
setup_dummy_channel(maker)
|
552
|
-
setup_dummy_item(maker)
|
553
|
-
|
554
|
-
enclosure = maker.items.last.enclosure
|
555
|
-
enclosure.url = url
|
556
|
-
enclosure.length = length
|
557
|
-
enclosure.type = type
|
558
|
-
end
|
559
|
-
enclosure = rss.channel.items.last.enclosure
|
560
|
-
assert_equal(url, enclosure.url)
|
561
|
-
assert_equal(length.to_i, enclosure.length)
|
562
|
-
assert_equal(type, enclosure.type)
|
563
|
-
end
|
564
|
-
|
565
|
-
def test_not_valid_enclosure
|
566
|
-
url = "http://www.scripting.com/mp3s/weatherReportSuite.mp3"
|
567
|
-
length = "12216320"
|
568
|
-
type = "audio/mpeg"
|
569
|
-
|
570
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
571
|
-
setup_dummy_channel(maker)
|
572
|
-
setup_dummy_item(maker)
|
573
|
-
|
574
|
-
enclosure = maker.items.last.enclosure
|
575
|
-
# enclosure.url = url
|
576
|
-
enclosure.length = length
|
577
|
-
enclosure.type = type
|
578
|
-
end
|
579
|
-
assert_nil(rss.channel.items.last.enclosure)
|
580
|
-
|
581
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
582
|
-
setup_dummy_channel(maker)
|
583
|
-
setup_dummy_item(maker)
|
584
|
-
|
585
|
-
enclosure = maker.items.last.enclosure
|
586
|
-
enclosure.url = url
|
587
|
-
# enclosure.length = length
|
588
|
-
enclosure.type = type
|
589
|
-
end
|
590
|
-
assert_nil(rss.channel.items.last.enclosure)
|
591
|
-
|
592
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
593
|
-
setup_dummy_channel(maker)
|
594
|
-
setup_dummy_item(maker)
|
595
|
-
|
596
|
-
enclosure = maker.items.last.enclosure
|
597
|
-
enclosure.url = url
|
598
|
-
enclosure.length = length
|
599
|
-
# enclosure.type = type
|
600
|
-
end
|
601
|
-
assert_nil(rss.channel.items.last.enclosure)
|
602
|
-
end
|
603
|
-
|
604
|
-
|
605
|
-
def test_source
|
606
|
-
url = "http://static.userland.com/tomalak/links2.xml"
|
607
|
-
content = "Tomalak's Realm"
|
608
|
-
|
609
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
610
|
-
setup_dummy_channel(maker)
|
611
|
-
setup_dummy_item(maker)
|
612
|
-
|
613
|
-
source = maker.items.last.source
|
614
|
-
source.url = url
|
615
|
-
source.content = content
|
616
|
-
end
|
617
|
-
source = rss.channel.items.last.source
|
618
|
-
assert_equal(url, source.url)
|
619
|
-
assert_equal(content, source.content)
|
620
|
-
end
|
621
|
-
|
622
|
-
def test_not_valid_source
|
623
|
-
url = "http://static.userland.com/tomalak/links2.xml"
|
624
|
-
content = "Tomalak's Realm"
|
625
|
-
|
626
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
627
|
-
setup_dummy_channel(maker)
|
628
|
-
setup_dummy_item(maker)
|
629
|
-
|
630
|
-
source = maker.items.last.source
|
631
|
-
# source.url = url
|
632
|
-
source.content = content
|
633
|
-
end
|
634
|
-
assert_nil(rss.channel.items.last.source)
|
635
|
-
|
636
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
637
|
-
setup_dummy_channel(maker)
|
638
|
-
setup_dummy_item(maker)
|
639
|
-
|
640
|
-
source = maker.items.last.source
|
641
|
-
source.url = url
|
642
|
-
# source.content = content
|
643
|
-
end
|
644
|
-
assert_nil(rss.channel.items.last.source)
|
645
|
-
end
|
646
|
-
|
647
|
-
def test_category
|
648
|
-
domain = "http://www.fool.com/cusips"
|
649
|
-
content = "MSFT"
|
650
|
-
|
651
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
652
|
-
setup_dummy_channel(maker)
|
653
|
-
setup_dummy_item(maker)
|
654
|
-
|
655
|
-
maker.items.last.categories.new_category do |category|
|
656
|
-
category.domain = domain
|
657
|
-
category.content = content
|
658
|
-
end
|
659
|
-
end
|
660
|
-
category = rss.channel.items.last.categories.last
|
661
|
-
assert_equal(domain, category.domain)
|
662
|
-
assert_equal(content, category.content)
|
663
|
-
end
|
664
|
-
|
665
|
-
def test_not_valid_category
|
666
|
-
# content = "Grateful Dead"
|
667
|
-
|
668
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
669
|
-
setup_dummy_channel(maker)
|
670
|
-
setup_dummy_item(maker)
|
671
|
-
|
672
|
-
maker.items.last.categories.new_category do |category|
|
673
|
-
# category.content = content
|
674
|
-
end
|
675
|
-
end
|
676
|
-
assert(rss.channel.items.last.categories.empty?)
|
677
|
-
end
|
678
|
-
|
679
|
-
def test_textInput
|
680
|
-
title = "fugafuga"
|
681
|
-
description = "text hoge fuga"
|
682
|
-
name = "hoge"
|
683
|
-
link = "http://hoge.com"
|
684
|
-
|
685
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
686
|
-
setup_dummy_channel(maker)
|
687
|
-
|
688
|
-
maker.textinput.title = title
|
689
|
-
maker.textinput.description = description
|
690
|
-
maker.textinput.name = name
|
691
|
-
maker.textinput.link = link
|
692
|
-
end
|
693
|
-
textInput = rss.channel.textInput
|
694
|
-
assert_equal(title, textInput.title)
|
695
|
-
assert_equal(description, textInput.description)
|
696
|
-
assert_equal(name, textInput.name)
|
697
|
-
assert_equal(link, textInput.link)
|
698
|
-
|
699
|
-
assert_not_set_error("maker.channel", %w(link description title)) do
|
700
|
-
RSS::Maker.make("2.0") do |maker|
|
701
|
-
# setup_dummy_channel(maker)
|
702
|
-
|
703
|
-
maker.textinput.title = title
|
704
|
-
maker.textinput.description = description
|
705
|
-
maker.textinput.name = name
|
706
|
-
maker.textinput.link = link
|
707
|
-
end
|
708
|
-
end
|
709
|
-
end
|
710
|
-
|
711
|
-
def test_not_valid_textInput
|
712
|
-
title = "fugafuga"
|
713
|
-
description = "text hoge fuga"
|
714
|
-
name = "hoge"
|
715
|
-
link = "http://hoge.com"
|
716
|
-
|
717
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
718
|
-
setup_dummy_channel(maker)
|
719
|
-
|
720
|
-
# maker.textinput.title = title
|
721
|
-
maker.textinput.description = description
|
722
|
-
maker.textinput.name = name
|
723
|
-
maker.textinput.link = link
|
724
|
-
end
|
725
|
-
assert_nil(rss.channel.textInput)
|
726
|
-
|
727
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
728
|
-
setup_dummy_channel(maker)
|
729
|
-
|
730
|
-
maker.textinput.title = title
|
731
|
-
# maker.textinput.description = description
|
732
|
-
maker.textinput.name = name
|
733
|
-
maker.textinput.link = link
|
734
|
-
end
|
735
|
-
assert_nil(rss.channel.textInput)
|
736
|
-
|
737
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
738
|
-
setup_dummy_channel(maker)
|
739
|
-
|
740
|
-
maker.textinput.title = title
|
741
|
-
maker.textinput.description = description
|
742
|
-
# maker.textinput.name = name
|
743
|
-
maker.textinput.link = link
|
744
|
-
end
|
745
|
-
assert_nil(rss.channel.textInput)
|
746
|
-
|
747
|
-
rss = RSS::Maker.make("2.0") do |maker|
|
748
|
-
setup_dummy_channel(maker)
|
749
|
-
|
750
|
-
maker.textinput.title = title
|
751
|
-
maker.textinput.description = description
|
752
|
-
maker.textinput.name = name
|
753
|
-
# maker.textinput.link = link
|
754
|
-
end
|
755
|
-
assert_nil(rss.channel.textInput)
|
756
|
-
end
|
757
|
-
end
|
758
|
-
end
|