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_aixm do
it "must build correct XML with OFM extensions" do
digest = subject.to_digest
subject.to_aixm(: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_aixm do
it "must build correct XML with OFM extensions" do
digest = subject.to_digest
subject.to_aixm(: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
subject do
AIXM::Factory.polygon_airspace
end
it "must build correct XML without short name" do
subject.short_name = nil
subject.to_aixm.wont_match(/txtLocalType/)
end
it "must build correct XML with identical name and short name" do
subject.short_name = 'POLYGON AIRSPACE'
subject.to_aixm.wont_match(/txtLocalType/)
end
it "must build correct XML without schedule" do
subject.schedule = nil
subject.to_aixm.wont_match(/codeWorkHr/)
end
end
end
end