require_relative '../../../spec_helper' describe AIXM::Component::Helipad do subject do AIXM::Factory.airport.helipads.first 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 = 'h1' }.name.must_equal 'H1' end end describe :xy= do macro :xy it "fails on nil value" do [nil].wont_be_written_to subject, :xy end end describe :z= do macro :z_qnh end describe :length= do it "fails on invalid values" do [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :length end it "accepts nil value" do [nil].must_be_written_to subject, :length end end describe :width= do it "fails on invalid values" do [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :width end it "accepts nil value" do [nil].must_be_written_to subject, :width end end describe :composition= do it "fails on invalid values" do [:foobar, 123].wont_be_written_to subject, :composition end it "accepts nil value" do [nil].must_be_written_to subject, :composition end it "looks up valid values" do subject.tap { |s| s.composition = :macadam }.composition.must_equal :macadam subject.tap { |s| s.composition = :GRADE }.composition.must_equal :graded_earth end end describe :status= do it "fails on invalid values" do [:foobar, 123].wont_be_written_to subject, :status end it "accepts nil value" do [nil].must_be_written_to subject, :status end it "looks up valid values" do subject.tap { |s| s.status = :closed }.status.must_equal :closed subject.tap { |s| s.status = :SPOWER }.status.must_equal :secondary_power end end describe :remarks= do macro :remarks end describe :xml= do it "builds correct complete OFMX" do AIXM.ofmx! subject.to_xml.must_equal <<~END LFNT H1 43.99915000N 004.75154444E WGE 141 FT 20 20 M GRASS OTHER Authorizaton by AD operator required END end it "builds correct minimal OFMX" do AIXM.ofmx! subject.z = subject.length = subject.width = subject.composition = subject.status = subject.remarks = nil subject.to_xml.must_equal <<~END LFNT H1 43.99915000N 004.75154444E WGE END end end end