Sha256: 715485152fa8ac0404eecb0bec690b4003b3d6dc30774284edad768d6b96ff3e

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 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 '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

8 entries across 8 versions & 1 rubygems

Version Path
resync-0.3.0 spec/unit/resync/xml/xml_spec.rb
resync-0.2.2 spec/unit/resync/xml/xml_spec.rb
resync-0.2.1 spec/unit/resync/xml/xml_spec.rb
resync-0.2.0 spec/unit/resync/xml/xml_spec.rb
resync-0.1.3 spec/unit/resync/xml/xml_spec.rb
resync-0.1.2 spec/unit/resync/xml/xml_spec.rb
resync-0.1.1 spec/unit/resync/xml/xml_spec.rb
resync-0.1.0 spec/unit/resync/xml/xml_spec.rb