6
class TestMaker09 < TestCase
9
rss = RSS::Maker.make("0.91")
12
rss = RSS::Maker.make("0.9") do |maker|
13
setup_dummy_channel(maker)
15
assert_equal("0.91", rss.rss_version)
17
rss = RSS::Maker.make("0.91") do |maker|
18
setup_dummy_channel(maker)
20
assert_equal("0.91", rss.rss_version)
23
rss = RSS::Maker.make("0.91") do |maker|
24
setup_dummy_channel(maker)
26
maker.encoding = "EUC-JP"
28
assert_equal("0.91", rss.rss_version)
29
assert_equal("EUC-JP", rss.encoding)
31
rss = RSS::Maker.make("0.91") do |maker|
32
setup_dummy_channel(maker)
34
maker.standalone = "yes"
36
assert_equal("0.91", rss.rss_version)
37
assert_equal("yes", rss.standalone)
39
rss = RSS::Maker.make("0.91") do |maker|
40
setup_dummy_channel(maker)
42
maker.encoding = "EUC-JP"
43
maker.standalone = "yes"
45
assert_equal("0.91", rss.rss_version)
46
assert_equal("EUC-JP", rss.encoding)
47
assert_equal("yes", rss.standalone)
52
link = "http://hoge.com"
53
description = "fugafugafugafuga"
56
managingEditor = "bar"
57
webMaster = "web master"
58
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))'
59
docs = "http://foo.com/doc"
69
lastBuildDate = Time.now
71
rss = RSS::Maker.make("0.91") do |maker|
72
maker.channel.title = title
73
maker.channel.link = link
74
maker.channel.description = description
75
maker.channel.language = language
76
maker.channel.copyright = copyright
77
maker.channel.managingEditor = managingEditor
78
maker.channel.webMaster = webMaster
79
maker.channel.rating = rating
80
maker.channel.docs = docs
81
maker.channel.pubDate = pubDate
82
maker.channel.lastBuildDate = lastBuildDate
84
skipDays.each do |day|
85
maker.channel.skipDays.new_day do |new_day|
89
skipHours.each do |hour|
90
maker.channel.skipHours.new_hour do |new_hour|
91
new_hour.content = hour
97
assert_equal(title, channel.title)
98
assert_equal(link, channel.link)
99
assert_equal(description, channel.description)
100
assert_equal(language, channel.language)
101
assert_equal(copyright, channel.copyright)
102
assert_equal(managingEditor, channel.managingEditor)
103
assert_equal(webMaster, channel.webMaster)
104
assert_equal(rating, channel.rating)
105
assert_equal(docs, channel.docs)
106
assert_equal(pubDate, channel.pubDate)
107
assert_equal(pubDate, channel.date)
108
assert_equal(lastBuildDate, channel.lastBuildDate)
110
skipDays.each_with_index do |day, i|
111
assert_equal(day, channel.skipDays.days[i].content)
113
skipHours.each_with_index do |hour, i|
114
assert_equal(hour.to_i, channel.skipHours.hours[i].content)
117
assert(channel.items.empty?)
118
assert_nil(channel.image)
119
assert_nil(channel.textInput)
122
def test_not_valid_channel
124
link = "http://hoge.com"
125
description = "fugafugafugafuga"
128
assert_not_set_error("maker.channel", %w(title)) do
129
RSS::Maker.make("0.91") do |maker|
130
# maker.channel.title = title
131
maker.channel.link = link
132
maker.channel.description = description
133
maker.channel.language = language
137
assert_not_set_error("maker.channel", %w(link)) do
138
RSS::Maker.make("0.91") do |maker|
139
maker.channel.title = title
140
# maker.channel.link = link
141
maker.channel.link = nil
142
maker.channel.description = description
143
maker.channel.language = language
147
assert_not_set_error("maker.channel", %w(description)) do
148
RSS::Maker.make("0.91") do |maker|
149
maker.channel.title = title
150
maker.channel.link = link
151
# maker.channel.description = description
152
maker.channel.language = language
156
assert_not_set_error("maker.channel", %w(language)) do
157
RSS::Maker.make("0.91") do |maker|
158
maker.channel.title = title
159
maker.channel.link = link
160
maker.channel.description = description
161
# maker.channel.language = language
168
link = "http://hoge.com"
169
url = "http://hoge.com/hoge.png"
172
description = "an image"
174
rss = RSS::Maker.make("0.91") do |maker|
175
setup_dummy_channel(maker)
176
maker.channel.link = link
178
maker.image.title = title
179
maker.image.url = url
180
maker.image.width = width
181
maker.image.height = height
182
maker.image.description = description
185
assert_equal(title, image.title)
186
assert_equal(link, image.link)
187
assert_equal(url, image.url)
188
assert_equal(width.to_i, image.width)
189
assert_equal(height.to_i, image.height)
190
assert_equal(description, image.description)
192
assert_not_set_error("maker.channel", %w(description title language)) do
193
RSS::Maker.make("0.91") do |maker|
194
# setup_dummy_channel(maker)
195
maker.channel.link = link
197
maker.image.title = title
198
maker.image.url = url
199
maker.image.width = width
200
maker.image.height = height
201
maker.image.description = description
206
def test_not_valid_image
208
link = "http://hoge.com"
209
url = "http://hoge.com/hoge.png"
212
description = "an image"
214
rss = RSS::Maker.make("0.91") do |maker|
215
setup_dummy_channel(maker)
216
maker.channel.link = link
218
# maker.image.title = title
219
maker.image.url = url
220
maker.image.width = width
221
maker.image.height = height
222
maker.image.description = description
224
assert_nil(rss.channel.image)
226
assert_not_set_error("maker.channel", %w(link)) do
227
RSS::Maker.make("0.91") do |maker|
228
setup_dummy_channel(maker)
229
# maker.channel.link = link
230
maker.channel.link = nil
232
maker.image.title = title
233
maker.image.url = url
234
maker.image.width = width
235
maker.image.height = height
236
maker.image.description = description
240
rss = RSS::Maker.make("0.91") do |maker|
241
setup_dummy_channel(maker)
242
maker.channel.link = link
244
maker.image.title = title
245
# maker.image.url = url
246
maker.image.width = width
247
maker.image.height = height
248
maker.image.description = description
250
assert_nil(rss.channel.image)
255
link = "http://hoge.com/"
256
description = "text hoge fuga"
258
rss = RSS::Maker.make("0.91") do |maker|
259
setup_dummy_channel(maker)
261
assert(rss.channel.items.empty?)
263
rss = RSS::Maker.make("0.91") do |maker|
264
setup_dummy_channel(maker)
266
maker.items.new_item do |item|
269
# item.description = description
272
assert_equal(1, rss.channel.items.size)
273
item = rss.channel.items.first
274
assert_equal(title, item.title)
275
assert_equal(link, item.link)
276
assert_nil(item.description)
280
rss = RSS::Maker.make("0.91") do |maker|
281
setup_dummy_channel(maker)
283
item_size.times do |i|
284
maker.items.new_item do |item|
285
item.title = "#{title}#{i}"
286
item.link = "#{link}#{i}"
287
item.description = "#{description}#{i}"
290
maker.items.do_sort = true
292
assert_equal(item_size, rss.items.size)
293
rss.channel.items.each_with_index do |item, i|
294
assert_equal("#{title}#{i}", item.title)
295
assert_equal("#{link}#{i}", item.link)
296
assert_equal("#{description}#{i}", item.description)
299
rss = RSS::Maker.make("0.91") do |maker|
300
setup_dummy_channel(maker)
302
item_size.times do |i|
303
maker.items.new_item do |item|
304
item.title = "#{title}#{i}"
305
item.link = "#{link}#{i}"
306
item.description = "#{description}#{i}"
309
maker.items.do_sort = Proc.new do |x, y|
310
y.title[-1] <=> x.title[-1]
313
assert_equal(item_size, rss.items.size)
314
rss.channel.items.reverse.each_with_index do |item, i|
315
assert_equal("#{title}#{i}", item.title)
316
assert_equal("#{link}#{i}", item.link)
317
assert_equal("#{description}#{i}", item.description)
323
description = "text hoge fuga"
325
link = "http://hoge.com"
327
rss = RSS::Maker.make("0.91") do |maker|
328
setup_dummy_channel(maker)
330
maker.textinput.title = title
331
maker.textinput.description = description
332
maker.textinput.name = name
333
maker.textinput.link = link
335
textInput = rss.channel.textInput
336
assert_equal(title, textInput.title)
337
assert_equal(description, textInput.description)
338
assert_equal(name, textInput.name)
339
assert_equal(link, textInput.link)
341
rss = RSS::Maker.make("0.91") do |maker|
342
# setup_dummy_channel(maker)
344
maker.textinput.title = title
345
maker.textinput.description = description
346
maker.textinput.name = name
347
maker.textinput.link = link
352
def test_not_valid_textInput
354
description = "text hoge fuga"
356
link = "http://hoge.com"
358
rss = RSS::Maker.make("0.91") do |maker|
359
setup_dummy_channel(maker)
361
# maker.textinput.title = title
362
maker.textinput.description = description
363
maker.textinput.name = name
364
maker.textinput.link = link
366
assert_nil(rss.channel.textInput)
368
rss = RSS::Maker.make("0.91") do |maker|
369
setup_dummy_channel(maker)
371
maker.textinput.title = title
372
# maker.textinput.description = description
373
maker.textinput.name = name
374
maker.textinput.link = link
376
assert_nil(rss.channel.textInput)
378
rss = RSS::Maker.make("0.91") do |maker|
379
setup_dummy_channel(maker)
381
maker.textinput.title = title
382
maker.textinput.description = description
383
# maker.textinput.name = name
384
maker.textinput.link = link
386
assert_nil(rss.channel.textInput)
388
rss = RSS::Maker.make("0.91") do |maker|
389
setup_dummy_channel(maker)
391
maker.textinput.title = title
392
maker.textinput.description = description
393
maker.textinput.name = name
394
# maker.textinput.link = link
396
assert_nil(rss.channel.textInput)