XML testing in Rails - Fixed attributes order in Builder::XmlMarkup in ruby -

Posted by Daniel Cukier on Stack Overflow See other posts from Stack Overflow or by Daniel Cukier
Published on 2010-04-30T20:14:04Z Indexed on 2010/04/30 20:17 UTC
Read the original article Hit count: 257

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about ruby-on-rails