require_relative '../../../spec_helper' describe AIXM::Feature::Organisation do subject do AIXM::Factory.organisation end describe :name= do it "fails on invalid values" do _([nil, :foobar, 123]).wont_be_written_to subject, :name end it "upcases and transcodes valid values" do _(subject.tap { |s| s.name = 'Nîmes-Alès' }.name).must_equal 'NIMES-ALES' end end describe :type= do it "fails on invalid values" do _([nil, :foobar, 123]).wont_be_written_to subject, :type end it "looks up valid values" do _(subject.tap { |s| s.type = :state }.type).must_equal :state _(subject.tap { |s| s.type = :IO }.type).must_equal :international_organisation end end describe :id= do it "fails on invalid values" do _([:foobar, 123]).wont_be_written_to subject, :id end it "accepts nil value" do _([nil]).must_be_written_to subject, :id end it "upcases valid values" do _(subject.tap { |s| s.id = 'lf' }.id).must_equal 'LF' end end describe :remarks= do macro :remarks end describe :to_xml do it "builds correct complete OFMX" do AIXM.ofmx! _(subject.to_xml).must_equal <<~END FRANCE LF S Oversea departments not included END end it "builds correct minimal OFMX" do AIXM.ofmx! subject.id = subject.remarks = nil _(subject.to_xml).must_equal <<~END FRANCE S END end it "builds OFMX with mid" do AIXM.ofmx! AIXM.config.mid_region = 'LF' _(subject.to_xml).must_match // end end end