spec/unit/braintree/xml/parser_spec.rb in braintree-2.48.0 vs spec/unit/braintree/xml/parser_spec.rb in braintree-2.48.1
- old
+ new
@@ -55,12 +55,26 @@
</root>
END
xml.should parse_to(:root => {:customers => [{:name => "Adam"}, {:name => "Ben"}]})
end
- it "parses using libxml" do
+ it "parses using libxml when not using ruby 2.0" do
xml = "<root><foo type=\"integer\">123</foo></root>"
+ stub_const("RUBY_VERSION", "2.1.1")
::Braintree::Xml::Libxml.should_receive(:parse).and_call_original
+
+ Braintree::Xml::Parser.hash_from_xml(xml)
+ end
+
+ it "parses using rexml when using ruby 2.0 to avoid Libxml segfault" do
+ segfault_prone_library_in_ruby_2_0 = ::Braintree::Xml::Libxml
+
+ xml = "<root><foo type=\"integer\">123</foo></root>"
+ stub_const("RUBY_VERSION", "2.0.0")
+
+ ::Braintree::Xml::Rexml.should_receive(:parse).and_call_original
+ segfault_prone_library_in_ruby_2_0.should_not_receive(:parse)
+
Braintree::Xml::Parser.hash_from_xml(xml)
end
end
end