summaryrefslogtreecommitdiff
path: root/test/rss/rss-assertions.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-16 04:51:15 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-16 04:51:15 +0000
commit891ad83098840851fb16f7ec4a664fc664792df0 (patch)
treee1d33d49cca9875ec515d3ee4ed0dc2686432941 /test/rss/rss-assertions.rb
parent0ebac90b0ebb07ad2aa99080c8509559a7ddc74d (diff)
* lib/rss/: untabified.
* test/rss/: untabified. * lib/rss/0.9.rb (RSS::Rss#to_s): inent -> indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/rss-assertions.rb')
-rw-r--r--test/rss/rss-assertions.rb266
1 files changed, 133 insertions, 133 deletions
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index ad7da1f6b4..40a72e93cd 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -1,139 +1,139 @@
# -*- tab-width: 2 -*- vim: ts=2
module Test
- module Unit
- module Assertions
- # For backward compatibility
- unless instance_methods.include?("assert_raise")
- def assert_raise(*args, &block)
- assert_raises(*args, &block)
- end
- end
- end
- end
+ module Unit
+ module Assertions
+ # For backward compatibility
+ unless instance_methods.include?("assert_raise")
+ def assert_raise(*args, &block)
+ assert_raises(*args, &block)
+ end
+ end
+ end
+ end
end
module RSS
- module Assertions
-
- def assert_parse(rss, assert_method, *args)
- send("assert_#{assert_method}", *args) do
- ::RSS::Parser.parse(rss)
- end
- send("assert_#{assert_method}", *args) do
- ::RSS::Parser.parse(rss, false).validate
- end
- end
-
- def assert_ns(prefix, uri)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise NSError")
- rescue ::RSS::NSError => e
- assert_equal(prefix, e.prefix)
- assert_equal(uri, e.uri)
- end
- end
- end
-
- def assert_missing_tag(tag, parent)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise MissingTagError")
- rescue ::RSS::MissingTagError => e
- assert_equal(tag, e.tag)
- assert_equal(parent, e.parent)
- end
- end
- end
-
- def assert_too_much_tag(tag, parent)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise TooMuchTagError")
- rescue ::RSS::TooMuchTagError => e
- assert_equal(tag, e.tag)
- assert_equal(parent, e.parent)
- end
- end
- end
-
- def assert_missing_attribute(tag, attrname)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise MissingAttributeError")
- rescue ::RSS::MissingAttributeError => e
- assert_equal(tag, e.tag)
- assert_equal(attrname, e.attribute)
- end
- end
- end
-
- def assert_not_excepted_tag(tag, parent)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise NotExceptedTagError")
- rescue ::RSS::NotExceptedTagError => e
- assert_equal(tag, e.tag)
- assert_equal(parent, e.parent)
- end
- end
- end
-
- def assert_not_available_value(tag, value)
- _wrap_assertion do
- begin
- yield
- flunk("Not raise NotAvailableValueError")
- rescue ::RSS::NotAvailableValueError => e
- assert_equal(tag, e.tag)
- assert_equal(value, e.value)
- end
- end
- end
-
- def assert_xml_stylesheet_attrs(xsl, attrs)
- _wrap_assertion do
- normalized_attrs = {}
- attrs.each do |name, value|
- normalized_attrs[name.to_s] = value
- end
- ::RSS::XMLStyleSheet::ATTRIBUTES.each do |name|
- assert_equal(normalized_attrs[name], xsl.send(name))
- end
- end
- end
-
- def assert_xml_stylesheet(target, xsl, attrs)
- _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)
- else
- assert_nil(target)
- assert_equal("", xsl.to_s)
- end
- end
- 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)
- end
- pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s*<rdf:RDF.*\z/m, "")
- assert_equal(xss_strs.join("\n"), pi_str)
- end
-
- end
+ module Assertions
+
+ def assert_parse(rss, assert_method, *args)
+ send("assert_#{assert_method}", *args) do
+ ::RSS::Parser.parse(rss)
+ end
+ send("assert_#{assert_method}", *args) do
+ ::RSS::Parser.parse(rss, false).validate
+ end
+ end
+
+ def assert_ns(prefix, uri)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise NSError")
+ rescue ::RSS::NSError => e
+ assert_equal(prefix, e.prefix)
+ assert_equal(uri, e.uri)
+ end
+ end
+ end
+
+ def assert_missing_tag(tag, parent)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise MissingTagError")
+ rescue ::RSS::MissingTagError => e
+ assert_equal(tag, e.tag)
+ assert_equal(parent, e.parent)
+ end
+ end
+ end
+
+ def assert_too_much_tag(tag, parent)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise TooMuchTagError")
+ rescue ::RSS::TooMuchTagError => e
+ assert_equal(tag, e.tag)
+ assert_equal(parent, e.parent)
+ end
+ end
+ end
+
+ def assert_missing_attribute(tag, attrname)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise MissingAttributeError")
+ rescue ::RSS::MissingAttributeError => e
+ assert_equal(tag, e.tag)
+ assert_equal(attrname, e.attribute)
+ end
+ end
+ end
+
+ def assert_not_excepted_tag(tag, parent)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise NotExceptedTagError")
+ rescue ::RSS::NotExceptedTagError => e
+ assert_equal(tag, e.tag)
+ assert_equal(parent, e.parent)
+ end
+ end
+ end
+
+ def assert_not_available_value(tag, value)
+ _wrap_assertion do
+ begin
+ yield
+ flunk("Not raise NotAvailableValueError")
+ rescue ::RSS::NotAvailableValueError => e
+ assert_equal(tag, e.tag)
+ assert_equal(value, e.value)
+ end
+ end
+ end
+
+ def assert_xml_stylesheet_attrs(xsl, attrs)
+ _wrap_assertion do
+ normalized_attrs = {}
+ attrs.each do |name, value|
+ normalized_attrs[name.to_s] = value
+ end
+ ::RSS::XMLStyleSheet::ATTRIBUTES.each do |name|
+ assert_equal(normalized_attrs[name], xsl.send(name))
+ end
+ end
+ end
+
+ def assert_xml_stylesheet(target, xsl, attrs)
+ _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)
+ else
+ assert_nil(target)
+ assert_equal("", xsl.to_s)
+ end
+ end
+ 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)
+ end
+ pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s*<rdf:RDF.*\z/m, "")
+ assert_equal(xss_strs.join("\n"), pi_str)
+ end
+
+ end
end