require File.dirname(__FILE__) + '/../spec_helper.rb' describe ROXML::XML::Parser do before do # quiet the error handler ROXML::XML::Error.reset_handler end it "should raise on malformed xml" do proc { Book.from_xml(fixture(:book_malformed)) }.should raise_error(ROXML::XML::Error) end it "should escape invalid characters on output to text node" do node = ROXML::XML::Node.new("entities") node.content = " < > ' \" & " if ROXML::XML_PARSER == 'libxml' node.to_s.should == " < > ' \" & " else node.to_s.should == " < > ' " & " end end it "should esape invalid characters for attribute name" do node = ROXML::XML::Node.new("attr_holder") node.attributes["entities"] = "\"'<>&" if ROXML::XML_PARSER == 'libxml' node.to_s.should == %{} else node.to_s.should == %{} end end end describe ROXML::XML::Document do describe "#save" do context "with rexml parser" do it "should defer to existing XMLDecl" do if ROXML::XML_PARSER == 'rexml' @doc = ROXML::XML::Document.new @doc << REXML::XMLDecl.new('1.1') @doc.save('spec/xml/decl_test.xml') ROXML::XML::Parser.parse(File.read('spec/xml/decl_test.xml')).to_s.should == ROXML::XML::Parser.parse(%{}).to_s end end end end end