summaryrefslogtreecommitdiff
path: root/test/rss/test_parser.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-12 09:06:00 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-12 09:06:00 +0000
commit97c07d3487aac92f72469d0f955eda12c851e87f (patch)
treec983fa577af3ab2c548316cb1631a8838e234615 /test/rss/test_parser.rb
parent961cbe5262946732e47182714ea3b4395a71227d (diff)
rss: Add option Hash support to RSS::Parser.parse
Available options: * :validate * :ignore_unknown_element * :parser_class git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_parser.rb')
-rw-r--r--test/rss/test_parser.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 7d64657d579..4e7cc1b963f 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -61,5 +61,61 @@ EOR
EOR
end
end
+
+ def test_parse_option_validate_nil
+ assert_raise(RSS::MissingTagError) do
+ RSS::Parser.parse(make_RDF(<<-RDF), :validate => nil)
+ RDF
+ end
+ end
+
+ def test_parse_option_validate_true
+ assert_raise(RSS::MissingTagError) do
+ RSS::Parser.parse(make_RDF(<<-RDF), :validate => true)
+ RDF
+ end
+ end
+
+ def test_parse_option_validate_false
+ rdf = RSS::Parser.parse(make_RDF(<<-RDF), :validate => false)
+ RDF
+ assert_nil(rdf.channel)
+ end
+
+ def test_parse_option_ignore_unknown_element_nil
+ assert_nothing_raised do
+ RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => nil)
+<unknown/>
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+ RDF
+ end
+ end
+
+ def test_parse_option_ignore_unknown_element_true
+ assert_nothing_raised do
+ RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => true)
+<unknown/>
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+ RDF
+ end
+ end
+
+ def test_parse_option_ignore_unknown_element_false
+ assert_raise(RSS::NotExpectedTagError) do
+ RSS::Parser.parse(make_RDF(<<-RDF), :ignore_unknown_element => false)
+<unknown/>
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+ RDF
+ end
+ end
end
end