Sha256: 370d5a8d9dff1fc5983c378b2b29a69676f11a9e09fdd8011584df3fc98f4f05

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

require_relative '../../../spec_helper'

describe AIXM::Feature::Service do
  subject do
    AIXM::Factory.service
  end

  describe :initialize do
    it "sets defaults" do
      subject = AIXM::Feature::Service.new(
        type: :approach_control_service
      )
      subject.frequencies.must_equal []
    end
  end

  describe :type= do
    it "fails on invalid values" do
      -> { subject.type = :foobar }.must_raise ArgumentError
      -> { subject.type = nil }.must_raise ArgumentError
    end

    it "looks up valid values" do
      subject.tap { |s| s.type = :area_control_service }.type.must_equal :area_control_service
      subject.tap { |s| s.type = :ATIS }.type.must_equal :automated_terminal_information_service
    end
  end

  describe :timetable= do
    macro :timetable
  end

  describe :remarks= do
    macro :remarks
  end

  describe :add_frequency do
    it "fails on invalid arguments" do
      -> { subject.add_frequency nil }.must_raise ArgumentError
    end

    it "adds frequency to the array" do
      count = subject.frequencies.count
      subject.add_frequency(AIXM::Factory.frequency)
      subject.frequencies.count.must_equal count + 1
    end
  end

  describe :guess_unit_type do
    it "finds the probably unit type for a matchable service" do
      subject.tap { |s| s.type = :flight_information_service }.guessed_unit_type.must_equal :flight_information_centre
    end

    it "returns nil for an unmatchable service" do
      subject.tap { |s| s.type = :aeronautical_mobile_satellite_service }.guessed_unit_type.must_be_nil
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aixm-0.3.7 spec/lib/aixm/feature/service_spec.rb
aixm-0.3.6 spec/lib/aixm/feature/service_spec.rb
aixm-0.3.5 spec/lib/aixm/feature/service_spec.rb
aixm-0.3.4 spec/lib/aixm/feature/service_spec.rb