summaryrefslogtreecommitdiff
path: root/test/rss/test_parser.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-22 05:41:33 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-22 05:41:33 +0000
commitbe7999fd3dd2868ff382a7611e978aa2f8ac61c2 (patch)
tree3e2486e8434f30b7281f1a61322c732f7b01c05f /test/rss/test_parser.rb
parent17743ce0a8a74095e4f111cff4c102d5d99b5a7a (diff)
* lib/rss/parser.rb (RSS::Parser#initialize): accept HTTP/FTP
URI and local file path too. * test/rss/test_parser.rb (RSS::TestParser#test_parse): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_parser.rb')
-rw-r--r--test/rss/test_parser.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 6739a11..adf0864 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -1,3 +1,5 @@
+require "fileutils"
+
require "rss-testcase"
require "rss/1.0"
@@ -9,10 +11,19 @@ module RSS
def setup
@_default_parser = Parser.default_parser
+ @rss10 = make_RDF(<<-EOR)
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+EOR
+ @rss_file = "rss10.rdf"
+ File.open(@rss_file, "w") {|f| f.print(@rss10)}
end
def teardown
Parser.default_parser = @_default_parser
+ FileUtils.rm_f(@rss_file)
end
def test_RDF
@@ -585,7 +596,7 @@ EOR
end
def test_default_parser
- assert_nothing_raised() do
+ assert_nothing_raised do
Parser.default_parser = RSS::AVAILABLE_PARSERS.first
end
@@ -594,6 +605,19 @@ EOR
end
end
+ def test_parse
+ assert_not_nil(RSS::Parser.parse(@rss_file))
+
+ garbage_rss_file = @rss_file + "-garbage"
+ if RSS::Parser.default_parser.name == "RSS::XMLParserParser"
+ assert_raise(RSS::NotWellFormedError) do
+ RSS::Parser.parse(garbage_rss_file)
+ end
+ else
+ assert_nil(RSS::Parser.parse(garbage_rss_file))
+ end
+ end
+
end
end