XML testing in Rails - Fixed attributes order in Builder::XmlMarkup in ruby -
- by Daniel Cukier
I have the following test in my Rails Application:
it "should validate xml" do
builder = Builder::XmlMarkup.new
builder.server(:name => "myServer", :ip => "192.168.1.1").should == "<server name=\"myServer\" ip=\"192.168.1.1\"/>"
end
The problem is that this test passes sometimes, because the order of the xml tag attributes is unpredictable. Is there a way to force this order? Is there any other easy way to build xml?
This example is simplified, I have a big XML. My problem is that I want to do an integration test, which compares a WebService call with a fixed XML file. Otherwise, I would have to parse the xml and verify element by element in the XML.