Sha256: e76285154bea9d77b0064c06e4c9348fbf44b86aa99f94e343c7d1662b30eb02

Contents?: true

Size: 754 Bytes

Versions: 4

Compression:

Stored size: 754 Bytes

Contents

# encoding: utf-8
require_relative './spec_helper'

describe ROXML::XMLRef do

  class Org
    include ROXML
    xml_accessor :fines,
                 :in   => 'policy/fines',
                 :from => 'fine',
                 :as   => { :key => 'name', :value => 'desc' }
  end

  let(:org) do
    org = Org.new
    org.fines = { 'name' => 'a fine', 'desc' => 'a desc' }
    org
  end

  let(:reference) do
    Org.roxml_attrs.first.to_ref(org)
  end

  it "should properly reconstruct wrappers with multiple elements" do

    expect(reference).to be_a(ROXML::XMLHashRef)

    xml = ROXML::XML.new_node('org').tap do |root|
      reference.update_xml(root, org.fines)
    end

    expect(xml_path( xml )).to eq(%w{org policy fines fine name})
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roxml-4.2.0 spec/reference_spec.rb
roxml-4.1.1 spec/reference_spec.rb
roxml-4.1.0 spec/reference_spec.rb
roxml-4.0.0 spec/reference_spec.rb