summaryrefslogtreecommitdiff
path: root/test/rss
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-29 08:42:46 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-29 08:42:46 +0000
commit94031b9628f4a5e02df018a29111051a97a7a2cb (patch)
tree761525f578203bcad1eb01106ddd29b57d30b2c5 /test/rss
parent7556f66e9cd2eaca3c7cc114f56be732c8845086 (diff)
* lib/rss/maker/base.rb (RSS::Maker::RSSBase#to_feed): raise
exception not return nil if RSS::Maker.make can't get required information. * test/rss/rss-assertions.rb: follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss')
-rw-r--r--test/rss/rss-assertions.rb46
1 files changed, 31 insertions, 15 deletions
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index dd06fb2..f396e9a 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -1272,22 +1272,32 @@ EOA
invalid_feed_checker=nil)
_wrap_assertion do
elements = []
- invalid_feed = false
- feed = RSS::Maker.make("atom:#{feed_type}") do |maker|
- yield maker
- targets = chain_reader(maker, maker_readers)
- targets.each do |target|
- element = maker_extractor.call(target)
- elements << element if element
+ invalid_feed_exception = nil
+ feed = nil
+ begin
+ feed = RSS::Maker.make("atom:#{feed_type}") do |maker|
+ yield maker
+ targets = chain_reader(maker, maker_readers)
+ targets.each do |target|
+ element = maker_extractor.call(target)
+ elements << element if element
+ end
+ if invalid_feed_checker
+ invalid_feed_exception = invalid_feed_checker.call(targets)
+ end
end
- if invalid_feed_checker
- invalid_feed = invalid_feed_checker.call(targets)
+ rescue RSS::Error
+ if invalid_feed_exception.is_a?(RSS::TooMuchTagError)
+ assert_too_much_tag(invalid_feed_exception.tag,
+ invalid_feed_exception.parent) do
+ raise
+ end
+ else
+ raise
end
end
- if invalid_feed
- assert_nil(feed)
- else
+ if invalid_feed_exception.nil?
actual_elements = chain_reader(feed, feed_readers) || []
actual_elements = actual_elements.collect do |target|
feed_extractor.call(target)
@@ -1542,18 +1552,24 @@ EOA
:length => target.length,
}
end
+
+ if feed_readers.first == "entries"
+ parent = "entry"
+ else
+ parent = feed_type
+ end
invalid_feed_checker = Proc.new do |targets|
infos = {}
- invalid = false
+ invalid_exception = nil
targets.each do |target|
key = [target.hreflang, target.type]
if infos.has_key?(key)
- invalid = true
+ invalid_exception = RSS::TooMuchTagError.new("link", parent)
break
end
infos[key] = true if target.rel.nil? or target.rel == "alternate"
end
- invalid
+ invalid_exception
end
invalid_feed_checker = nil if allow_duplication
_assert_maker_atom_elements(feed_type, maker_readers, feed_readers,