Skip to content

Commit 0422385

Browse files
author
Nathan Sutton
committed
Adds more specs cover when YAML and Symbol are specifically allowed
1 parent 7486897 commit 0422385

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/parser_shared_example.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,13 @@
323323
@xml = "<tag type=\"yaml\">--- \n1: returns an integer\n:message: Have a nice day\narray: \n- has-dashes: true\n has_underscores: true\n</tag>"
324324
end
325325

326-
it "raises MultiXML::DisallowedTypeError" do
326+
it "raises MultiXML::DisallowedTypeError by default" do
327327
expect{ MultiXml.parse(@xml)['tag'] }.to raise_error(MultiXml::DisallowedTypeError)
328328
end
329+
330+
it "returns the correctly parsed YAML when the type is allowed" do
331+
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq({:message => "Have a nice day", 1 => "returns an integer", "array" => [{"has-dashes" => true, "has_underscores" => true}]})
332+
end
329333
end
330334

331335
context "with an attribute type=\"symbol\"" do
@@ -336,6 +340,10 @@
336340
it "raises MultiXML::DisallowedTypeError" do
337341
expect{ MultiXml.parse(@xml)['tag'] }.to raise_error(MultiXml::DisallowedTypeError)
338342
end
343+
344+
it "returns the correctly parsed Symbol when the type is allowed" do
345+
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq(:my_symbol)
346+
end
339347
end
340348

341349
context "with an attribute type=\"file\"" do
@@ -442,9 +450,13 @@
442450
@xml = "<tag type=\"#{type}\"/>"
443451
end
444452

445-
it "raises MultiXml::DisallowedTypeError" do
453+
it "raises MultiXml::DisallowedTypeError by default" do
446454
expect{ MultiXml.parse(@xml)['tag']}.to raise_error(MultiXml::DisallowedTypeError)
447455
end
456+
457+
it "returns nil when the type is allowed" do
458+
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to be_nil
459+
end
448460
end
449461
end
450462

0 commit comments

Comments
 (0)