summaryrefslogtreecommitdiff
path: root/test/rss/test_parser.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/test_parser.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/test_parser.rb')
-rw-r--r--test/rss/test_parser.rb458
1 files changed, 229 insertions, 229 deletions
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 5b15ccb908..3fd26bffb4 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -7,139 +7,139 @@ require "rss/2.0"
require "rss/dublincore"
module RSS
- class TestParser < TestCase
-
- def setup
- @_default_parser = Parser.default_parser
- end
-
- def teardown
- Parser.default_parser = @_default_parser
- end
-
- def test_RDF
- assert_ns("", RDF::URI) do
- Parser.parse(<<-EOR)
+ class TestParser < TestCase
+
+ def setup
+ @_default_parser = Parser.default_parser
+ end
+
+ def teardown
+ Parser.default_parser = @_default_parser
+ end
+
+ def test_RDF
+ assert_ns("", RDF::URI) do
+ Parser.parse(<<-EOR)
#{make_xmldecl}
<RDF/>
EOR
- end
+ end
- assert_ns("", RDF::URI) do
- Parser.parse(<<-EOR)
+ assert_ns("", RDF::URI) do
+ Parser.parse(<<-EOR)
#{make_xmldecl}
<RDF xmlns="hoge"/>
EOR
- end
+ end
- assert_ns("rdf", RDF::URI) do
- Parser.parse(<<-EOR)
+ assert_ns("rdf", RDF::URI) do
+ Parser.parse(<<-EOR)
#{make_xmldecl}
<rdf:RDF xmlns:rdf="hoge"/>
EOR
- end
+ end
- assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
+ assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
#{make_xmldecl}
<rdf:RDF xmlns:rdf="#{RSS::RDF::URI}"/>
EOR
- assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
+ assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
#{make_xmldecl}
<RDF xmlns="#{RSS::RDF::URI}"/>
EOR
- assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
+ assert_parse(<<-EOR, :missing_tag, "channel", "RDF")
#{make_xmldecl}
<RDF xmlns="#{RSS::RDF::URI}"/>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
#{make_channel}
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
#{make_channel}
#{make_image}
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
#{make_channel}
#{make_textinput}
EOR
- assert_too_much_tag("image", "RDF") do
- Parser.parse(make_RDF(<<-EOR))
+ assert_too_much_tag("image", "RDF") do
+ Parser.parse(make_RDF(<<-EOR))
#{make_channel}
#{make_image}
#{make_image}
#{make_item}
#{make_textinput}
EOR
- end
+ end
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_item}
#{make_image}
#{make_textinput}
EOR
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_item}
#{make_textinput}
#{make_image}
EOR
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_image}
#{make_item}
EOR
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_image}
#{make_item}
#{make_textinput}
EOR
- 1.step(15, 3) do |i|
- rss = make_RDF() do
- res = make_channel
- i.times { res << make_item }
- res
- end
- assert_parse(rss, :nothing_raised)
- end
+ 1.step(15, 3) do |i|
+ rss = make_RDF() do
+ res = make_channel
+ i.times { res << make_item }
+ res
+ end
+ assert_parse(rss, :nothing_raised)
+ end
- end
+ end
- def test_channel
+ def test_channel
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "channel", "about")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "channel", "about")
<channel />
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "channel")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "channel")
<channel rdf:about="http://example.com/"/>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "channel")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "channel")
<channel rdf:about="http://example.com/">
<title>hoge</title>
</channel>
EOR
- assert_parse(make_RDF(<<EOR), :missing_tag, "description", "channel")
+ assert_parse(make_RDF(<<EOR), :missing_tag, "description", "channel")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
</channel>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -147,7 +147,7 @@ EOR
</channel>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "resource")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "resource")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -156,7 +156,7 @@ EOR
</channel>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "items", "channel")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -165,7 +165,7 @@ EOR
</channel>
EOR
- rss = make_RDF(<<-EOR)
+ rss = make_RDF(<<-EOR)
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -175,15 +175,15 @@ EOR
</channel>
EOR
- assert_missing_tag("Seq", "items") do
- Parser.parse(rss)
- end
+ assert_missing_tag("Seq", "items") do
+ Parser.parse(rss)
+ end
- assert_missing_tag("item", "RDF") do
- Parser.parse(rss, false).validate
- end
+ assert_missing_tag("item", "RDF") do
+ Parser.parse(rss, false).validate
+ end
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -196,7 +196,7 @@ EOR
</channel>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "resource")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "resource")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -210,7 +210,7 @@ EOR
</channel>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -224,11 +224,11 @@ EOR
</channel>
EOR
- end
+ end
- def test_rdf_li
+ def test_rdf_li
- rss = make_RDF(<<-EOR)
+ rss = make_RDF(<<-EOR)
<channel rdf:about="http://example.com/">
<title>hoge</title>
<link>http://example.com/</link>
@@ -244,41 +244,41 @@ EOR
#{make_item}
EOR
- source = Proc.new do |rdf_li_attr|
- eval(%Q[%Q[#{rss}]], binding)
- end
+ source = Proc.new do |rdf_li_attr|
+ eval(%Q[%Q[#{rss}]], binding)
+ end
- attr = %q[resource="http://example.com/hoge"]
- assert_parse(source.call(attr), :nothing_raised)
+ attr = %q[resource="http://example.com/hoge"]
+ assert_parse(source.call(attr), :nothing_raised)
- attr = %q[rdf:resource="http://example.com/hoge"]
- assert_parse(source.call(attr), :nothing_raised)
+ attr = %q[rdf:resource="http://example.com/hoge"]
+ assert_parse(source.call(attr), :nothing_raised)
- assert_parse(source.call(""), :missing_attribute, "li", "resource")
- end
+ assert_parse(source.call(""), :missing_attribute, "li", "resource")
+ end
- def test_image
+ def test_image
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "about")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "image", "about")
#{make_channel}
<image>
</image>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "image")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "image")
#{make_channel}
<image rdf:about="http://example.com/hoge.png">
</image>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "url", "image")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "url", "image")
#{make_channel}
<image rdf:about="http://example.com/hoge.png">
<title>hoge</title>
</image>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "image")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "image")
#{make_channel}
<image rdf:about="http://example.com/hoge.png">
<title>hoge</title>
@@ -286,7 +286,7 @@ EOR
</image>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "item", "RDF")
#{make_channel}
<image rdf:about="http://example.com/hoge.png">
<title>hoge</title>
@@ -295,7 +295,7 @@ EOR
</image>
EOR
- rss = make_RDF(<<-EOR)
+ rss = make_RDF(<<-EOR)
#{make_channel}
<image rdf:about="http://example.com/hoge.png">
<link>http://example.com/</link>
@@ -304,33 +304,33 @@ EOR
</image>
EOR
- assert_missing_tag("item", "RDF") do
- Parser.parse(rss)
- end
+ assert_missing_tag("item", "RDF") do
+ Parser.parse(rss)
+ end
- assert_missing_tag("item", "RDF") do
- Parser.parse(rss, false).validate
- end
+ assert_missing_tag("item", "RDF") do
+ Parser.parse(rss, false).validate
+ end
- end
+ end
- def test_item
+ def test_item
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "item", "about")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "item", "about")
#{make_channel}
#{make_image}
<item>
</item>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "item")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "item")
#{make_channel}
#{make_image}
<item rdf:about="http://example.com/hoge.html">
</item>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "item")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "item")
#{make_channel}
#{make_image}
<item rdf:about="http://example.com/hoge.html">
@@ -338,8 +338,8 @@ EOR
</item>
EOR
- assert_too_much_tag("title", "item") do
- Parser.parse(make_RDF(<<-EOR))
+ assert_too_much_tag("title", "item") do
+ Parser.parse(make_RDF(<<-EOR))
#{make_channel}
#{make_image}
<item rdf:about="http://example.com/hoge.html">
@@ -348,9 +348,9 @@ EOR
<link>http://example.com/hoge.html</link>
</item>
EOR
- end
+ end
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_image}
<item rdf:about="http://example.com/hoge.html">
@@ -359,7 +359,7 @@ EOR
</item>
EOR
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_image}
<item rdf:about="http://example.com/hoge.html">
@@ -369,11 +369,11 @@ EOR
</item>
EOR
- end
+ end
- def test_textinput
+ def test_textinput
- assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "about")
+ assert_parse(make_RDF(<<-EOR), :missing_attribute, "textinput", "about")
#{make_channel}
#{make_image}
#{make_item}
@@ -381,7 +381,7 @@ EOR
</textinput>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "textinput")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "title", "textinput")
#{make_channel}
#{make_image}
#{make_item}
@@ -389,7 +389,7 @@ EOR
</textinput>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "description", "textinput")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "description", "textinput")
#{make_channel}
#{make_image}
#{make_item}
@@ -398,8 +398,8 @@ EOR
</textinput>
EOR
- assert_too_much_tag("title", "textinput") do
- Parser.parse(make_RDF(<<-EOR))
+ assert_too_much_tag("title", "textinput") do
+ Parser.parse(make_RDF(<<-EOR))
#{make_channel}
#{make_image}
#{make_item}
@@ -409,9 +409,9 @@ EOR
<description>hogehoge</description>
</textinput>
EOR
- end
+ end
- assert_parse(make_RDF(<<-EOR), :missing_tag, "name", "textinput")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "name", "textinput")
#{make_channel}
#{make_image}
#{make_item}
@@ -421,7 +421,7 @@ EOR
</textinput>
EOR
- assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "textinput")
+ assert_parse(make_RDF(<<-EOR), :missing_tag, "link", "textinput")
#{make_channel}
#{make_image}
#{make_item}
@@ -432,7 +432,7 @@ EOR
</textinput>
EOR
- assert_parse(make_RDF(<<-EOR), :nothing_raised)
+ assert_parse(make_RDF(<<-EOR), :nothing_raised)
#{make_channel}
#{make_image}
#{make_item}
@@ -444,170 +444,170 @@ EOR
</textinput>
EOR
- end
+ end
- def test_rss20
-
- assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss")
+ def test_rss20
+
+ assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss")
EOR
- assert_parse(make_rss20(<<-EOR), :nothing_raised)
+ assert_parse(make_rss20(<<-EOR), :nothing_raised)
#{make_channel20("")}
EOR
- end
-
- def test_cloud20
-
- attrs = [
- ["domain", CLOUD_DOMAIN],
- ["port", CLOUD_PORT],
- ["path", CLOUD_PATH],
- ["registerProcedure", CLOUD_REGISTER_PROCEDURE],
- ["protocol", CLOUD_PROTOCOL],
- ]
-
- (attrs.size + 1).times do |i|
- missing_attr = attrs[i]
- if missing_attr
- meth = :missing_attribute
- args = ["cloud", missing_attr[0]]
- else
- meth = :nothing_raised
- args = []
- end
-
- cloud_attrs = []
- attrs.each_with_index do |attr, j|
- unless i == j
- cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"]
- end
- end
-
- assert_parse(make_rss20(<<-EOR), meth, *args)
+ end
+
+ def test_cloud20
+
+ attrs = [
+ ["domain", CLOUD_DOMAIN],
+ ["port", CLOUD_PORT],
+ ["path", CLOUD_PATH],
+ ["registerProcedure", CLOUD_REGISTER_PROCEDURE],
+ ["protocol", CLOUD_PROTOCOL],
+ ]
+
+ (attrs.size + 1).times do |i|
+ missing_attr = attrs[i]
+ if missing_attr
+ meth = :missing_attribute
+ args = ["cloud", missing_attr[0]]
+ else
+ meth = :nothing_raised
+ args = []
+ end
+
+ cloud_attrs = []
+ attrs.each_with_index do |attr, j|
+ unless i == j
+ cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"]
+ end
+ end
+
+ assert_parse(make_rss20(<<-EOR), meth, *args)
#{make_channel20(%Q[<cloud #{cloud_attrs.join("\n")}/>])}
EOR
- end
+ end
- end
+ end
- def test_source20
+ def test_source20
- assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url")
+ assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url")
#{make_channel20(make_item20(%Q[<source>Example</source>]))}
EOR
- assert_parse(make_rss20(<<-EOR), :nothing_raised)
+ assert_parse(make_rss20(<<-EOR), :nothing_raised)
#{make_channel20(make_item20(%Q[<source url="http://example.com/" />]))}
EOR
- assert_parse(make_rss20(<<-EOR), :nothing_raised)
+ assert_parse(make_rss20(<<-EOR), :nothing_raised)
#{make_channel20(make_item20(%Q[<source url="http://example.com/">Example</source>]))}
EOR
- end
-
- def test_enclosure20
-
- attrs = [
- ["url", ENCLOSURE_URL],
- ["length", ENCLOSURE_LENGTH],
- ["type", ENCLOSURE_TYPE],
- ]
-
- (attrs.size + 1).times do |i|
- missing_attr = attrs[i]
- if missing_attr
- meth = :missing_attribute
- args = ["enclosure", missing_attr[0]]
- else
- meth = :nothing_raised
- args = []
- end
-
- enclosure_attrs = []
- attrs.each_with_index do |attr, j|
- unless i == j
- enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"]
- end
- end
-
- assert_parse(make_rss20(<<-EOR), meth, *args)
+ end
+
+ def test_enclosure20
+
+ attrs = [
+ ["url", ENCLOSURE_URL],
+ ["length", ENCLOSURE_LENGTH],
+ ["type", ENCLOSURE_TYPE],
+ ]
+
+ (attrs.size + 1).times do |i|
+ missing_attr = attrs[i]
+ if missing_attr
+ meth = :missing_attribute
+ args = ["enclosure", missing_attr[0]]
+ else
+ meth = :nothing_raised
+ args = []
+ end
+
+ enclosure_attrs = []
+ attrs.each_with_index do |attr, j|
+ unless i == j
+ enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"]
+ end
+ end
+
+ assert_parse(make_rss20(<<-EOR), meth, *args)
#{make_channel20(%Q[
#{make_item20(%Q[
<enclosure
#{enclosure_attrs.join("\n")} />
- ])}
- ])}
-EOR
-
- end
-
- end
-
- def test_category20
-
- attrs = [
- ["domain", CATEGORY_DOMAIN],
- ]
-
- (attrs.size + 1).times do |i|
- missing_attr = attrs[i]
- if missing_attr
- meth = :missing_attribute
- args = ["category", missing_attr[0]]
- else
- meth = :nothing_raised
- args = []
- end
-
- category_attrs = []
- attrs.each_with_index do |attr, j|
- unless i == j
- category_attrs << %Q[#{attr[0]}="#{attr[1]}"]
- end
- end
-
- ["", "Example Text"].each do |text|
- assert_parse(make_rss20(<<-EOR), meth, *args)
+ ])}
+ ])}
+EOR
+
+ end
+
+ end
+
+ def test_category20
+
+ attrs = [
+ ["domain", CATEGORY_DOMAIN],
+ ]
+
+ (attrs.size + 1).times do |i|
+ missing_attr = attrs[i]
+ if missing_attr
+ meth = :missing_attribute
+ args = ["category", missing_attr[0]]
+ else
+ meth = :nothing_raised
+ args = []
+ end
+
+ category_attrs = []
+ attrs.each_with_index do |attr, j|
+ unless i == j
+ category_attrs << %Q[#{attr[0]}="#{attr[1]}"]
+ end
+ end
+
+ ["", "Example Text"].each do |text|
+ assert_parse(make_rss20(<<-EOR), meth, *args)
#{make_channel20(%Q[
#{make_item20(%Q[
<category
#{category_attrs.join("\n")}>#{text}</category>
- ])}
- ])}
+ ])}
+ ])}
EOR
- end
- end
+ end
+ end
- end
+ end
- def test_ignore
+ def test_ignore
- rss = make_RDF(<<-EOR)
+ rss = make_RDF(<<-EOR)
#{make_channel}
#{make_item}
<a/>
EOR
- assert_parse(rss, :nothing_raised)
+ assert_parse(rss, :nothing_raised)
- assert_not_excepted_tag("a", "RDF") do
- Parser.parse(rss, true, false)
- end
+ assert_not_excepted_tag("a", "RDF") do
+ Parser.parse(rss, true, false)
+ end
- end
+ end
- def test_default_parser
- assert_nothing_raised() do
- Parser.default_parser = RSS::AVAILABLE_PARSERS.first
- end
+ def test_default_parser
+ assert_nothing_raised() do
+ Parser.default_parser = RSS::AVAILABLE_PARSERS.first
+ end
- assert_raise(RSS::NotValidXMLParser) do
- Parser.default_parser = RSS::Parser
- end
- end
+ assert_raise(RSS::NotValidXMLParser) do
+ Parser.default_parser = RSS::Parser
+ end
+ end
- end
+ end
end