diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 10:03:17 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 10:03:17 +0000 |
commit | abe876ed4e69d08868373051bebee6ab7e303954 (patch) | |
tree | fd5dfb00cf7a485e98ae179947b61093f6820a21 /test/rss/test_parser.rb | |
parent | cfbe158faea79c6c61f04e99d1309e26bf9f1e54 (diff) |
* test/rss/*: Test::Unit::TestCase -> RSS::TestCase and
Test::Unit::Assertions -> RSS::Assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_parser.rb')
-rw-r--r-- | test/rss/test_parser.rb | 220 |
1 files changed, 115 insertions, 105 deletions
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb index 6ad5e380c4..461d64d612 100644 --- a/test/rss/test_parser.rb +++ b/test/rss/test_parser.rb @@ -1,130 +1,138 @@ # -*- tab-width: 2 -*- vim: ts=2 -require "test/unit" +require "rss-testcase" + require "rss/1.0" -require "common" - -class TestParser < Test::Unit::TestCase - include TestRSSMixin - - def test_RDF - assert_ns("", RDF::URI) do - Parser.parse(<<-EOR) + +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) #{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_not_excepted_tag("image", "RDF") do - Parser.parse(make_RDF(<<-EOR)) + assert_not_excepted_tag("image", "RDF") do + Parser.parse(make_RDF(<<-EOR)) #{make_channel} #{make_item} #{make_image} #{make_textinput} EOR - end + end - 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 + 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 - 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> @@ -132,7 +140,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> @@ -141,7 +149,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> @@ -150,7 +158,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> @@ -160,15 +168,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> @@ -181,7 +189,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> @@ -195,7 +203,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> @@ -209,30 +217,30 @@ EOR </channel> EOR - end + 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> @@ -240,7 +248,7 @@ EOR </image> EOR - rss = make_RDF(<<-EOR) + rss = make_RDF(<<-EOR) #{make_channel} <image rdf:about="http://example.com/hoge.png"> <title>hoge</title> @@ -249,15 +257,15 @@ EOR </image> EOR - assert_missing_tag("url", "image") do - Parser.parse(rss) - end + assert_missing_tag("url", "image") 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") #{make_channel} <image rdf:about="http://example.com/hoge.png"> <title>hoge</title> @@ -266,25 +274,25 @@ EOR </image> EOR - 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"> @@ -292,8 +300,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"> @@ -302,9 +310,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"> @@ -313,7 +321,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"> @@ -323,11 +331,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} @@ -335,7 +343,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} @@ -343,7 +351,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} @@ -352,8 +360,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} @@ -363,9 +371,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} @@ -375,7 +383,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} @@ -386,7 +394,7 @@ EOR </textinput> EOR - assert_parse(make_RDF(<<-EOR), :nothing_raised) + assert_parse(make_RDF(<<-EOR), :nothing_raised) #{make_channel} #{make_image} #{make_item} @@ -398,32 +406,34 @@ EOR </textinput> EOR - 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 + 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 + 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 + |