require_relative '../../../spec_helper'
describe AIXM::Feature::Airspace do
context "incomplete" do
subject do
AIXM.airspace(name: 'foobar', type: 'D')
end
describe :complete? do
it "must fail validation" do
subject.wont_be :complete?
end
end
end
context "complete" do
context "with one class layer" do
subject do
AIXM::Factory.polygon_airspace
end
describe :complete? do
it "must pass validation" do
subject.must_be :complete?
end
end
describe :to_digest do
it "must return digest of payload" do
subject.to_digest.must_equal 367297292
end
end
describe :to_xml do
it "must build correct XML with OFM extensions" do
digest = subject.to_digest
subject.to_xml(:ofm).must_equal <<~"END"
D
#{digest}
POLYGON
POLYGON AIRSPACE
C
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
H24
polygon airspace
false
D
#{digest}
CWA
47.85916667N
7.56000000E
WGE
47.90416667N
7.56333333E
FNT
47.94361111N
7.59583333E
WGE
FRANCE_GERMANY
GRC
47.85916667N
7.56000000E
WGE
END
end
end
context "with two class layers" do
subject do
AIXM::Factory.polygon_airspace.tap do |airspace|
airspace.class_layers << AIXM::Factory.class_layer
end
end
describe :complete? do
it "must pass validation" do
subject.must_be :complete?
end
end
describe :to_digest do
it "must return digest of payload" do
subject.to_digest.must_equal 481196243
end
end
describe :to_xml do
it "must build correct XML with OFM extensions" do
digest = subject.to_digest
subject.to_xml(:ofm).must_equal <<~"END"
D
#{digest}
POLYGON
POLYGON AIRSPACE
C
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
H24
polygon airspace
false
D
#{digest}
CWA
47.85916667N
7.56000000E
WGE
47.90416667N
7.56333333E
FNT
47.94361111N
7.59583333E
WGE
FRANCE_GERMANY
GRC
47.85916667N
7.56000000E
WGE
CLASS
CLASS
CLASS
POLYGON AIRSPACE
C
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
CLASS
POLYGON AIRSPACE
C
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
END
end
end
end
end
context "partially complete" do
it "must build correct XML without short name" do
subject = AIXM::Factory.polygon_airspace(short_name: nil)
subject.to_xml.wont_match(/txtLocalType/)
end
it "must build correct XML with identical name and short name" do
subject = AIXM::Factory.polygon_airspace(short_name: 'POLYGON AIRSPACE')
subject.to_xml.wont_match(/txtLocalType/)
end
it "must build correct XML without schedule" do
subject = AIXM::Factory.polygon_airspace(schedule: nil)
subject.to_xml.wont_match(/codeWorkHr/)
end
end
end
end