File: reference_spec.rb

package info (click to toggle)
ruby-roxml 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 800 kB
  • sloc: ruby: 4,133; xml: 1,013; makefile: 7
file content (34 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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