1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rss/test_parser.rb
shugo 1474dd064b * test/-ext-/test_printf.rb, test/rss/test_parser.rb,
test/ruby/test_array.rb, test/ruby/test_hash.rb,
  test/ruby/test_m17n.rb, test/ruby/test_marshal.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb: don't use
  untrusted?, untrust, and trust to avoid warnings in case $VERBOSE is
  true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 05:41:44 +00:00

64 lines
1.4 KiB
Ruby

require "tempfile"
require_relative "rss-testcase"
require "rss/1.0"
require "rss/dublincore"
module RSS
class TestParser < TestCase
def setup
@_default_parser = Parser.default_parser
@rss10 = make_RDF(<<-EOR)
#{make_channel}
#{make_item}
#{make_textinput}
#{make_image}
EOR
@rss_tmp = Tempfile.new(%w"rss10- .rdf")
@rss_tmp.print(@rss10)
@rss_tmp.close
@rss_file = @rss_tmp.path.untaint
end
def teardown
Parser.default_parser = @_default_parser
@rss_tmp.close(true)
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
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
def test_parse_tag_includes_hyphen
assert_nothing_raised do
RSS::Parser.parse(make_RDF(<<-EOR))
<xCal:x-calconnect-venue xmlns:xCal="urn:ietf:params:xml:ns:xcal" />
#{make_channel}
#{make_item}
#{make_textinput}
#{make_image}
EOR
end
end
end
end