Sha256: 5d7d11fdbf67950801ff37067ff093da37aff3c2c5cf452fd8e177e4c89a1988
Contents?: true
Size: 1.6 KB
Versions: 9
Compression:
Stored size: 1.6 KB
Contents
require_relative "../../test_helper" module Unit class TestAx < MiniTest::Test describe Ax do before do @xml = <<-XML <?xml version="1.0" encoding="utf-8"?> <response> <data> <article> <title>MagnumPI is awesome!!!</title> <category><![CDATA[ruby]]></category> </article> <article> <title>Netherlands beats Spain with 1-5 :)</title> <category>sport</category> </article> </data> </response> XML end it "parses XML like XmlSimple" do assert_equal XmlSimple.xml_in(@xml), Ax.new(@xml).to_enum assert_equal XmlSimple.xml_in(@xml), Ax.new(@xml).to_hash assert_equal({ "data" => [{ "article" => [ { "title" => ["MagnumPI is awesome!!!"], "category" => ["ruby"] }, { "title" => ["Netherlands beats Spain with 1-5 :)"], "category" => ["sport"] } ] }] }, Ax.new(@xml).to_hash) end it "can iterate through an XML document" do articles = [] Ax.new(@xml).each("/*/article") do |article| articles << article end assert_equal [ { "title" => ["MagnumPI is awesome!!!"], "category" => ["ruby"] }, { "title" => ["Netherlands beats Spain with 1-5 :)"], "category" => ["sport"] } ], articles end end end end
Version data entries
9 entries across 9 versions & 1 rubygems