summaryrefslogtreecommitdiff
path: root/test/rss/test_maker_1.0.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-05 03:03:05 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-05 03:03:05 +0000
commit71976790ec02f88d9fb51fab151312124f6df223 (patch)
tree0a70c0031e53d40f05e846486b25f91070274d66 /test/rss/test_maker_1.0.rb
parent43009063c70fe62028eb035e67a06863b98dc540 (diff)
downloadruby-71976790ec02f88d9fb51fab151312124f6df223.tar.gz
* lib/rss, sample/rss, test/rss:
- 0.1.7 -> 0.1.8. - supported <itunes:XXX>. - reverted backward incompatibility API changes introduced 0.1.7. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_maker_1.0.rb')
-rw-r--r--test/rss/test_maker_1.0.rb92
1 files changed, 50 insertions, 42 deletions
diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb
index cc1e58c1a2..60cc3708a7 100644
--- a/test/rss/test_maker_1.0.rb
+++ b/test/rss/test_maker_1.0.rb
@@ -209,7 +209,7 @@ module RSS
end
end
- def test_items
+ def test_items(with_convenience_way=true)
title = "TITLE"
link = "http://hoge.com/"
description = "text hoge fuga"
@@ -242,42 +242,46 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- maker.items.new_item do |item|
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |_item|
+ _item.title = "#{title}#{i}"
+ _item.link = "#{link}#{i}"
+ _item.description = "#{description}#{i}"
end
end
maker.items.do_sort = true
end
assert_equal(item_size, rss.items.size)
- rss.items.each_with_index do |item, i|
- assert_equal("#{link}#{i}", item.about)
- assert_equal("#{title}#{i}", item.title)
- assert_equal("#{link}#{i}", item.link)
- assert_equal("#{description}#{i}", item.description)
+ rss.items.each_with_index do |_item, i|
+ assert_equal("#{link}#{i}", _item.about)
+ assert_equal("#{title}#{i}", _item.title)
+ assert_equal("#{link}#{i}", _item.link)
+ assert_equal("#{description}#{i}", _item.description)
end
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
item_size.times do |i|
- maker.items.new_item do |item|
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |_item|
+ _item.title = "#{title}#{i}"
+ _item.link = "#{link}#{i}"
+ _item.description = "#{description}#{i}"
end
end
maker.items.do_sort = Proc.new do |x, y|
- y.title.content[-1] <=> x.title.content[-1]
+ if with_convenience_way
+ y.title[-1] <=> x.title[-1]
+ else
+ y.title {|t| t.content[-1]} <=> x.title {|t| t.content[-1]}
+ end
end
end
assert_equal(item_size, rss.items.size)
- rss.items.reverse.each_with_index do |item, i|
- assert_equal("#{link}#{i}", item.about)
- assert_equal("#{title}#{i}", item.title)
- assert_equal("#{link}#{i}", item.link)
- assert_equal("#{description}#{i}", item.description)
+ rss.items.reverse.each_with_index do |_item, i|
+ assert_equal("#{link}#{i}", _item.about)
+ assert_equal("#{title}#{i}", _item.title)
+ assert_equal("#{link}#{i}", _item.link)
+ assert_equal("#{description}#{i}", _item.description)
end
max_size = item_size / 2
@@ -285,20 +289,20 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- maker.items.new_item do |item|
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |_item|
+ _item.title = "#{title}#{i}"
+ _item.link = "#{link}#{i}"
+ _item.description = "#{description}#{i}"
end
end
maker.items.max_size = max_size
end
assert_equal(max_size, rss.items.size)
- rss.items.each_with_index do |item, i|
- assert_equal("#{link}#{i}", item.about)
- assert_equal("#{title}#{i}", item.title)
- assert_equal("#{link}#{i}", item.link)
- assert_equal("#{description}#{i}", item.description)
+ rss.items.each_with_index do |_item, i|
+ assert_equal("#{link}#{i}", _item.about)
+ assert_equal("#{title}#{i}", _item.title)
+ assert_equal("#{link}#{i}", _item.link)
+ assert_equal("#{description}#{i}", _item.description)
end
max_size = 0
@@ -307,10 +311,10 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- maker.items.new_item do |item|
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |_item|
+ _item.title = "#{title}#{i}"
+ _item.link = "#{link}#{i}"
+ _item.description = "#{description}#{i}"
end
end
maker.items.max_size = max_size
@@ -322,23 +326,27 @@ module RSS
setup_dummy_channel(maker)
item_size.times do |i|
- maker.items.new_item do |item|
- item.title = "#{title}#{i}"
- item.link = "#{link}#{i}"
- item.description = "#{description}#{i}"
+ maker.items.new_item do |_item|
+ _item.title = "#{title}#{i}"
+ _item.link = "#{link}#{i}"
+ _item.description = "#{description}#{i}"
end
end
maker.items.max_size = max_size
end
assert_equal(item_size + max_size + 1, rss.items.size)
- rss.items.each_with_index do |item, i|
- assert_equal("#{link}#{i}", item.about)
- assert_equal("#{title}#{i}", item.title)
- assert_equal("#{link}#{i}", item.link)
- assert_equal("#{description}#{i}", item.description)
+ rss.items.each_with_index do |_item, i|
+ assert_equal("#{link}#{i}", _item.about)
+ assert_equal("#{title}#{i}", _item.title)
+ assert_equal("#{link}#{i}", _item.link)
+ assert_equal("#{description}#{i}", _item.description)
end
end
+ def test_items_with_new_api_since_018
+ test_items(false)
+ end
+
def test_not_valid_items
title = "TITLE"
link = "http://hoge.com/"