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 :marking= do
macro :marking
end
describe :fato= do
it "fails on invalid values" do
_([:foobar, 0]).wont_be_written_to subject, :fato
end
it "accepts valid values" do
_([nil, AIXM::Factory.fato]).must_be_written_to subject, :fato
end
end
describe :helicopter_class= do
it "fails on invalid values" do
_([:foobar, 123]).wont_be_written_to subject, :helicopter_class
end
it "accepts nil value" do
_([nil]).must_be_written_to subject, :helicopter_class
end
it "looks up valid values" do
_(subject.tap { |s| s.helicopter_class = 1 }.helicopter_class).must_equal :'1'
_(subject.tap { |s| s.helicopter_class = :OTHER }.helicopter_class).must_equal :other
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
LFNT
H1
43.99915000N
004.75154444E
WGE
141
FT
20
20
M
CONC
PAVED
FAIR
30
F
A
W
U
Cracks near the center
1500
KG
0.5
MPA
8
T
1
Continuous white lines
OTHER
Authorizaton by AD operator required
LFNT
H1
AIM
omnidirectional
LIM
GRN
lighting remarks
END
end
it "builds correct minimal OFMX" do
AIXM.ofmx!
%i(z length width helicopter_class marking status remarks).each { |a| subject.send(:"#{a}=", nil) }
%i(composition preparation condition pcn siwl_weight siwl_tire_pressure auw_weight remarks).each { |a| subject.surface.send(:"#{a}=", nil) }
subject.instance_eval { @lightings.clear }
_(subject.to_xml).must_equal <<~END
LFNT
H1
LFNT
H1
43.99915000N
004.75154444E
WGE
END
end
it "builds OFMX with mid" do
AIXM.ofmx!
AIXM.config.mid_region = 'LF'
_(subject.to_xml).must_match //
end
end
end