Sha256: 7b3e59959e1ef4e3983a350c63473009d94fa721193c610cadb232748adc9900
Contents?: true
Size: 1.39 KB
Versions: 11
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' module Resync describe XML do describe '#element' do it 'returns an element unchanged' do elem = REXML::Element.new('foo') expect(XML.element(elem)).to be(elem) end it 'returns the root element of a string document' do xml_str = '<?xml version="1.0"?><foo><bar/><baz/></foo>' elem = XML.element(xml_str) expect(elem).to be_a(REXML::Element) expect(elem).to be_xml('<foo><bar/><baz/></foo>') end it 'returns the root element of a REXML::Document' do xml_str = '<?xml version="1.0"?><foo><bar/><baz/></foo>' doc = REXML::Document.new(xml_str) elem = XML.element(doc) expect(elem).to be_a(REXML::Element) expect(elem).to be_xml(doc.root) end it 'parses an XML fragment as an element' do xml_str = '<foo><bar/><baz/></foo>' elem = XML.element(xml_str) expect(elem).to be_a(REXML::Element) expect(elem).to be_xml(xml_str) end it 'parses a file as an XML document' do file = File.new('spec/data/examples/example-1.xml') elem = XML.element(file) expect(elem).to be_a(REXML::Element) expect(elem.name).to eq('urlset') end it 'fails when it gets something other than XML' do data = 12_345 expect { XML.element(data) }.to raise_exception end end end end
Version data entries
11 entries across 11 versions & 1 rubygems