From 2fa78a09f7d3c35640f261cc427944a5011401cc Mon Sep 17 00:00:00 2001 From: kou Date: Wed, 8 Dec 2004 12:58:36 +0000 Subject: * lib/rss, test/rss, sample/rss: backported from CVS HEAD. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rss/rss-assertions.rb | 341 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 316 insertions(+), 25 deletions(-) (limited to 'test/rss/rss-assertions.rb') diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb index 6b83cbe09..569e9621d 100644 --- a/test/rss/rss-assertions.rb +++ b/test/rss/rss-assertions.rb @@ -94,27 +94,44 @@ module RSS end end end - - def assert_xml_stylesheet_attrs(xsl, attrs) + + def assert_not_set_error(name, variables) _wrap_assertion do - normalized_attrs = {} - attrs.each do |name, value| - normalized_attrs[name.to_s] = value + begin + yield + flunk("Not raise NotSetError") + rescue ::RSS::NotSetError => e + assert_equal(name, e.name) + assert_equal(variables.sort, e.variables.sort) end + end + end + + def assert_xml_declaration(version, encoding, standalone, rss) + _wrap_assertion do + assert_equal(version, rss.version) + assert_equal(encoding, rss.encoding) + assert_equal(standalone, rss.standalone) + end + end + + def assert_xml_stylesheet_attrs(attrs, xsl) + _wrap_assertion do + n_attrs = normalized_attrs(attrs) ::RSS::XMLStyleSheet::ATTRIBUTES.each do |name| - assert_equal(normalized_attrs[name], xsl.send(name)) + assert_equal(n_attrs[name], xsl.send(name)) end end end - def assert_xml_stylesheet(target, xsl, attrs) + def assert_xml_stylesheet(target, attrs, xsl) _wrap_assertion do if attrs.has_key?(:href) if !attrs.has_key?(:type) and attrs.has_key?(:guess_type) attrs[:type] = attrs[:guess_type] end assert_equal("xml-stylesheet", target) - assert_xml_stylesheet_attrs(xsl, attrs) + assert_xml_stylesheet_attrs(attrs, xsl) else assert_nil(target) assert_equal("", xsl.to_s) @@ -123,39 +140,313 @@ module RSS end def assert_xml_stylesheet_pis(attrs_ary) - rdf = ::RSS::RDF.new() - xss_strs = [] - attrs_ary.each do |attrs| - xss = ::RSS::XMLStyleSheet.new(*attrs) - xss_strs.push(xss.to_s) - rdf.xml_stylesheets.push(xss) + _wrap_assertion do + rdf = ::RSS::RDF.new() + xss_strs = [] + attrs_ary.each do |attrs| + xss = ::RSS::XMLStyleSheet.new(*attrs) + xss_strs.push(xss.to_s) + rdf.xml_stylesheets.push(xss) + end + pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s*