* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#normalize): fixed

strange RSS::Maker::Item#max_size behavior.
  Thanks to Kazuhiko <kazuhiko@fdiary.net>.

* test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2005-09-16 23:48:17 +00:00
Родитель aa6393778a
Коммит 446eef82cf
3 изменённых файлов: 67 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Sat Sep 17 08:35:39 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#normalize): fixed
strange RSS::Maker::Item#max_size behavior.
Thanks to Kazuhiko <kazuhiko@fdiary.net>.
* test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto.
Sat Sep 17 08:02:53 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb: supported DIGEST-MD5. Thanks, Mathieu Arnold.

Просмотреть файл

@ -401,7 +401,11 @@ EOC
end
def normalize
sort_if_need[0..@max_size]
if @max_size >= 0
sort_if_need[0...@max_size]
else
sort_if_need[0..@max_size]
end
end
def current_element(rss)

Просмотреть файл

@ -256,6 +256,60 @@ module RSS
assert_equal("#{link}#{i}", item.link)
assert_equal("#{description}#{i}", item.description)
end
max_size = item_size / 2
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
item_size.times do |i|
item = maker.items.new_item
item.title = "#{title}#{i}"
item.link = "#{link}#{i}"
item.description = "#{description}#{i}"
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)
end
max_size = 0
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
item_size.times do |i|
item = maker.items.new_item
item.title = "#{title}#{i}"
item.link = "#{link}#{i}"
item.description = "#{description}#{i}"
end
maker.items.max_size = max_size
end
assert_equal(max_size, rss.items.size)
max_size = -2
rss = RSS::Maker.make("1.0") do |maker|
setup_dummy_channel(maker)
item_size.times do |i|
item = maker.items.new_item
item.title = "#{title}#{i}"
item.link = "#{link}#{i}"
item.description = "#{description}#{i}"
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)
end
end
def test_not_valid_items