Sha256: e138ecb913d3139c38e2f783338005998eb1fc7ac00b717647f7c5f809e5f503

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

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

describe AIXM::Feature::Organisation do
  subject do
    AIXM::Factory.organisation
  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 = 'Nîmes-Alès' }.name.must_equal 'NIMES-ALES'
    end
  end

  describe :type= do
    it "fails on invalid values" do
      [nil, :foobar, 123].wont_be_written_to subject, :type
    end

    it "looks up valid values" do
      subject.tap { |s| s.type = :state }.type.must_equal :state
      subject.tap { |s| s.type = :IO }.type.must_equal :international_organisation
    end
  end

  describe :id= do
    it "fails on invalid values" do
      [:foobar, 123].wont_be_written_to subject, :id
    end

    it "accepts nil value" do
      [nil].must_be_written_to subject, :id
    end

    it "upcases valid values" do
      subject.tap { |s| s.id = 'lf' }.id.must_equal 'LF'
    end
  end

  describe :remarks= do
    macro :remarks
  end

  describe :to_xml do
    it "builds correct complete OFMX" do
      AIXM.ofmx!
      subject.to_xml.must_equal <<~END
        <!-- Organisation: FRANCE -->
        <Org source="LF|GEN|0.0 FACTORY|0|0">
          <OrgUid>
            <txtName>FRANCE</txtName>
          </OrgUid>
          <codeId>LF</codeId>
          <codeType>S</codeType>
          <txtRmk>Oversea departments not included</txtRmk>
        </Org>
      END
    end

    it "builds correct minimal OFMX" do
      AIXM.ofmx!
      subject.id = subject.remarks = nil
      subject.to_xml.must_equal <<~END
        <!-- Organisation: FRANCE -->
        <Org source="LF|GEN|0.0 FACTORY|0|0">
          <OrgUid>
            <txtName>FRANCE</txtName>
          </OrgUid>
          <codeType>S</codeType>
        </Org>
      END
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
aixm-0.3.7 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.6 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.5 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.4 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.3 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.2 spec/lib/aixm/feature/organisation_spec.rb
aixm-0.3.1 spec/lib/aixm/feature/organisation_spec.rb