Sha256: c2d5a0f1136702dce5273f03ef273c92eaa9e64565b6316e27375da7bdf8207a
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
require "spec_helper" module NamespaceSpec class NestedChild < Lutaml::Model::Serializable attribute :name, :string xml do root "NestedChild" map_element :name, to: :name end end class Child < Lutaml::Model::Serializable attribute :nested_child, NestedChild xml do root "NestedChild" map_element :NestedChild, to: :nested_child end end class Parent < Lutaml::Model::Serializable attribute :child, Child xml do root "Parent" namespace "https://abc.com" map_element :Child, to: :child end end end RSpec.describe "NamespaceSpec" do let(:parsed) { NamespaceSpec::Parent.from_xml(xml) } let(:xml) do <<~XML <Parent xmlns="https://abc.com"> <Child> <NestedChild> <name>Rogger moore</name> </NestedChild> </Child> </Parent> XML end it "parses nested child using root namespace" do expect(parsed.child.nested_child.name).to eq("Rogger moore") end it "round-trips xml" do expect(parsed.to_xml).to be_equivalent_to(xml) end end
Version data entries
4 entries across 4 versions & 1 rubygems