rcap 2.4.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/.ruby-version +1 -0
 - data/CHANGELOG.md +18 -0
 - data/README.md +1 -0
 - data/lib/rcap.rb +3 -1
 - data/lib/rcap/alert.rb +30 -29
 - data/lib/rcap/base/alert.rb +208 -205
 - data/lib/rcap/base/area.rb +95 -91
 - data/lib/rcap/base/circle.rb +45 -34
 - data/lib/rcap/base/event_code.rb +2 -0
 - data/lib/rcap/base/geocode.rb +2 -0
 - data/lib/rcap/base/info.rb +273 -272
 - data/lib/rcap/base/parameter.rb +29 -28
 - data/lib/rcap/base/point.rb +26 -24
 - data/lib/rcap/base/polygon.rb +43 -35
 - data/lib/rcap/base/resource.rb +65 -65
 - data/lib/rcap/cap_1_0/alert.rb +85 -86
 - data/lib/rcap/cap_1_0/area.rb +2 -2
 - data/lib/rcap/cap_1_0/circle.rb +2 -1
 - data/lib/rcap/cap_1_0/event_code.rb +3 -1
 - data/lib/rcap/cap_1_0/geocode.rb +3 -1
 - data/lib/rcap/cap_1_0/info.rb +3 -3
 - data/lib/rcap/cap_1_0/parameter.rb +13 -13
 - data/lib/rcap/cap_1_0/point.rb +2 -1
 - data/lib/rcap/cap_1_0/polygon.rb +3 -3
 - data/lib/rcap/cap_1_0/resource.rb +2 -3
 - data/lib/rcap/cap_1_1/alert.rb +6 -6
 - data/lib/rcap/cap_1_1/area.rb +2 -2
 - data/lib/rcap/cap_1_1/circle.rb +2 -1
 - data/lib/rcap/cap_1_1/event_code.rb +3 -1
 - data/lib/rcap/cap_1_1/geocode.rb +3 -1
 - data/lib/rcap/cap_1_1/info.rb +125 -132
 - data/lib/rcap/cap_1_1/parameter.rb +2 -3
 - data/lib/rcap/cap_1_1/point.rb +2 -1
 - data/lib/rcap/cap_1_1/polygon.rb +3 -3
 - data/lib/rcap/cap_1_1/resource.rb +37 -38
 - data/lib/rcap/cap_1_2/alert.rb +6 -6
 - data/lib/rcap/cap_1_2/area.rb +2 -2
 - data/lib/rcap/cap_1_2/circle.rb +2 -1
 - data/lib/rcap/cap_1_2/event_code.rb +3 -1
 - data/lib/rcap/cap_1_2/geocode.rb +3 -1
 - data/lib/rcap/cap_1_2/info.rb +120 -123
 - data/lib/rcap/cap_1_2/parameter.rb +2 -3
 - data/lib/rcap/cap_1_2/point.rb +2 -1
 - data/lib/rcap/cap_1_2/polygon.rb +4 -4
 - data/lib/rcap/cap_1_2/resource.rb +38 -38
 - data/lib/rcap/config.rb +5 -3
 - data/lib/rcap/custom_validators.rb +75 -78
 - data/lib/rcap/extensions/array.rb +3 -1
 - data/lib/rcap/extensions/date.rb +3 -1
 - data/lib/rcap/extensions/date_time.rb +5 -2
 - data/lib/rcap/extensions/float.rb +2 -0
 - data/lib/rcap/extensions/integer.rb +7 -0
 - data/lib/rcap/extensions/nil_class.rb +2 -0
 - data/lib/rcap/extensions/string.rb +6 -4
 - data/lib/rcap/extensions/time.rb +5 -3
 - data/lib/rcap/formatters/yaml.rb +5 -0
 - data/lib/rcap/info.rb +6 -5
 - data/lib/rcap/utilities.rb +27 -30
 - data/lib/rcap/validation.rb +22 -21
 - data/lib/rcap/version.rb +3 -1
 - data/rcap.gemspec +5 -5
 - data/spec/alert_spec.rb +141 -141
 - data/spec/cap_1_0/alert_spec.rb +92 -94
 - data/spec/cap_1_0/area_spec.rb +86 -86
 - data/spec/cap_1_0/circle_spec.rb +48 -39
 - data/spec/cap_1_0/event_code_spec.rb +15 -15
 - data/spec/cap_1_0/geocode_spec.rb +16 -16
 - data/spec/cap_1_0/info_spec.rb +175 -177
 - data/spec/cap_1_0/parameter_spec.rb +27 -27
 - data/spec/cap_1_0/point_spec.rb +18 -18
 - data/spec/cap_1_0/polygon_spec.rb +43 -41
 - data/spec/cap_1_0/resource_spec.rb +63 -64
 - data/spec/cap_1_1/alert_spec.rb +107 -109
 - data/spec/cap_1_1/area_spec.rb +90 -90
 - data/spec/cap_1_1/circle_spec.rb +43 -34
 - data/spec/cap_1_1/event_code_spec.rb +15 -16
 - data/spec/cap_1_1/geocode_spec.rb +16 -16
 - data/spec/cap_1_1/info_spec.rb +194 -196
 - data/spec/cap_1_1/parameter_spec.rb +17 -17
 - data/spec/cap_1_1/point_spec.rb +18 -18
 - data/spec/cap_1_1/polygon_spec.rb +43 -41
 - data/spec/cap_1_1/resource_spec.rb +106 -107
 - data/spec/cap_1_2/alert_spec.rb +98 -99
 - data/spec/cap_1_2/area_spec.rb +90 -90
 - data/spec/cap_1_2/circle_spec.rb +52 -43
 - data/spec/cap_1_2/event_code_spec.rb +19 -20
 - data/spec/cap_1_2/geocode_spec.rb +20 -20
 - data/spec/cap_1_2/info_spec.rb +196 -198
 - data/spec/cap_1_2/parameter_spec.rb +19 -19
 - data/spec/cap_1_2/point_spec.rb +21 -21
 - data/spec/cap_1_2/polygon_spec.rb +55 -47
 - data/spec/cap_1_2/resource_spec.rb +96 -97
 - data/spec/extensions_spec.rb +29 -29
 - data/spec/info_spec.rb +15 -15
 - data/spec/spec_helper.rb +3 -3
 - data/spec/validations_spec.rb +73 -73
 - metadata +12 -11
 - data/lib/rcap/extensions/fixnum.rb +0 -5
 
    
        data/spec/cap_1_2/alert_spec.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe( 
     | 
| 
       4 
     | 
    
         
            -
              before( 
     | 
| 
      
 3 
     | 
    
         
            +
            describe(RCAP::CAP_1_2::Alert) do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
       5 
5 
     | 
    
         
             
                @alert_builder = lambda do |alert|
         
     | 
| 
       6 
6 
     | 
    
         
             
                  alert.sender      = 'Sender'
         
     | 
| 
       7 
7 
     | 
    
         
             
                  alert.sent        = DateTime.now
         
     | 
| 
         @@ -9,17 +9,17 @@ describe( RCAP::CAP_1_2::Alert ) do 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  alert.scope       = RCAP::CAP_1_2::Alert::SCOPE_PUBLIC
         
     | 
| 
       10 
10 
     | 
    
         
             
                  alert.source      = 'Source'
         
     | 
| 
       11 
11 
     | 
    
         
             
                  alert.restriction = 'No Restriction'
         
     | 
| 
       12 
     | 
    
         
            -
                  [ 
     | 
| 
      
 12 
     | 
    
         
            +
                  ['Address 1', 'Address 2'].each do |address|
         
     | 
| 
       13 
13 
     | 
    
         
             
                    alert.addresses << address
         
     | 
| 
       14 
14 
     | 
    
         
             
                  end
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
      
 15 
     | 
    
         
            +
                  %w(Code1 Code2).each do |code|
         
     | 
| 
       16 
16 
     | 
    
         
             
                    alert.codes << code
         
     | 
| 
       17 
17 
     | 
    
         
             
                  end
         
     | 
| 
       18 
18 
     | 
    
         
             
                  alert.note        = 'Note'
         
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
      
 19 
     | 
    
         
            +
                  %w(Reference1 Reference2).each do |reference|
         
     | 
| 
       20 
20 
     | 
    
         
             
                    alert.references << reference
         
     | 
| 
       21 
21 
     | 
    
         
             
                  end
         
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
      
 22 
     | 
    
         
            +
                  %w(Incident1 Incident2).each do |incident|
         
     | 
| 
       23 
23 
     | 
    
         
             
                    alert.incidents << incident
         
     | 
| 
       24 
24 
     | 
    
         
             
                  end
         
     | 
| 
       25 
25 
     | 
    
         
             
                  2.times do
         
     | 
| 
         @@ -28,158 +28,157 @@ describe( RCAP::CAP_1_2::Alert ) do 
     | 
|
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              context( 
     | 
| 
       32 
     | 
    
         
            -
                before( 
     | 
| 
      
 31 
     | 
    
         
            +
              context('on initialisation') do
         
     | 
| 
      
 32 
     | 
    
         
            +
                before(:each)  do
         
     | 
| 
       33 
33 
     | 
    
         
             
                  @alert = RCAP::CAP_1_2::Alert.new
         
     | 
| 
       34 
34 
     | 
    
         
             
                end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                it( 
     | 
| 
       37 
     | 
    
         
            -
                it( 
     | 
| 
       38 
     | 
    
         
            -
                it( 
     | 
| 
       39 
     | 
    
         
            -
                it( 
     | 
| 
       40 
     | 
    
         
            -
                it( 
     | 
| 
       41 
     | 
    
         
            -
                it( 
     | 
| 
       42 
     | 
    
         
            -
                it( 
     | 
| 
       43 
     | 
    
         
            -
                it( 
     | 
| 
       44 
     | 
    
         
            -
                it( 
     | 
| 
       45 
     | 
    
         
            -
                it( 
     | 
| 
       46 
     | 
    
         
            -
                it( 
     | 
| 
       47 
     | 
    
         
            -
                it( 
     | 
| 
       48 
     | 
    
         
            -
                it( 
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                shared_examples_for( 
     | 
| 
       51 
     | 
    
         
            -
                  it( 
     | 
| 
       52 
     | 
    
         
            -
                  it( 
     | 
| 
       53 
     | 
    
         
            -
                  it( 
     | 
| 
       54 
     | 
    
         
            -
                  it( 
     | 
| 
       55 
     | 
    
         
            -
                  it( 
     | 
| 
       56 
     | 
    
         
            -
                  it( 
     | 
| 
       57 
     | 
    
         
            -
                  it( 
     | 
| 
       58 
     | 
    
         
            -
                  it( 
     | 
| 
       59 
     | 
    
         
            -
                  it( 
     | 
| 
       60 
     | 
    
         
            -
                  it( 
     | 
| 
       61 
     | 
    
         
            -
                  it( 
     | 
| 
       62 
     | 
    
         
            -
                  it( 
     | 
| 
       63 
     | 
    
         
            -
                  it( 
     | 
| 
       64 
     | 
    
         
            -
                  it( 
     | 
| 
      
 36 
     | 
    
         
            +
                it('should have a identifier') { @alert.identifier.should_not(be_nil) }
         
     | 
| 
      
 37 
     | 
    
         
            +
                it('should not have a sender') { @alert.sender.should(be_nil) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                it('should not have a sent time') { @alert.sent.should(be_nil) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                it('should not have a status') { @alert.status.should(be_nil) }
         
     | 
| 
      
 40 
     | 
    
         
            +
                it('should not have a scope') { @alert.scope.should(be_nil) }
         
     | 
| 
      
 41 
     | 
    
         
            +
                it('should not have a source') { @alert.source.should(be_nil) }
         
     | 
| 
      
 42 
     | 
    
         
            +
                it('should not have a restriction') { @alert.restriction.should(be_nil) }
         
     | 
| 
      
 43 
     | 
    
         
            +
                it('should not have any addresses') { @alert.addresses.should(be_empty) }
         
     | 
| 
      
 44 
     | 
    
         
            +
                it('should not have any codes') { @alert.codes.should(be_empty) }
         
     | 
| 
      
 45 
     | 
    
         
            +
                it('should not have a note') { @alert.note.should(be_nil) }
         
     | 
| 
      
 46 
     | 
    
         
            +
                it('should not have any references') { @alert.references.should(be_empty) }
         
     | 
| 
      
 47 
     | 
    
         
            +
                it('should not have any incidents') { @alert.incidents.should(be_empty) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                it('should not have any infos') { @alert.infos.should(be_empty) }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                shared_examples_for('a successfully parsed CAP 1.2 alert') do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  it('should parse identifier correctly') { @alert.identifier.should  == @original_alert.identifier }
         
     | 
| 
      
 52 
     | 
    
         
            +
                  it('should parse sender correctly')     { @alert.sender.should      == @original_alert.sender }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  it('should parse sent correctly')       { @alert.sent.should(be_within(1).of(@original_alert.sent)) }
         
     | 
| 
      
 54 
     | 
    
         
            +
                  it('should parse status correctly')     { @alert.status.should      == @original_alert.status }
         
     | 
| 
      
 55 
     | 
    
         
            +
                  it('should parse msg_type correctly')   { @alert.msg_type.should    == @original_alert.msg_type }
         
     | 
| 
      
 56 
     | 
    
         
            +
                  it('should parse source correctly')     { @alert.source.should      == @original_alert.source }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  it('should parse scope correctly')      { @alert.scope.should       == @original_alert.scope }
         
     | 
| 
      
 58 
     | 
    
         
            +
                  it('should parse restriction correctly') { @alert.restriction.should == @original_alert.restriction }
         
     | 
| 
      
 59 
     | 
    
         
            +
                  it('should parse addresses correctly')  { @alert.addresses.should   == @original_alert.addresses }
         
     | 
| 
      
 60 
     | 
    
         
            +
                  it('should parse codes correctly')      { @alert.codes              == @original_alert.codes }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  it('should parse note correctly')       { @alert.note.should        == @original_alert.note }
         
     | 
| 
      
 62 
     | 
    
         
            +
                  it('should parse references correctly') { @alert.references.should  == @original_alert.references }
         
     | 
| 
      
 63 
     | 
    
         
            +
                  it('should parse incidents correctly')  { @alert.incidents.should   == @original_alert.incidents }
         
     | 
| 
      
 64 
     | 
    
         
            +
                  it('should parse infos correctly') do
         
     | 
| 
       65 
65 
     | 
    
         
             
                    @alert.infos.size.should == @original_alert.infos.size
         
     | 
| 
       66 
     | 
    
         
            -
                    @alert.infos.each{ |info| info.class.should == RCAP::CAP_1_2::Info }
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @alert.infos.each { |info| info.class.should == RCAP::CAP_1_2::Info }
         
     | 
| 
       67 
67 
     | 
    
         
             
                  end
         
     | 
| 
       68 
68 
     | 
    
         
             
                end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
                context( 
     | 
| 
       71 
     | 
    
         
            -
                  before( 
     | 
| 
       72 
     | 
    
         
            -
                    @original_alert = RCAP::CAP_1_2::Alert.new( 
     | 
| 
      
 70 
     | 
    
         
            +
                context('from XML') do
         
     | 
| 
      
 71 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @original_alert = RCAP::CAP_1_2::Alert.new(&@alert_builder)
         
     | 
| 
       73 
73 
     | 
    
         
             
                    @xml_string = @original_alert.to_xml
         
     | 
| 
       74 
     | 
    
         
            -
                    @xml_document = REXML::Document.new( 
     | 
| 
      
 74 
     | 
    
         
            +
                    @xml_document = REXML::Document.new(@xml_string)
         
     | 
| 
       75 
75 
     | 
    
         
             
                    @alert_element = @xml_document.root
         
     | 
| 
       76 
     | 
    
         
            -
                    @alert = RCAP::CAP_1_2::Alert.from_xml_element( 
     | 
| 
      
 76 
     | 
    
         
            +
                    @alert = RCAP::CAP_1_2::Alert.from_xml_element(@alert_element)
         
     | 
| 
       77 
77 
     | 
    
         
             
                  end
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 79 
     | 
    
         
            +
                  it_should_behave_like('a successfully parsed CAP 1.2 alert')
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                context( 
     | 
| 
       84 
     | 
    
         
            -
                  before( 
     | 
| 
       85 
     | 
    
         
            -
                    @original_alert = RCAP::CAP_1_2::Alert.new( 
     | 
| 
      
 83 
     | 
    
         
            +
                context('from YAML') do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 85 
     | 
    
         
            +
                    @original_alert = RCAP::CAP_1_2::Alert.new(&@alert_builder)
         
     | 
| 
       86 
86 
     | 
    
         
             
                    @yaml_string = @original_alert.to_yaml
         
     | 
| 
       87 
     | 
    
         
            -
                    @alert = RCAP::CAP_1_2::Alert.from_yaml( 
     | 
| 
      
 87 
     | 
    
         
            +
                    @alert = RCAP::CAP_1_2::Alert.from_yaml(@yaml_string)
         
     | 
| 
       88 
88 
     | 
    
         
             
                  end
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 90 
     | 
    
         
            +
                  it_should_behave_like('a successfully parsed CAP 1.2 alert')
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                context( 
     | 
| 
       94 
     | 
    
         
            -
                  before( 
     | 
| 
       95 
     | 
    
         
            -
                    @original_alert = RCAP::CAP_1_2::Alert.new( 
     | 
| 
       96 
     | 
    
         
            -
                    @alert = RCAP::CAP_1_2::Alert.from_h( 
     | 
| 
      
 93 
     | 
    
         
            +
                context('from a hash') do
         
     | 
| 
      
 94 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 95 
     | 
    
         
            +
                    @original_alert = RCAP::CAP_1_2::Alert.new(&@alert_builder)
         
     | 
| 
      
 96 
     | 
    
         
            +
                    @alert = RCAP::CAP_1_2::Alert.from_h(@original_alert.to_h)
         
     | 
| 
       97 
97 
     | 
    
         
             
                  end
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 99 
     | 
    
         
            +
                  it_should_behave_like('a successfully parsed CAP 1.2 alert')
         
     | 
| 
       100 
100 
     | 
    
         
             
                end
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
                context( 
     | 
| 
       103 
     | 
    
         
            -
                  before( 
     | 
| 
       104 
     | 
    
         
            -
                    @original_alert = RCAP::CAP_1_2::Alert.new( 
     | 
| 
       105 
     | 
    
         
            -
                    @alert = RCAP::CAP_1_2::Alert.from_json( 
     | 
| 
      
 102 
     | 
    
         
            +
                context('from JSON') do
         
     | 
| 
      
 103 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 104 
     | 
    
         
            +
                    @original_alert = RCAP::CAP_1_2::Alert.new(&@alert_builder)
         
     | 
| 
      
 105 
     | 
    
         
            +
                    @alert = RCAP::CAP_1_2::Alert.from_json(@original_alert.to_json)
         
     | 
| 
       106 
106 
     | 
    
         
             
                  end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 108 
     | 
    
         
            +
                  it_should_behave_like('a successfully parsed CAP 1.2 alert')
         
     | 
| 
       109 
109 
     | 
    
         
             
                end
         
     | 
| 
       110 
110 
     | 
    
         
             
              end
         
     | 
| 
       111 
111 
     | 
    
         | 
| 
       112 
     | 
    
         
            -
              describe( 
     | 
| 
       113 
     | 
    
         
            -
                before( 
     | 
| 
      
 112 
     | 
    
         
            +
              describe('is not valid if it') do
         
     | 
| 
      
 113 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
       114 
114 
     | 
    
         
             
                  @alert = RCAP::CAP_1_2::Alert.new do |alert|
         
     | 
| 
       115 
115 
     | 
    
         
             
                    alert.identifier = 'Identifier'
         
     | 
| 
       116 
     | 
    
         
            -
                    alert.sender     =  
     | 
| 
      
 116 
     | 
    
         
            +
                    alert.sender     = 'cap@tempuri.org'
         
     | 
| 
       117 
117 
     | 
    
         
             
                    alert.sent       = DateTime.now
         
     | 
| 
       118 
118 
     | 
    
         
             
                    alert.status     = RCAP::CAP_1_2::Alert::STATUS_TEST
         
     | 
| 
       119 
119 
     | 
    
         
             
                    alert.msg_type   = RCAP::CAP_1_2::Alert::MSG_TYPE_ALERT
         
     | 
| 
       120 
120 
     | 
    
         
             
                    alert.scope      = RCAP::CAP_1_2::Alert::SCOPE_PUBLIC
         
     | 
| 
       121 
     | 
    
         
            -
                    @alert.should( 
     | 
| 
      
 121 
     | 
    
         
            +
                    @alert.should(be_valid)
         
     | 
| 
       122 
122 
     | 
    
         
             
                  end
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
                  it( 
     | 
| 
      
 124 
     | 
    
         
            +
                  it('does not have a identifier') do
         
     | 
| 
       125 
125 
     | 
    
         
             
                    @alert.identifier = nil
         
     | 
| 
       126 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 126 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       127 
127 
     | 
    
         
             
                  end
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                  it( 
     | 
| 
      
 129 
     | 
    
         
            +
                  it('does not have a sender') do
         
     | 
| 
       130 
130 
     | 
    
         
             
                    @alert.sender = nil
         
     | 
| 
       131 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 131 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       132 
132 
     | 
    
         
             
                  end
         
     | 
| 
       133 
133 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
                  it( 
     | 
| 
      
 134 
     | 
    
         
            +
                  it('does not have a sent time (sent)') do
         
     | 
| 
       135 
135 
     | 
    
         
             
                    @alert.sent = nil
         
     | 
| 
       136 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 136 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       137 
137 
     | 
    
         
             
                  end
         
     | 
| 
       138 
138 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
                  it( 
     | 
| 
      
 139 
     | 
    
         
            +
                  it('does not have a status') do
         
     | 
| 
       140 
140 
     | 
    
         
             
                    @alert.status = nil
         
     | 
| 
       141 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 141 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       142 
142 
     | 
    
         
             
                  end
         
     | 
| 
       143 
143 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
                  it( 
     | 
| 
      
 144 
     | 
    
         
            +
                  it('does not have a message type (msg_type)') do
         
     | 
| 
       145 
145 
     | 
    
         
             
                    @alert.msg_type = nil
         
     | 
| 
       146 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 146 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       147 
147 
     | 
    
         
             
                  end
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
     | 
    
         
            -
                  it( 
     | 
| 
      
 149 
     | 
    
         
            +
                  it('does not have a scope') do
         
     | 
| 
       150 
150 
     | 
    
         
             
                    @alert.scope = nil
         
     | 
| 
       151 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 151 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       152 
152 
     | 
    
         
             
                  end
         
     | 
| 
       153 
153 
     | 
    
         | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
                  it( 'does not have a valid status' ) do
         
     | 
| 
      
 154 
     | 
    
         
            +
                  it('does not have a valid status') do
         
     | 
| 
       156 
155 
     | 
    
         
             
                    @alert.status = 'incorrect value'
         
     | 
| 
       157 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 156 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       158 
157 
     | 
    
         
             
                  end
         
     | 
| 
       159 
158 
     | 
    
         | 
| 
       160 
     | 
    
         
            -
                  it( 
     | 
| 
      
 159 
     | 
    
         
            +
                  it('does not have a valid message type msg_type') do
         
     | 
| 
       161 
160 
     | 
    
         
             
                    @alert.msg_type = 'incorrect value'
         
     | 
| 
       162 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 161 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       163 
162 
     | 
    
         
             
                  end
         
     | 
| 
       164 
163 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                  it( 
     | 
| 
      
 164 
     | 
    
         
            +
                  it('does not have a valid scope') do
         
     | 
| 
       166 
165 
     | 
    
         
             
                    @alert.scope = 'incorrect value'
         
     | 
| 
       167 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 166 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       168 
167 
     | 
    
         
             
                  end
         
     | 
| 
       169 
168 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
                  it( 
     | 
| 
      
 169 
     | 
    
         
            +
                  it('does not have a restriction with a Restricted scope') do
         
     | 
| 
       171 
170 
     | 
    
         
             
                    @alert.scope = RCAP::CAP_1_2::Alert::SCOPE_RESTRICTED
         
     | 
| 
       172 
171 
     | 
    
         
             
                    @alert.restriction = nil
         
     | 
| 
       173 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 172 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       174 
173 
     | 
    
         
             
                  end
         
     | 
| 
       175 
174 
     | 
    
         | 
| 
       176 
     | 
    
         
            -
                  it( 
     | 
| 
      
 175 
     | 
    
         
            +
                  it('does not have any addresses with a Private scope') do
         
     | 
| 
       177 
176 
     | 
    
         
             
                    @alert.scope = RCAP::CAP_1_2::Alert::SCOPE_PRIVATE
         
     | 
| 
       178 
177 
     | 
    
         
             
                    @alert.addresses.clear
         
     | 
| 
       179 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 178 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       180 
179 
     | 
    
         
             
                  end
         
     | 
| 
       181 
180 
     | 
    
         | 
| 
       182 
     | 
    
         
            -
                  it( 
     | 
| 
      
 181 
     | 
    
         
            +
                  it('has in invalid info attribute') do
         
     | 
| 
       183 
182 
     | 
    
         
             
                    @info = RCAP::CAP_1_2::Info.new do |info|
         
     | 
| 
       184 
183 
     | 
    
         
             
                      info.event      = 'Info Event'
         
     | 
| 
       185 
184 
     | 
    
         
             
                      info.categories << RCAP::CAP_1_2::Info::CATEGORY_GEO
         
     | 
| 
         @@ -189,38 +188,38 @@ describe( RCAP::CAP_1_2::Alert ) do 
     | 
|
| 
       189 
188 
     | 
    
         
             
                    end
         
     | 
| 
       190 
189 
     | 
    
         
             
                    @info.event = nil
         
     | 
| 
       191 
190 
     | 
    
         
             
                    @alert.infos << @info
         
     | 
| 
       192 
     | 
    
         
            -
                    @info.should_not( 
     | 
| 
       193 
     | 
    
         
            -
                    @alert.should_not( 
     | 
| 
      
 191 
     | 
    
         
            +
                    @info.should_not(be_valid)
         
     | 
| 
      
 192 
     | 
    
         
            +
                    @alert.should_not(be_valid)
         
     | 
| 
       194 
193 
     | 
    
         
             
                  end
         
     | 
| 
       195 
194 
     | 
    
         
             
                end
         
     | 
| 
       196 
195 
     | 
    
         
             
              end
         
     | 
| 
       197 
196 
     | 
    
         | 
| 
       198 
     | 
    
         
            -
              describe( 
     | 
| 
       199 
     | 
    
         
            -
                before( 
     | 
| 
      
 197 
     | 
    
         
            +
              describe('instance methods') do
         
     | 
| 
      
 198 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
       200 
199 
     | 
    
         
             
                  @alert = RCAP::CAP_1_2::Alert.new
         
     | 
| 
       201 
200 
     | 
    
         
             
                end
         
     | 
| 
       202 
201 
     | 
    
         | 
| 
       203 
     | 
    
         
            -
                describe( 
     | 
| 
       204 
     | 
    
         
            -
                  before( 
     | 
| 
      
 202 
     | 
    
         
            +
                describe('#add_info') do
         
     | 
| 
      
 203 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       205 
204 
     | 
    
         
             
                    @info = @alert.add_info do |info|
         
     | 
| 
       206 
205 
     | 
    
         
             
                      info.urgency = 'urgent'
         
     | 
| 
       207 
206 
     | 
    
         
             
                    end
         
     | 
| 
       208 
207 
     | 
    
         
             
                    @info.urgency.should == 'urgent'
         
     | 
| 
       209 
208 
     | 
    
         
             
                  end
         
     | 
| 
       210 
209 
     | 
    
         | 
| 
       211 
     | 
    
         
            -
                  it( 
     | 
| 
      
 210 
     | 
    
         
            +
                  it('should return a CAP 1.2 Info object') do
         
     | 
| 
       212 
211 
     | 
    
         
             
                    @info.class.should == RCAP::CAP_1_2::Info
         
     | 
| 
       213 
212 
     | 
    
         
             
                  end
         
     | 
| 
       214 
213 
     | 
    
         | 
| 
       215 
     | 
    
         
            -
                  it( 
     | 
| 
      
 214 
     | 
    
         
            +
                  it('should add an Info object to the infos array') do
         
     | 
| 
       216 
215 
     | 
    
         
             
                    @alert.infos.size.should == 1
         
     | 
| 
       217 
216 
     | 
    
         
             
                  end
         
     | 
| 
       218 
217 
     | 
    
         
             
                end
         
     | 
| 
       219 
218 
     | 
    
         | 
| 
       220 
     | 
    
         
            -
                describe( 
     | 
| 
       221 
     | 
    
         
            -
                  context( 
     | 
| 
       222 
     | 
    
         
            -
                    it( 
     | 
| 
       223 
     | 
    
         
            -
                      lambda{ @alert.to_xml( 
     | 
| 
      
 219 
     | 
    
         
            +
                describe('#to_xml') do
         
     | 
| 
      
 220 
     | 
    
         
            +
                  context('with pretty_print = true') do
         
     | 
| 
      
 221 
     | 
    
         
            +
                    it('should not raise an exception') do
         
     | 
| 
      
 222 
     | 
    
         
            +
                      lambda { @alert.to_xml(true) }.should_not(raise_exception)
         
     | 
| 
       224 
223 
     | 
    
         
             
                    end
         
     | 
| 
       225 
224 
     | 
    
         
             
                  end
         
     | 
| 
       226 
225 
     | 
    
         
             
                end
         
     | 
    
        data/spec/cap_1_2/area_spec.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe( 
     | 
| 
       4 
     | 
    
         
            -
              before( 
     | 
| 
      
 3 
     | 
    
         
            +
            describe(RCAP::CAP_1_2::Area) do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
       5 
5 
     | 
    
         
             
                @area_builder = lambda do |area|
         
     | 
| 
       6 
6 
     | 
    
         
             
                  area.area_desc = 'Area Description'
         
     | 
| 
       7 
7 
     | 
    
         
             
                  area.altitude  = 100
         
     | 
| 
         @@ -24,207 +24,207 @@ describe( RCAP::CAP_1_2::Area ) do 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  end
         
     | 
| 
       25 
25 
     | 
    
         
             
                end
         
     | 
| 
       26 
26 
     | 
    
         
             
              end
         
     | 
| 
       27 
     | 
    
         
            -
              context( 
     | 
| 
       28 
     | 
    
         
            -
                before( 
     | 
| 
      
 27 
     | 
    
         
            +
              context('on initialisation') do
         
     | 
| 
      
 28 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
       29 
29 
     | 
    
         
             
                  @area = RCAP::CAP_1_2::Area.new
         
     | 
| 
       30 
     | 
    
         
            -
                  @original_area = RCAP::CAP_1_2::Area.new( 
     | 
| 
      
 30 
     | 
    
         
            +
                  @original_area = RCAP::CAP_1_2::Area.new(&@area_builder)
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                # Atomic
         
     | 
| 
       34 
     | 
    
         
            -
                it( 
     | 
| 
       35 
     | 
    
         
            -
                it( 
     | 
| 
       36 
     | 
    
         
            -
                it( 
     | 
| 
      
 34 
     | 
    
         
            +
                it('should not have a area_desc') { @area.area_desc.should(be_nil) }
         
     | 
| 
      
 35 
     | 
    
         
            +
                it('should not have a altitude') { @area.altitude.should(be_nil) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                it('should not have a ceiling') { @area.ceiling.should(be_nil) }
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                # Group
         
     | 
| 
       39 
     | 
    
         
            -
                it( 
     | 
| 
       40 
     | 
    
         
            -
                it( 
     | 
| 
       41 
     | 
    
         
            -
                it( 
     | 
| 
      
 39 
     | 
    
         
            +
                it('should have an empty polygons') { @area.polygons.should(be_empty) }
         
     | 
| 
      
 40 
     | 
    
         
            +
                it('should have an empty circles') { @area.circles.should(be_empty) }
         
     | 
| 
      
 41 
     | 
    
         
            +
                it('should have an empty geocodes') { @area.geocodes.should(be_empty) }
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                shared_examples_for( 
     | 
| 
       44 
     | 
    
         
            -
                  it( 
     | 
| 
      
 43 
     | 
    
         
            +
                shared_examples_for('it can parse into a CAP 1.2 Area object') do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  it('should parse the area_desc correctly') do
         
     | 
| 
       45 
45 
     | 
    
         
             
                    @area.area_desc.should == @original_area.area_desc
         
     | 
| 
       46 
46 
     | 
    
         
             
                  end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                  it( 
     | 
| 
      
 48 
     | 
    
         
            +
                  it('should parse the altitude correctly') do
         
     | 
| 
       49 
49 
     | 
    
         
             
                    @area.altitude.should == @original_area.altitude
         
     | 
| 
       50 
50 
     | 
    
         
             
                  end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                  it( 
     | 
| 
      
 52 
     | 
    
         
            +
                  it('should parse the ceiling correctly') do
         
     | 
| 
       53 
53 
     | 
    
         
             
                    @area.ceiling.should == @original_area.ceiling
         
     | 
| 
       54 
54 
     | 
    
         
             
                  end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
                  it( 
     | 
| 
      
 56 
     | 
    
         
            +
                  it('should parse the circles correctly') do
         
     | 
| 
       57 
57 
     | 
    
         
             
                    @area.circles.should == @original_area.circles
         
     | 
| 
       58 
58 
     | 
    
         
             
                  end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                  it( 
     | 
| 
      
 60 
     | 
    
         
            +
                  it('should parse the geocodes correctly') do
         
     | 
| 
       61 
61 
     | 
    
         
             
                    @area.geocodes.should == @original_area.geocodes
         
     | 
| 
       62 
62 
     | 
    
         
             
                  end
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
                  it( 
     | 
| 
      
 64 
     | 
    
         
            +
                  it('should parse the polygons correctly') do
         
     | 
| 
       65 
65 
     | 
    
         
             
                    @area.polygons.should == @original_area.polygons
         
     | 
| 
       66 
66 
     | 
    
         
             
                  end
         
     | 
| 
       67 
67 
     | 
    
         
             
                end
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                context( 
     | 
| 
       70 
     | 
    
         
            -
                  before( 
     | 
| 
      
 69 
     | 
    
         
            +
                context('from XML') do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       71 
71 
     | 
    
         
             
                    @alert = RCAP::CAP_1_2::Alert.new
         
     | 
| 
       72 
     | 
    
         
            -
                    @alert.add_info.add_area( 
     | 
| 
      
 72 
     | 
    
         
            +
                    @alert.add_info.add_area(&@area_builder)
         
     | 
| 
       73 
73 
     | 
    
         
             
                    @xml_string = @alert.to_xml
         
     | 
| 
       74 
     | 
    
         
            -
                    @xml_document = REXML::Document.new( 
     | 
| 
       75 
     | 
    
         
            -
                    @info_xml_element = RCAP.xpath_first( 
     | 
| 
       76 
     | 
    
         
            -
                    @area_xml_element = RCAP.xpath_first( 
     | 
| 
       77 
     | 
    
         
            -
                    @area = RCAP::CAP_1_2::Area.from_xml_element( 
     | 
| 
      
 74 
     | 
    
         
            +
                    @xml_document = REXML::Document.new(@xml_string)
         
     | 
| 
      
 75 
     | 
    
         
            +
                    @info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    @area_xml_element = RCAP.xpath_first(@info_xml_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @area = RCAP::CAP_1_2::Area.from_xml_element(@area_xml_element)
         
     | 
| 
       78 
78 
     | 
    
         
             
                  end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 80 
     | 
    
         
            +
                  it_should_behave_like('it can parse into a CAP 1.2 Area object')
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                context( 
     | 
| 
       84 
     | 
    
         
            -
                  before( 
     | 
| 
       85 
     | 
    
         
            -
                    @area = RCAP::CAP_1_2::Area.from_yaml_data( 
     | 
| 
      
 83 
     | 
    
         
            +
                context('from YAML Data') do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 85 
     | 
    
         
            +
                    @area = RCAP::CAP_1_2::Area.from_yaml_data(YAML.load(@original_area.to_yaml))
         
     | 
| 
       86 
86 
     | 
    
         
             
                  end
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 88 
     | 
    
         
            +
                  it_should_behave_like('it can parse into a CAP 1.2 Area object')
         
     | 
| 
       89 
89 
     | 
    
         
             
                end
         
     | 
| 
       90 
90 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
                context( 
     | 
| 
       92 
     | 
    
         
            -
                  before( 
     | 
| 
       93 
     | 
    
         
            -
                    @area = RCAP::CAP_1_2::Area.from_h( 
     | 
| 
      
 91 
     | 
    
         
            +
                context('from a hash') do
         
     | 
| 
      
 92 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
      
 93 
     | 
    
         
            +
                    @area = RCAP::CAP_1_2::Area.from_h(@original_area.to_h)
         
     | 
| 
       94 
94 
     | 
    
         
             
                  end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                  it_should_behave_like( 
     | 
| 
      
 96 
     | 
    
         
            +
                  it_should_behave_like('it can parse into a CAP 1.2 Area object')
         
     | 
| 
       97 
97 
     | 
    
         
             
                end
         
     | 
| 
       98 
98 
     | 
    
         
             
              end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
              context( 
     | 
| 
       101 
     | 
    
         
            -
                before( 
     | 
| 
       102 
     | 
    
         
            -
                  @area = RCAP::CAP_1_2::Area.new( 
     | 
| 
      
 100 
     | 
    
         
            +
              context('when exported') do
         
     | 
| 
      
 101 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  @area = RCAP::CAP_1_2::Area.new(&@area_builder)
         
     | 
| 
       103 
103 
     | 
    
         
             
                end
         
     | 
| 
       104 
104 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                context( 
     | 
| 
       106 
     | 
    
         
            -
                  before( 
     | 
| 
      
 105 
     | 
    
         
            +
                context('to a hash') do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       107 
107 
     | 
    
         
             
                    @area_hash = @area.to_h
         
     | 
| 
       108 
108 
     | 
    
         
             
                  end
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
                  it( 
     | 
| 
       111 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::AREA_DESC_KEY 
     | 
| 
      
 110 
     | 
    
         
            +
                  it('should export the area description correctly') do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::AREA_DESC_KEY].should == @area.area_desc
         
     | 
| 
       112 
112 
     | 
    
         
             
                  end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
       114 
     | 
    
         
            -
                  it( 
     | 
| 
       115 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::ALTITUDE_KEY 
     | 
| 
      
 114 
     | 
    
         
            +
                  it('should export the altitude correctly') do
         
     | 
| 
      
 115 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::ALTITUDE_KEY].should == @area.altitude
         
     | 
| 
       116 
116 
     | 
    
         
             
                  end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
                  it( 
     | 
| 
       119 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::CEILING_KEY 
     | 
| 
      
 118 
     | 
    
         
            +
                  it('should set the ceiling correctly') do
         
     | 
| 
      
 119 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::CEILING_KEY].should == @area.ceiling
         
     | 
| 
       120 
120 
     | 
    
         
             
                  end
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                  it( 
     | 
| 
       123 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::CIRCLES_KEY 
     | 
| 
      
 122 
     | 
    
         
            +
                  it('should export the circles correctly') do
         
     | 
| 
      
 123 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::CIRCLES_KEY].should == @area.circles.map { |circle| circle.to_a }
         
     | 
| 
       124 
124 
     | 
    
         
             
                  end
         
     | 
| 
       125 
125 
     | 
    
         | 
| 
       126 
     | 
    
         
            -
                  it( 
     | 
| 
       127 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::GEOCODES_KEY 
     | 
| 
      
 126 
     | 
    
         
            +
                  it('should export the geocodes correctly') do
         
     | 
| 
      
 127 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::GEOCODES_KEY].should == @area.geocodes.map { |geocode| geocode.to_h }
         
     | 
| 
       128 
128 
     | 
    
         
             
                  end
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                  it( 
     | 
| 
       131 
     | 
    
         
            -
                    @area_hash[ RCAP::CAP_1_2::Area::POLYGONS_KEY 
     | 
| 
      
 130 
     | 
    
         
            +
                  it('should export the polygons correctly') do
         
     | 
| 
      
 131 
     | 
    
         
            +
                    @area_hash[ RCAP::CAP_1_2::Area::POLYGONS_KEY].should == @area.polygons.map { |polygon| polygon.to_h }
         
     | 
| 
       132 
132 
     | 
    
         
             
                  end
         
     | 
| 
       133 
133 
     | 
    
         
             
                end
         
     | 
| 
       134 
134 
     | 
    
         
             
              end
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
              context( 
     | 
| 
       137 
     | 
    
         
            -
                before( 
     | 
| 
      
 136 
     | 
    
         
            +
              context('is not valid if') do
         
     | 
| 
      
 137 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
       138 
138 
     | 
    
         
             
                  @area = RCAP::CAP_1_2::Area.new do |area|
         
     | 
| 
       139 
     | 
    
         
            -
                    area.area_desc =  
     | 
| 
      
 139 
     | 
    
         
            +
                    area.area_desc = 'Cape Town Metropole'
         
     | 
| 
       140 
140 
     | 
    
         
             
                  end
         
     | 
| 
       141 
     | 
    
         
            -
                  @area.should( 
     | 
| 
      
 141 
     | 
    
         
            +
                  @area.should(be_valid)
         
     | 
| 
       142 
142 
     | 
    
         
             
                end
         
     | 
| 
       143 
143 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
                it( 
     | 
| 
      
 144 
     | 
    
         
            +
                it('does not have an area descrtiption (area_desc)') do
         
     | 
| 
       145 
145 
     | 
    
         
             
                  @area.area_desc = nil
         
     | 
| 
       146 
     | 
    
         
            -
                  @area.should_not( 
     | 
| 
      
 146 
     | 
    
         
            +
                  @area.should_not(be_valid)
         
     | 
| 
       147 
147 
     | 
    
         
             
                end
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
     | 
    
         
            -
                it( 
     | 
| 
      
 149 
     | 
    
         
            +
                it('has a ceiling defined but no altitude') do
         
     | 
| 
       150 
150 
     | 
    
         
             
                  @area.ceiling = 1
         
     | 
| 
       151 
151 
     | 
    
         
             
                  @area.altitude = nil
         
     | 
| 
       152 
     | 
    
         
            -
                  @area.should_not( 
     | 
| 
      
 152 
     | 
    
         
            +
                  @area.should_not(be_valid)
         
     | 
| 
       153 
153 
     | 
    
         
             
                end
         
     | 
| 
       154 
154 
     | 
    
         | 
| 
       155 
     | 
    
         
            -
                context( 
     | 
| 
       156 
     | 
    
         
            -
                  before( 
     | 
| 
      
 155 
     | 
    
         
            +
                context('it contains circles and it') do
         
     | 
| 
      
 156 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       157 
157 
     | 
    
         
             
                    @area.add_circle do |circle|
         
     | 
| 
       158 
158 
     | 
    
         
             
                      circle.lattitude = 0
         
     | 
| 
       159 
159 
     | 
    
         
             
                      circle.longitude = 0
         
     | 
| 
       160 
160 
     | 
    
         
             
                      circle.radius = 1
         
     | 
| 
       161 
161 
     | 
    
         
             
                    end
         
     | 
| 
       162 
     | 
    
         
            -
                    @area.should( 
     | 
| 
      
 162 
     | 
    
         
            +
                    @area.should(be_valid)
         
     | 
| 
       163 
163 
     | 
    
         
             
                  end
         
     | 
| 
       164 
164 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                  it( 
     | 
| 
      
 165 
     | 
    
         
            +
                  it('has an invalid circle') do
         
     | 
| 
       166 
166 
     | 
    
         
             
                    @area.circles.first.lattitude = nil
         
     | 
| 
       167 
     | 
    
         
            -
                    @area.should_not( 
     | 
| 
      
 167 
     | 
    
         
            +
                    @area.should_not(be_valid)
         
     | 
| 
       168 
168 
     | 
    
         
             
                  end
         
     | 
| 
       169 
169 
     | 
    
         
             
                end
         
     | 
| 
       170 
170 
     | 
    
         | 
| 
       171 
     | 
    
         
            -
                context( 
     | 
| 
       172 
     | 
    
         
            -
                  before( 
     | 
| 
      
 171 
     | 
    
         
            +
                context('it contains polygons and it') do
         
     | 
| 
      
 172 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       173 
173 
     | 
    
         
             
                    @polygon = @area.add_polygon do |polygon|
         
     | 
| 
       174 
     | 
    
         
            -
                      [ 
     | 
| 
      
 174 
     | 
    
         
            +
                      [0, 1, 2, 0].each do |coordinate|
         
     | 
| 
       175 
175 
     | 
    
         
             
                        polygon.add_point do |point|
         
     | 
| 
       176 
176 
     | 
    
         
             
                          point.lattitude = coordinate
         
     | 
| 
       177 
177 
     | 
    
         
             
                          point.longitude = coordinate
         
     | 
| 
       178 
178 
     | 
    
         
             
                        end
         
     | 
| 
       179 
179 
     | 
    
         
             
                      end
         
     | 
| 
       180 
180 
     | 
    
         
             
                    end
         
     | 
| 
       181 
     | 
    
         
            -
                    @area.should( 
     | 
| 
      
 181 
     | 
    
         
            +
                    @area.should(be_valid)
         
     | 
| 
       182 
182 
     | 
    
         
             
                  end
         
     | 
| 
       183 
183 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
                  it( 
     | 
| 
      
 184 
     | 
    
         
            +
                  it('has an invalid polygon') do
         
     | 
| 
       185 
185 
     | 
    
         
             
                    @polygon.points.first.lattitude = nil
         
     | 
| 
       186 
     | 
    
         
            -
                    @area.should_not( 
     | 
| 
      
 186 
     | 
    
         
            +
                    @area.should_not(be_valid)
         
     | 
| 
       187 
187 
     | 
    
         
             
                  end
         
     | 
| 
       188 
188 
     | 
    
         
             
                end
         
     | 
| 
       189 
189 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
                context( 
     | 
| 
       191 
     | 
    
         
            -
                  before( 
     | 
| 
      
 190 
     | 
    
         
            +
                context('it contains geocodes and it') do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       192 
192 
     | 
    
         
             
                    @geocode = @area.add_geocode do |geocode|
         
     | 
| 
       193 
193 
     | 
    
         
             
                      geocode.name  = 'name'
         
     | 
| 
       194 
194 
     | 
    
         
             
                      geocode.value = 'value'
         
     | 
| 
       195 
195 
     | 
    
         
             
                    end
         
     | 
| 
       196 
196 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
                    @area.should( 
     | 
| 
      
 197 
     | 
    
         
            +
                    @area.should(be_valid)
         
     | 
| 
       198 
198 
     | 
    
         
             
                  end
         
     | 
| 
       199 
199 
     | 
    
         | 
| 
       200 
     | 
    
         
            -
                  it( 
     | 
| 
       201 
     | 
    
         
            -
                    @geocode. 
     | 
| 
       202 
     | 
    
         
            -
                    @area.should_not( 
     | 
| 
      
 200 
     | 
    
         
            +
                  it('has an invalid geocode') do
         
     | 
| 
      
 201 
     | 
    
         
            +
                    @geocode.name = nil
         
     | 
| 
      
 202 
     | 
    
         
            +
                    @area.should_not(be_valid)
         
     | 
| 
       203 
203 
     | 
    
         
             
                  end
         
     | 
| 
       204 
204 
     | 
    
         
             
                end
         
     | 
| 
       205 
205 
     | 
    
         
             
              end
         
     | 
| 
       206 
206 
     | 
    
         | 
| 
       207 
     | 
    
         
            -
              describe( 
     | 
| 
       208 
     | 
    
         
            -
                before( 
     | 
| 
      
 207 
     | 
    
         
            +
              describe('instance methods') do
         
     | 
| 
      
 208 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
       209 
209 
     | 
    
         
             
                  @area = RCAP::CAP_1_2::Area.new
         
     | 
| 
       210 
210 
     | 
    
         
             
                end
         
     | 
| 
       211 
211 
     | 
    
         | 
| 
       212 
     | 
    
         
            -
                describe( 
     | 
| 
       213 
     | 
    
         
            -
                  before( 
     | 
| 
      
 212 
     | 
    
         
            +
                describe('#add_polygon') do
         
     | 
| 
      
 213 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       214 
214 
     | 
    
         
             
                    @polygon = @area.add_polygon
         
     | 
| 
       215 
215 
     | 
    
         
             
                  end
         
     | 
| 
       216 
216 
     | 
    
         | 
| 
       217 
     | 
    
         
            -
                  it( 
     | 
| 
      
 217 
     | 
    
         
            +
                  it('should return a CAP 1.1 Polygon') do
         
     | 
| 
       218 
218 
     | 
    
         
             
                    @polygon.class.should == RCAP::CAP_1_2::Polygon
         
     | 
| 
       219 
219 
     | 
    
         
             
                  end
         
     | 
| 
       220 
220 
     | 
    
         | 
| 
       221 
     | 
    
         
            -
                  it( 
     | 
| 
      
 221 
     | 
    
         
            +
                  it('should add a Polygon to the polygons attribute') do
         
     | 
| 
       222 
222 
     | 
    
         
             
                    @area.polygons.size.should == 1
         
     | 
| 
       223 
223 
     | 
    
         
             
                  end
         
     | 
| 
       224 
224 
     | 
    
         
             
                end
         
     | 
| 
       225 
225 
     | 
    
         | 
| 
       226 
     | 
    
         
            -
                describe( 
     | 
| 
       227 
     | 
    
         
            -
                  before( 
     | 
| 
      
 226 
     | 
    
         
            +
                describe('#add_circle') do
         
     | 
| 
      
 227 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       228 
228 
     | 
    
         
             
                    @circle = @area.add_circle do |circle|
         
     | 
| 
       229 
229 
     | 
    
         
             
                      circle.lattitude = 1
         
     | 
| 
       230 
230 
     | 
    
         
             
                      circle.longitude = 1
         
     | 
| 
         @@ -232,33 +232,33 @@ describe( RCAP::CAP_1_2::Area ) do 
     | 
|
| 
       232 
232 
     | 
    
         
             
                    end
         
     | 
| 
       233 
233 
     | 
    
         
             
                  end
         
     | 
| 
       234 
234 
     | 
    
         | 
| 
       235 
     | 
    
         
            -
                  it( 
     | 
| 
      
 235 
     | 
    
         
            +
                  it('should return a CAP 1.1 Circle') do
         
     | 
| 
       236 
236 
     | 
    
         
             
                    @circle.class.should == RCAP::CAP_1_2::Circle
         
     | 
| 
       237 
237 
     | 
    
         
             
                    @circle.lattitude.should == 1
         
     | 
| 
       238 
238 
     | 
    
         
             
                    @circle.longitude.should == 1
         
     | 
| 
       239 
239 
     | 
    
         
             
                    @circle.radius.should == 1
         
     | 
| 
       240 
240 
     | 
    
         
             
                  end
         
     | 
| 
       241 
241 
     | 
    
         | 
| 
       242 
     | 
    
         
            -
                  it( 
     | 
| 
      
 242 
     | 
    
         
            +
                  it('should add a circle to the circles attribute') do
         
     | 
| 
       243 
243 
     | 
    
         
             
                    @area.circles.size.should == 1
         
     | 
| 
       244 
244 
     | 
    
         
             
                  end
         
     | 
| 
       245 
245 
     | 
    
         
             
                end
         
     | 
| 
       246 
246 
     | 
    
         | 
| 
       247 
     | 
    
         
            -
                describe( 
     | 
| 
       248 
     | 
    
         
            -
                  before( 
     | 
| 
      
 247 
     | 
    
         
            +
                describe('#add_geocode') do
         
     | 
| 
      
 248 
     | 
    
         
            +
                  before(:each) do
         
     | 
| 
       249 
249 
     | 
    
         
             
                    @geocode = @area.add_geocode do |geocode|
         
     | 
| 
       250 
250 
     | 
    
         
             
                      geocode.name = 'Geocode'
         
     | 
| 
       251 
251 
     | 
    
         
             
                      geocode.value = '123'
         
     | 
| 
       252 
252 
     | 
    
         
             
                    end
         
     | 
| 
       253 
253 
     | 
    
         
             
                  end
         
     | 
| 
       254 
254 
     | 
    
         | 
| 
       255 
     | 
    
         
            -
                  it( 
     | 
| 
      
 255 
     | 
    
         
            +
                  it('should return a CAP 1.1 Geocode') do
         
     | 
| 
       256 
256 
     | 
    
         
             
                    @geocode.class.should == RCAP::CAP_1_2::Geocode
         
     | 
| 
       257 
257 
     | 
    
         
             
                    @geocode.name.should == 'Geocode'
         
     | 
| 
       258 
258 
     | 
    
         
             
                    @geocode.value.should == '123'
         
     | 
| 
       259 
259 
     | 
    
         
             
                  end
         
     | 
| 
       260 
260 
     | 
    
         | 
| 
       261 
     | 
    
         
            -
                  it( 
     | 
| 
      
 261 
     | 
    
         
            +
                  it('should add a geocode to the geocodes attribute') do
         
     | 
| 
       262 
262 
     | 
    
         
             
                    @area.geocodes.size.should == 1
         
     | 
| 
       263 
263 
     | 
    
         
             
                  end
         
     | 
| 
       264 
264 
     | 
    
         
             
                end
         
     |