require_relative '../../../spec_helper'
describe AIXM::Component::Layer do
context "only required attributes set" do
subject do
AIXM.layer(vertical_limits: AIXM::Factory.vertical_limits)
end
describe :initialize do
it "sets defaults" do
subject.wont_be :selective?
end
end
describe :class= do
it "fails on invalid values" do
[:X, 'X'].wont_be_written_to subject, :class
end
it "symbolizes and upcases valid values" do
subject.tap { |s| s.class = 'c' }.class.must_equal :C
end
end
describe :vertical_limits= do
it "fails on invalid values" do
[nil, :foobar, 123].wont_be_written_to subject, :vertical_limits
end
end
describe :timetable= do
macro :timetable
end
describe :selective= do
it "fails on invalid values" do
[nil, 'N', 0].wont_be_written_to subject, :selective
end
end
describe :remarks= do
macro :remarks
end
describe :to_xml do
it "builds correct OFMX" do
AIXM.ofmx!
subject.to_xml.must_equal <<~END
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
N
END
end
it "builds correct AIXM" do
AIXM.aixm!
subject.to_xml.wont_match(//)
subject.to_xml.wont_match(//)
subject.to_xml.wont_match(//)
end
end
end
context "required and optional attributes set" do
subject do
AIXM::Factory.layer
end
it "builds correct OFMX" do
AIXM.ofmx!
subject.to_xml.must_equal <<~END
C
STD
65
FL
STD
45
FL
ALT
6000
FT
HEI
3000
FT
H24
Y
airspace layer
END
end
it "builds correct AIXM" do
AIXM.aixm!
subject.to_xml.wont_match(//)
end
end
end