0

I have an XML file hw.xml that contains hardware info for a node.

<node hostname="my_hostname">
  <volume raid="RAID-10">
   ....
   ....
  </volume>
</node> 

how to mock the xml file such that it should fail the test cases if raid attribute is not equal to RAID-10?

Abhishek J
  • 101
  • 7

1 Answers1

1

You can create a XML mock using Nokogiri, like this:

builder = Nokogiri::XML::Builder.new do |xml|
  xml.root {
    xml.products {
      xml.widget {
        xml.id_ "10"
        xml.name "Awesome widget"
      }
    }
  }
end
puts builder.to_xml

You can see the documentation for this here.