rcap 0.4 → 1.0.0.rc.1
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.
- data/.gitignore +7 -0
- data/CHANGELOG.rdoc +6 -0
- data/Gemfile +4 -0
- data/README.rdoc +104 -85
- data/Rakefile +35 -0
- data/lib/rcap.rb +21 -14
- data/lib/rcap/alert.rb +26 -325
- data/lib/rcap/cap_1_1/alert.rb +363 -0
- data/lib/rcap/cap_1_1/area.rb +180 -0
- data/lib/rcap/cap_1_1/circle.rb +81 -0
- data/lib/rcap/cap_1_1/event_code.rb +22 -0
- data/lib/rcap/cap_1_1/geocode.rb +22 -0
- data/lib/rcap/cap_1_1/info.rb +470 -0
- data/lib/rcap/cap_1_1/parameter.rb +68 -0
- data/lib/rcap/cap_1_1/point.rb +55 -0
- data/lib/rcap/cap_1_1/polygon.rb +89 -0
- data/lib/rcap/cap_1_1/resource.rb +145 -0
- data/lib/rcap/cap_1_2/alert.rb +363 -0
- data/lib/rcap/cap_1_2/area.rb +180 -0
- data/lib/rcap/cap_1_2/circle.rb +81 -0
- data/lib/rcap/cap_1_2/event_code.rb +22 -0
- data/lib/rcap/cap_1_2/geocode.rb +22 -0
- data/lib/rcap/cap_1_2/info.rb +472 -0
- data/lib/rcap/cap_1_2/parameter.rb +68 -0
- data/lib/rcap/cap_1_2/point.rb +55 -0
- data/lib/rcap/cap_1_2/polygon.rb +90 -0
- data/lib/rcap/cap_1_2/resource.rb +147 -0
- data/lib/rcap/utilities.rb +14 -9
- data/lib/rcap/validations.rb +39 -7
- data/lib/rcap/version.rb +3 -0
- data/rcap.gemspec +30 -0
- data/spec/alert_spec.rb +109 -172
- data/spec/cap_1_1/alert_spec.rb +222 -0
- data/spec/cap_1_1/area_spec.rb +247 -0
- data/spec/cap_1_1/circle_spec.rb +88 -0
- data/spec/{geocode_spec.rb → cap_1_1/geocode_spec.rb} +8 -8
- data/spec/{info_spec.rb → cap_1_1/info_spec.rb} +143 -75
- data/spec/{point_spec.rb → cap_1_1/point_spec.rb} +8 -8
- data/spec/cap_1_1/polygon_spec.rb +97 -0
- data/spec/{resource_spec.rb → cap_1_1/resource_spec.rb} +24 -24
- data/spec/cap_1_2/alert_spec.rb +233 -0
- data/spec/cap_1_2/area_spec.rb +248 -0
- data/spec/cap_1_2/circle_spec.rb +95 -0
- data/spec/cap_1_2/geocode_spec.rb +38 -0
- data/spec/cap_1_2/info_spec.rb +338 -0
- data/spec/cap_1_2/point_spec.rb +46 -0
- data/spec/cap_1_2/polygon_spec.rb +102 -0
- data/spec/cap_1_2/resource_spec.rb +161 -0
- data/spec/spec.opts +2 -0
- data/spec/validations_spec.rb +80 -7
- metadata +122 -37
- data/lib/rcap/area.rb +0 -156
- data/lib/rcap/circle.rb +0 -78
- data/lib/rcap/event_code.rb +0 -20
- data/lib/rcap/geocode.rb +0 -20
- data/lib/rcap/info.rb +0 -437
- data/lib/rcap/parameter.rb +0 -66
- data/lib/rcap/point.rb +0 -53
- data/lib/rcap/polygon.rb +0 -77
- data/lib/rcap/resource.rb +0 -143
- data/spec/area_spec.rb +0 -179
- data/spec/circle_spec.rb +0 -88
- data/spec/polygon_spec.rb +0 -68
@@ -0,0 +1,247 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe( RCAP::CAP_1_1::Area ) do
|
4
|
+
context( 'on initialisation' ) do
|
5
|
+
before( :each ) do
|
6
|
+
@area = RCAP::CAP_1_1::Area.new
|
7
|
+
end
|
8
|
+
|
9
|
+
# Atomic
|
10
|
+
it( 'should not have a area_desc' ){ @area.area_desc.should( be_nil )}
|
11
|
+
it( 'should not have a altitude' ){ @area.altitude.should( be_nil )}
|
12
|
+
it( 'should not have a ceiling' ){ @area.ceiling.should( be_nil )}
|
13
|
+
|
14
|
+
# Group
|
15
|
+
it( 'should have an empty polygons' ){ @area.polygons.should( be_empty )}
|
16
|
+
it( 'should have an empty circles' ){ @area.circles.should( be_empty )}
|
17
|
+
it( 'should have an empty geocodes' ){ @area.geocodes.should( be_empty )}
|
18
|
+
|
19
|
+
shared_examples_for( "it can parse into a CAP 1.1 Area object" ) do
|
20
|
+
it( 'should parse the area_desc correctly' ) do
|
21
|
+
@area.area_desc.should == @original_area.area_desc
|
22
|
+
end
|
23
|
+
|
24
|
+
it( 'should parse the altitude correctly' ) do
|
25
|
+
@area.altitude.should == @original_area.altitude
|
26
|
+
end
|
27
|
+
|
28
|
+
it( 'should parse the ceiling correctly' ) do
|
29
|
+
@area.ceiling.should == @original_area.ceiling
|
30
|
+
end
|
31
|
+
|
32
|
+
it( 'should parse the circles correctly' ) do
|
33
|
+
@area.circles.should == @original_area.circles
|
34
|
+
end
|
35
|
+
|
36
|
+
it( 'should parse the geocodes correctly' ) do
|
37
|
+
@area.geocodes.should == @original_area.geocodes
|
38
|
+
end
|
39
|
+
|
40
|
+
it( 'should parse the polygons correctly' ) do
|
41
|
+
@area.polygons.should == @original_area.polygons
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context( 'from XML' ) do
|
46
|
+
before( :each ) do
|
47
|
+
@original_area = RCAP::CAP_1_1::Area.new( :area_desc => 'Area Description',
|
48
|
+
:altitude => 100,
|
49
|
+
:ceiling => 200,
|
50
|
+
:circles => RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0 , :radius => 100 ),
|
51
|
+
:geocodes => RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' ),
|
52
|
+
:polygons => RCAP::CAP_1_1::Polygon.new( :points => RCAP::CAP_1_1::Point.new( :lattitude =>1, :longitude => 1 )))
|
53
|
+
|
54
|
+
@alert = RCAP::CAP_1_1::Alert.new( :infos => RCAP::CAP_1_1::Info.new( :areas => @original_area ))
|
55
|
+
@xml_string = @alert.to_xml
|
56
|
+
@xml_document = REXML::Document.new( @xml_string )
|
57
|
+
@info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_1::Info::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
58
|
+
@area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_1::Area::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
59
|
+
@area = RCAP::CAP_1_1::Area.from_xml_element( @area_xml_element )
|
60
|
+
end
|
61
|
+
|
62
|
+
it_should_behave_like( "it can parse into a CAP 1.1 Area object" )
|
63
|
+
end
|
64
|
+
|
65
|
+
context( 'from YAML Data' ) do
|
66
|
+
before( :each ) do
|
67
|
+
@original_area = RCAP::CAP_1_1::Area.new( :area_desc => 'Area Description',
|
68
|
+
:altitude => 100,
|
69
|
+
:ceiling => 200,
|
70
|
+
:circles => RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0 , :radius => 100 ),
|
71
|
+
:geocodes => RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' ),
|
72
|
+
:polygons => RCAP::CAP_1_1::Polygon.new( :points => RCAP::CAP_1_1::Point.new( :lattitude =>1, :longitude => 1 )))
|
73
|
+
|
74
|
+
@area = RCAP::CAP_1_1::Area.from_yaml_data( YAML.load( @original_area.to_yaml ))
|
75
|
+
end
|
76
|
+
|
77
|
+
it_should_behave_like( "it can parse into a CAP 1.1 Area object" )
|
78
|
+
end
|
79
|
+
|
80
|
+
context( 'from a hash' ) do
|
81
|
+
before( :each ) do
|
82
|
+
@original_area = RCAP::CAP_1_1::Area.new( :area_desc => 'Area Description',
|
83
|
+
:altitude => 100,
|
84
|
+
:ceiling => 200,
|
85
|
+
:circles => RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0 , :radius => 100 ),
|
86
|
+
:geocodes => RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' ),
|
87
|
+
:polygons => RCAP::CAP_1_1::Polygon.new( :points => RCAP::CAP_1_1::Point.new( :lattitude =>1, :longitude => 1 )))
|
88
|
+
|
89
|
+
@area = RCAP::CAP_1_1::Area.from_h( @original_area.to_h )
|
90
|
+
end
|
91
|
+
|
92
|
+
it_should_behave_like( "it can parse into a CAP 1.1 Area object" )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context( 'when exported' ) do
|
97
|
+
before( :each ) do
|
98
|
+
@area = RCAP::CAP_1_1::Area.new( :area_desc => 'Area Description',
|
99
|
+
:altitude => 100,
|
100
|
+
:ceiling => 200,
|
101
|
+
:circles => RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0 , :radius => 100 ),
|
102
|
+
:geocodes => RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' ),
|
103
|
+
:polygons => RCAP::CAP_1_1::Polygon.new( :points => RCAP::CAP_1_1::Point.new( :lattitude =>1, :longitude => 1 )))
|
104
|
+
end
|
105
|
+
context( 'to a hash' ) do
|
106
|
+
before( :each ) do
|
107
|
+
@area_hash = @area.to_h
|
108
|
+
end
|
109
|
+
|
110
|
+
it( 'should export the area description correctly' ) do
|
111
|
+
@area_hash[ RCAP::CAP_1_1::Area::AREA_DESC_KEY ].should == @area.area_desc
|
112
|
+
end
|
113
|
+
|
114
|
+
it( 'should export the altitude correctly' ) do
|
115
|
+
@area_hash[ RCAP::CAP_1_1::Area::ALTITUDE_KEY ].should == @area.altitude
|
116
|
+
end
|
117
|
+
|
118
|
+
it( 'should set the ceiling correctly' ) do
|
119
|
+
@area_hash[ RCAP::CAP_1_1::Area::CEILING_KEY ].should == @area.ceiling
|
120
|
+
end
|
121
|
+
|
122
|
+
it( 'should export the circles correctly' ) do
|
123
|
+
@area_hash[ RCAP::CAP_1_1::Area::CIRCLES_KEY ].should == @area.circles.map{ |circle| circle.to_h }
|
124
|
+
end
|
125
|
+
|
126
|
+
it( 'should export the geocodes correctly' ) do
|
127
|
+
@area_hash[ RCAP::CAP_1_1::Area::GEOCODES_KEY ].should == @area.geocodes.map{ |geocode| geocode.to_h }
|
128
|
+
end
|
129
|
+
|
130
|
+
it( 'should export the polygons correctly' ) do
|
131
|
+
@area_hash[ RCAP::CAP_1_1::Area::POLYGONS_KEY ].should == @area.polygons.map{ |polygon| polygon.to_h }
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context( 'is not valid if' ) do
|
137
|
+
before( :each ) do
|
138
|
+
@area = RCAP::CAP_1_1::Area.new( :area_desc => "Cape Town Metropole" )
|
139
|
+
@area.should( be_valid )
|
140
|
+
end
|
141
|
+
|
142
|
+
it( 'does not have an area descrtiption (area_desc)') do
|
143
|
+
@area.area_desc = nil
|
144
|
+
@area.should_not( be_valid )
|
145
|
+
end
|
146
|
+
|
147
|
+
it( 'has a ceiling defined but no altitude' ) do
|
148
|
+
@area.ceiling = 1
|
149
|
+
@area.altitude = nil
|
150
|
+
@area.should_not( be_valid )
|
151
|
+
end
|
152
|
+
|
153
|
+
context( 'it contains circles and it' ) do
|
154
|
+
before( :each ) do
|
155
|
+
@area.circles << RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0, :radius => 1)
|
156
|
+
@area.should( be_valid )
|
157
|
+
end
|
158
|
+
|
159
|
+
it( 'has an invalid circle' ) do
|
160
|
+
@area.circles.first.lattitude = nil
|
161
|
+
@area.should_not( be_valid )
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context( 'it contains polygons and it' ) do
|
166
|
+
before( :each ) do
|
167
|
+
@polygon = RCAP::CAP_1_1::Polygon.new
|
168
|
+
@polygon.points.push( RCAP::CAP_1_1::Point.new( :lattitude => 0, :longitude => 0 ),
|
169
|
+
RCAP::CAP_1_1::Point.new( :lattitude => 0, :longitude => 1 ),
|
170
|
+
RCAP::CAP_1_1::Point.new( :lattitude => 1, :longitude => 0 ))
|
171
|
+
@area.polygons << @polygon
|
172
|
+
@area.should( be_valid )
|
173
|
+
end
|
174
|
+
|
175
|
+
it( 'has an invalid polygon' ) do
|
176
|
+
@polygon.points.first.lattitude = nil
|
177
|
+
@area.should_not( be_valid )
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context( 'it contains geocodes and it' ) do
|
182
|
+
before( :each ) do
|
183
|
+
@geocode = RCAP::CAP_1_1::Geocode.new( :name => 'foo', :value => 'bar' )
|
184
|
+
@area.geocodes << @geocode
|
185
|
+
@area.should( be_valid )
|
186
|
+
end
|
187
|
+
|
188
|
+
it( 'has an invalid geocode' ) do
|
189
|
+
@geocode.value = nil
|
190
|
+
@area.should_not( be_valid )
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe( 'instance methods' ) do
|
196
|
+
before( :each ) do
|
197
|
+
@area = RCAP::CAP_1_1::Area.new
|
198
|
+
end
|
199
|
+
|
200
|
+
describe( '#add_polygon' ) do
|
201
|
+
before( :each ) do
|
202
|
+
@polygon = @area.add_polygon
|
203
|
+
end
|
204
|
+
|
205
|
+
it( 'should return a CAP 1.1 Polygon' ) do
|
206
|
+
@polygon.class.should == RCAP::CAP_1_1::Polygon
|
207
|
+
end
|
208
|
+
|
209
|
+
it( 'should add a Polygon to the polygons attribute' ) do
|
210
|
+
@area.polygons.size.should == 1
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe( '#add_circle' ) do
|
215
|
+
before( :each ) do
|
216
|
+
@circle = @area.add_circle( lattitude: 1, longitude: 1, radius: 1 )
|
217
|
+
end
|
218
|
+
|
219
|
+
it( 'should return a CAP 1.1 Circle' ) do
|
220
|
+
@circle.class.should == RCAP::CAP_1_1::Circle
|
221
|
+
@circle.lattitude.should == 1
|
222
|
+
@circle.longitude.should == 1
|
223
|
+
@circle.radius.should == 1
|
224
|
+
end
|
225
|
+
|
226
|
+
it( 'should add a circle to the circles attribute' ) do
|
227
|
+
@area.circles.size.should == 1
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe( '#add_geocode' ) do
|
232
|
+
before( :each ) do
|
233
|
+
@geocode = @area.add_geocode( name: 'Geocode', value: '123' )
|
234
|
+
end
|
235
|
+
|
236
|
+
it( 'should return a CAP 1.1 Geocode' ) do
|
237
|
+
@geocode.class.should == RCAP::CAP_1_1::Geocode
|
238
|
+
@geocode.name.should == 'Geocode'
|
239
|
+
@geocode.value.should == '123'
|
240
|
+
end
|
241
|
+
|
242
|
+
it( 'should add a geocode to the geocodes attribute' ) do
|
243
|
+
@area.geocodes.size.should == 1
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe( RCAP::CAP_1_1::Circle ) do
|
4
|
+
describe( 'should not be valid if' ) do
|
5
|
+
before( :each ) do
|
6
|
+
@circle = RCAP::CAP_1_1::Circle.new( :lattitude => 0, :longitude => 0 , :radius => 1 )
|
7
|
+
@circle.should( be_valid )
|
8
|
+
end
|
9
|
+
|
10
|
+
it( 'does not have a lattitude defined' ) do
|
11
|
+
@circle.lattitude = nil
|
12
|
+
@circle.should_not( be_valid )
|
13
|
+
end
|
14
|
+
|
15
|
+
it( 'does not have a longitude defined' ) do
|
16
|
+
@circle.longitude = nil
|
17
|
+
@circle.should_not( be_valid )
|
18
|
+
end
|
19
|
+
|
20
|
+
it( 'does not have a radius defined' ) do
|
21
|
+
@circle.radius = nil
|
22
|
+
@circle.should_not( be_valid )
|
23
|
+
end
|
24
|
+
|
25
|
+
it( 'does not have a numeric radius' ) do
|
26
|
+
@circle.radius = "not a number"
|
27
|
+
@circle.should_not( be_valid )
|
28
|
+
end
|
29
|
+
|
30
|
+
it( 'does not have a positive radius' ) do
|
31
|
+
@circle.radius = -1
|
32
|
+
@circle.should_not( be_valid )
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context( 'on initialisation' ) do
|
37
|
+
context( 'from XML' ) do
|
38
|
+
before( :each ) do
|
39
|
+
@original_circle = RCAP::CAP_1_1::Circle.new( :radius => 10.5,
|
40
|
+
:lattitude => 30, :longitude => 60 )
|
41
|
+
@alert = RCAP::CAP_1_1::Alert.new( :infos => RCAP::CAP_1_1::Info.new( :areas => RCAP::CAP_1_1::Area.new( :circles => @original_circle )))
|
42
|
+
@xml_string = @alert.to_xml
|
43
|
+
@xml_document = REXML::Document.new( @xml_string )
|
44
|
+
@info_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_1::Info::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
45
|
+
@area_element = RCAP.xpath_first( @info_element, RCAP::CAP_1_1::Area::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
46
|
+
@circle_element = RCAP.xpath_first( @area_element, RCAP::CAP_1_1::Circle::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
47
|
+
@circle = RCAP::CAP_1_1::Circle.from_xml_element( @circle_element )
|
48
|
+
end
|
49
|
+
|
50
|
+
it( 'should parse the radius correctly' ) do
|
51
|
+
@circle.radius.should == @original_circle.radius
|
52
|
+
end
|
53
|
+
|
54
|
+
it( 'should parse the lattitude and longitude correctly' ) do
|
55
|
+
@circle.lattitude.should == @original_circle.lattitude
|
56
|
+
@circle.longitude.should == @original_circle.longitude
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context( 'from a hash' ) do
|
61
|
+
before( :each ) do
|
62
|
+
@original_circle = RCAP::CAP_1_1::Circle.new( :radius => 10.5, :lattitude => 30, :longitude => 60 )
|
63
|
+
@circle = RCAP::CAP_1_1::Circle.from_h( @original_circle.to_h )
|
64
|
+
end
|
65
|
+
|
66
|
+
it( 'should set the radius correctly' ) do
|
67
|
+
@circle.radius.should == @original_circle.radius
|
68
|
+
end
|
69
|
+
|
70
|
+
it( 'should parse the lattitude and longitude correctly' ) do
|
71
|
+
@circle.lattitude.should == @original_circle.lattitude
|
72
|
+
@circle.longitude.should == @original_circle.longitude
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context( 'when exported' ) do
|
78
|
+
before( :each ) do
|
79
|
+
@circle = RCAP::CAP_1_1::Circle.new( :radius => 10.5, :lattitude => 30, :longitude => 60 )
|
80
|
+
end
|
81
|
+
|
82
|
+
context( 'to hash' ) do
|
83
|
+
it( 'should be correct' ) do
|
84
|
+
@circle.to_h.should == { 'radius' => 10.5, 'lattitude' => 30, 'longitude' => 60 }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe( RCAP::Geocode ) do
|
3
|
+
describe( RCAP::CAP_1_1::Geocode ) do
|
4
4
|
context( 'when initialised' ) do
|
5
5
|
context( 'from XML' ) do
|
6
6
|
before( :each ) do
|
7
|
-
@original_geocode = RCAP::Geocode.new( :name => 'name', :value => 'value' )
|
8
|
-
@alert = RCAP::Alert.new( :infos => RCAP::Info.new( :areas => RCAP::Area.new( :geocodes => @original_geocode )))
|
7
|
+
@original_geocode = RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' )
|
8
|
+
@alert = RCAP::CAP_1_1::Alert.new( :infos => RCAP::CAP_1_1::Info.new( :areas => RCAP::CAP_1_1::Area.new( :geocodes => @original_geocode )))
|
9
9
|
@xml_string = @alert.to_xml
|
10
10
|
@xml_document = REXML::Document.new( @xml_string )
|
11
|
-
@info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::Info::XPATH )
|
12
|
-
@area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::Area::XPATH )
|
13
|
-
@geocode_xml_element = RCAP.xpath_first( @area_xml_element, RCAP::Geocode::XPATH )
|
14
|
-
@geocode = RCAP::Geocode.from_xml_element( @geocode_xml_element )
|
11
|
+
@info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_1::Info::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
12
|
+
@area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_1::Area::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
13
|
+
@geocode_xml_element = RCAP.xpath_first( @area_xml_element, RCAP::CAP_1_1::Geocode::XPATH, RCAP::CAP_1_1::Alert::XMLNS )
|
14
|
+
@geocode = RCAP::CAP_1_1::Geocode.from_xml_element( @geocode_xml_element )
|
15
15
|
end
|
16
16
|
|
17
17
|
it( 'should parse the name correctly' ) do
|
@@ -26,7 +26,7 @@ describe( RCAP::Geocode ) do
|
|
26
26
|
|
27
27
|
context( 'when exported' ) do
|
28
28
|
before( :each ) do
|
29
|
-
@geocode = RCAP::Geocode.new( :name => 'name', :value => 'value' )
|
29
|
+
@geocode = RCAP::CAP_1_1::Geocode.new( :name => 'name', :value => 'value' )
|
30
30
|
end
|
31
31
|
|
32
32
|
context( 'to a hash' ) do
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe( RCAP::Info ) do
|
3
|
+
describe( RCAP::CAP_1_1::Info ) do
|
4
4
|
context( 'on initialisation' ) do
|
5
5
|
before( :each ) do
|
6
|
-
@info = RCAP::Info.new
|
6
|
+
@info = RCAP::CAP_1_1::Info.new
|
7
7
|
end
|
8
8
|
|
9
9
|
it( 'should have a default language of en-US' ) { @info.language.should == 'en-US' }
|
@@ -26,7 +26,7 @@ describe( RCAP::Info ) do
|
|
26
26
|
it( 'should have no contact' ) { @info.contact.should( be_nil )}
|
27
27
|
it( 'should have no parameters' ) { @info.parameters.should( be_empty )}
|
28
28
|
|
29
|
-
shared_examples_for( 'it can parse into
|
29
|
+
shared_examples_for( 'it can parse into a CAP 1.1 Info object' ) do
|
30
30
|
it( 'should parse categories correctly' ){ @info .categories.should == @original_info.categories }
|
31
31
|
it( 'should parse event correctly' ){ @info .event.should == @original_info.event }
|
32
32
|
it( 'should parse response_types correctly' ){ @info .response_types.should == @original_info.response_types }
|
@@ -34,9 +34,9 @@ describe( RCAP::Info ) do
|
|
34
34
|
it( 'should parse severity correctly' ){ @info .severity.should == @original_info.severity }
|
35
35
|
it( 'should parse certainty correctly' ){ @info .certainty.should == @original_info.certainty }
|
36
36
|
it( 'should parse audience correctly' ){ @info .audience.should == @original_info.audience }
|
37
|
-
it( 'should parse effective correctly' ){ @info .effective.should(
|
38
|
-
it( 'should parse onset correctly' ){ @info .onset.should(
|
39
|
-
it( 'should parse expires correctly' ){ @info .expires.should(
|
37
|
+
it( 'should parse effective correctly' ){ @info .effective.should( be_within(Rational( 1, 86400 )).of( @original_info.effective ))}
|
38
|
+
it( 'should parse onset correctly' ){ @info .onset.should( be_within( Rational( 1, 86400 )).of( @original_info.onset ))}
|
39
|
+
it( 'should parse expires correctly' ){ @info .expires.should( be_within( Rational( 1, 86400 )).of( @original_info.expires ))}
|
40
40
|
it( 'should parse sender_name correctly' ){ @info .sender_name.should == @original_info.sender_name }
|
41
41
|
it( 'should parse headline correctly' ){ @info .headline.should == @original_info.headline }
|
42
42
|
it( 'should parse description correctly' ){ @info .description.should == @original_info.description }
|
@@ -51,12 +51,12 @@ describe( RCAP::Info ) do
|
|
51
51
|
|
52
52
|
context( 'from XML' ) do
|
53
53
|
before( :each ) do
|
54
|
-
@original_info = RCAP::Info.new( :categories => [ RCAP::Info::CATEGORY_GEO, RCAP::Info::CATEGORY_FIRE ],
|
54
|
+
@original_info = RCAP::CAP_1_1::Info.new( :categories => [ RCAP::CAP_1_1::Info::CATEGORY_GEO, RCAP::CAP_1_1::Info::CATEGORY_FIRE ],
|
55
55
|
:event => 'Event Description',
|
56
|
-
:response_types => [ RCAP::Info::RESPONSE_TYPE_MONITOR, RCAP::Info::RESPONSE_TYPE_ASSESS ],
|
57
|
-
:urgency => RCAP::Info::URGENCY_IMMEDIATE,
|
58
|
-
:severity => RCAP::Info::SEVERITY_EXTREME,
|
59
|
-
:certainty => RCAP::Info::CERTAINTY_OBSERVED,
|
56
|
+
:response_types => [ RCAP::CAP_1_1::Info::RESPONSE_TYPE_MONITOR, RCAP::CAP_1_1::Info::RESPONSE_TYPE_ASSESS ],
|
57
|
+
:urgency => RCAP::CAP_1_1::Info::URGENCY_IMMEDIATE,
|
58
|
+
:severity => RCAP::CAP_1_1::Info::SEVERITY_EXTREME,
|
59
|
+
:certainty => RCAP::CAP_1_1::Info::CERTAINTY_OBSERVED,
|
60
60
|
:audience => 'Audience',
|
61
61
|
:effective => DateTime.now,
|
62
62
|
:onset => DateTime.now + 1,
|
@@ -67,30 +67,30 @@ describe( RCAP::Info ) do
|
|
67
67
|
:instruction => 'Instruction',
|
68
68
|
:web => 'http://website',
|
69
69
|
:contact => 'contact@address',
|
70
|
-
:event_codes => [ RCAP::EventCode.new( :name => 'name1', :value => 'value1' ),
|
71
|
-
RCAP::EventCode.new( :name => 'name2', :value => 'value2' )],
|
72
|
-
:parameters => [ RCAP::Parameter.new( :name => 'name1', :value => 'value1' ),
|
73
|
-
RCAP::Parameter.new( :name => 'name2', :value => 'value2' )],
|
74
|
-
:areas => [ RCAP::Area.new( :area_desc => 'Area1' ),
|
75
|
-
RCAP::Area.new( :area_desc => 'Area2' )]
|
70
|
+
:event_codes => [ RCAP::CAP_1_1::EventCode.new( :name => 'name1', :value => 'value1' ),
|
71
|
+
RCAP::CAP_1_1::EventCode.new( :name => 'name2', :value => 'value2' )],
|
72
|
+
:parameters => [ RCAP::CAP_1_1::Parameter.new( :name => 'name1', :value => 'value1' ),
|
73
|
+
RCAP::CAP_1_1::Parameter.new( :name => 'name2', :value => 'value2' )],
|
74
|
+
:areas => [ RCAP::CAP_1_1::Area.new( :area_desc => 'Area1' ),
|
75
|
+
RCAP::CAP_1_1::Area.new( :area_desc => 'Area2' )]
|
76
76
|
)
|
77
|
-
@alert = RCAP::Alert.new( :infos => @original_info )
|
78
|
-
|
79
|
-
|
80
|
-
@info = RCAP::Info.from_xml_element( RCAP.xpath_first( @xml_document.root, RCAP::Info::XPATH ))
|
77
|
+
@alert = RCAP::CAP_1_1::Alert.new( :infos => @original_info )
|
78
|
+
@xml_string = @alert.to_xml
|
79
|
+
@xml_document = REXML::Document.new( @xml_string )
|
80
|
+
@info = RCAP::CAP_1_1::Info.from_xml_element( RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_1::Info::XPATH, RCAP::CAP_1_1::Alert::XMLNS ))
|
81
81
|
end
|
82
82
|
|
83
|
-
it_should_behave_like( "it can parse into
|
83
|
+
it_should_behave_like( "it can parse into a CAP 1.1 Info object" )
|
84
84
|
end
|
85
85
|
|
86
86
|
context( 'from a hash' ) do
|
87
87
|
before( :each ) do
|
88
|
-
@original_info = RCAP::Info.new( :categories => [ RCAP::Info::CATEGORY_GEO, RCAP::Info::CATEGORY_FIRE ],
|
88
|
+
@original_info = RCAP::CAP_1_1::Info.new( :categories => [ RCAP::CAP_1_1::Info::CATEGORY_GEO, RCAP::CAP_1_1::Info::CATEGORY_FIRE ],
|
89
89
|
:event => 'Event Description',
|
90
|
-
:response_types => [ RCAP::Info::RESPONSE_TYPE_MONITOR, RCAP::Info::RESPONSE_TYPE_ASSESS ],
|
91
|
-
:urgency => RCAP::Info::URGENCY_IMMEDIATE,
|
92
|
-
:severity => RCAP::Info::SEVERITY_EXTREME,
|
93
|
-
:certainty => RCAP::Info::CERTAINTY_OBSERVED,
|
90
|
+
:response_types => [ RCAP::CAP_1_1::Info::RESPONSE_TYPE_MONITOR, RCAP::CAP_1_1::Info::RESPONSE_TYPE_ASSESS ],
|
91
|
+
:urgency => RCAP::CAP_1_1::Info::URGENCY_IMMEDIATE,
|
92
|
+
:severity => RCAP::CAP_1_1::Info::SEVERITY_EXTREME,
|
93
|
+
:certainty => RCAP::CAP_1_1::Info::CERTAINTY_OBSERVED,
|
94
94
|
:audience => 'Audience',
|
95
95
|
:effective => DateTime.now,
|
96
96
|
:onset => DateTime.now + 1,
|
@@ -101,31 +101,31 @@ describe( RCAP::Info ) do
|
|
101
101
|
:instruction => 'Instruction',
|
102
102
|
:web => 'http://website',
|
103
103
|
:contact => 'contact@address',
|
104
|
-
:event_codes => [ RCAP::EventCode.new( :name => 'name1', :value => 'value1' ),
|
105
|
-
RCAP::EventCode.new( :name => 'name2', :value => 'value2' )],
|
106
|
-
:parameters => [ RCAP::Parameter.new( :name => 'name1', :value => 'value1' ),
|
107
|
-
RCAP::Parameter.new( :name => 'name2', :value => 'value2' )],
|
108
|
-
:areas => [ RCAP::Area.new( :area_desc => 'Area1' ),
|
109
|
-
RCAP::Area.new( :area_desc => 'Area2' )]
|
104
|
+
:event_codes => [ RCAP::CAP_1_1::EventCode.new( :name => 'name1', :value => 'value1' ),
|
105
|
+
RCAP::CAP_1_1::EventCode.new( :name => 'name2', :value => 'value2' )],
|
106
|
+
:parameters => [ RCAP::CAP_1_1::Parameter.new( :name => 'name1', :value => 'value1' ),
|
107
|
+
RCAP::CAP_1_1::Parameter.new( :name => 'name2', :value => 'value2' )],
|
108
|
+
:areas => [ RCAP::CAP_1_1::Area.new( :area_desc => 'Area1' ),
|
109
|
+
RCAP::CAP_1_1::Area.new( :area_desc => 'Area2' )]
|
110
110
|
)
|
111
|
-
@info = RCAP::Info.from_h( @original_info.to_h )
|
111
|
+
@info = RCAP::CAP_1_1::Info.from_h( @original_info.to_h )
|
112
112
|
end
|
113
|
-
it_should_behave_like( "it can parse into
|
113
|
+
it_should_behave_like( "it can parse into a CAP 1.1 Info object" )
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
context( 'is not valid if it' ) do
|
118
118
|
before( :each ) do
|
119
|
-
@info = RCAP::Info.new( :event => 'Info Event',
|
120
|
-
:categories => RCAP::Info::CATEGORY_GEO,
|
121
|
-
:urgency => RCAP::Info::URGENCY_IMMEDIATE,
|
122
|
-
:severity => RCAP::Info::SEVERITY_EXTREME,
|
123
|
-
:certainty => RCAP::Info::CERTAINTY_OBSERVED )
|
119
|
+
@info = RCAP::CAP_1_1::Info.new( :event => 'Info Event',
|
120
|
+
:categories => RCAP::CAP_1_1::Info::CATEGORY_GEO,
|
121
|
+
:urgency => RCAP::CAP_1_1::Info::URGENCY_IMMEDIATE,
|
122
|
+
:severity => RCAP::CAP_1_1::Info::SEVERITY_EXTREME,
|
123
|
+
:certainty => RCAP::CAP_1_1::Info::CERTAINTY_OBSERVED )
|
124
124
|
@info.valid?
|
125
125
|
puts @info.errors.full_messages
|
126
126
|
@info.should( be_valid )
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it( 'does not have an event' ) do
|
130
130
|
@info.event = nil
|
131
131
|
@info.should_not( be_valid )
|
@@ -156,12 +156,12 @@ describe( RCAP::Info ) do
|
|
156
156
|
describe( 'when exported' ) do
|
157
157
|
context( 'to hash' ) do
|
158
158
|
before( :each ) do
|
159
|
-
@info = RCAP::Info.new( :categories => [ RCAP::Info::CATEGORY_GEO, RCAP::Info::CATEGORY_FIRE ],
|
159
|
+
@info = RCAP::CAP_1_1::Info.new( :categories => [ RCAP::CAP_1_1::Info::CATEGORY_GEO, RCAP::CAP_1_1::Info::CATEGORY_FIRE ],
|
160
160
|
:event => 'Event Description',
|
161
|
-
:response_types => [ RCAP::Info::RESPONSE_TYPE_MONITOR, RCAP::Info::RESPONSE_TYPE_ASSESS ],
|
162
|
-
:urgency => RCAP::Info::URGENCY_IMMEDIATE,
|
163
|
-
:severity => RCAP::Info::SEVERITY_EXTREME,
|
164
|
-
:certainty => RCAP::Info::CERTAINTY_OBSERVED,
|
161
|
+
:response_types => [ RCAP::CAP_1_1::Info::RESPONSE_TYPE_MONITOR, RCAP::CAP_1_1::Info::RESPONSE_TYPE_ASSESS ],
|
162
|
+
:urgency => RCAP::CAP_1_1::Info::URGENCY_IMMEDIATE,
|
163
|
+
:severity => RCAP::CAP_1_1::Info::SEVERITY_EXTREME,
|
164
|
+
:certainty => RCAP::CAP_1_1::Info::CERTAINTY_OBSERVED,
|
165
165
|
:audience => 'Audience',
|
166
166
|
:effective => DateTime.now,
|
167
167
|
:onset => DateTime.now + 1,
|
@@ -172,99 +172,167 @@ describe( RCAP::Info ) do
|
|
172
172
|
:instruction => 'Instruction',
|
173
173
|
:web => 'http://website',
|
174
174
|
:contact => 'contact@address',
|
175
|
-
:resources => [ RCAP::Resource.new( :resource_desc => 'Resource Description', :uri => 'http://tempuri.org/resource' )],
|
176
|
-
:event_codes => [ RCAP::EventCode.new( :name => 'name1', :value => 'value1' ),
|
177
|
-
RCAP::EventCode.new( :name => 'name2', :value => 'value2' )],
|
178
|
-
:parameters => [ RCAP::Parameter.new( :name => 'name1', :value => 'value1' ),
|
179
|
-
RCAP::Parameter.new( :name => 'name2', :value => 'value2' )],
|
180
|
-
:areas => [ RCAP::Area.new( :area_desc => 'Area1' ),
|
181
|
-
RCAP::Area.new( :area_desc => 'Area2' )])
|
175
|
+
:resources => [ RCAP::CAP_1_1::Resource.new( :resource_desc => 'Resource Description', :uri => 'http://tempuri.org/resource' )],
|
176
|
+
:event_codes => [ RCAP::CAP_1_1::EventCode.new( :name => 'name1', :value => 'value1' ),
|
177
|
+
RCAP::CAP_1_1::EventCode.new( :name => 'name2', :value => 'value2' )],
|
178
|
+
:parameters => [ RCAP::CAP_1_1::Parameter.new( :name => 'name1', :value => 'value1' ),
|
179
|
+
RCAP::CAP_1_1::Parameter.new( :name => 'name2', :value => 'value2' )],
|
180
|
+
:areas => [ RCAP::CAP_1_1::Area.new( :area_desc => 'Area1' ),
|
181
|
+
RCAP::CAP_1_1::Area.new( :area_desc => 'Area2' )])
|
182
182
|
@info_hash = @info.to_h
|
183
183
|
end
|
184
184
|
|
185
185
|
it( 'should export the language correctly' ) do
|
186
|
-
@info_hash[ RCAP::Info::LANGUAGE_KEY ].should == @info.language
|
186
|
+
@info_hash[ RCAP::CAP_1_1::Info::LANGUAGE_KEY ].should == @info.language
|
187
187
|
end
|
188
188
|
|
189
189
|
it( 'should export the categories' ) do
|
190
|
-
@info_hash[ RCAP::Info::CATEGORIES_KEY ].should == @info.categories
|
190
|
+
@info_hash[ RCAP::CAP_1_1::Info::CATEGORIES_KEY ].should == @info.categories
|
191
191
|
end
|
192
|
-
|
192
|
+
|
193
193
|
it( 'should export the event' ) do
|
194
|
-
@info_hash[ RCAP::Info::EVENT_KEY ].should == @info.event
|
194
|
+
@info_hash[ RCAP::CAP_1_1::Info::EVENT_KEY ].should == @info.event
|
195
195
|
end
|
196
196
|
|
197
197
|
it( 'should export the response types' ) do
|
198
|
-
@info_hash[ RCAP::Info::RESPONSE_TYPES_KEY ].should == @info.response_types
|
198
|
+
@info_hash[ RCAP::CAP_1_1::Info::RESPONSE_TYPES_KEY ].should == @info.response_types
|
199
199
|
end
|
200
200
|
|
201
201
|
it( 'should export the urgency' ) do
|
202
|
-
@info_hash[ RCAP::Info:: URGENCY_KEY ].should == @info.urgency
|
202
|
+
@info_hash[ RCAP::CAP_1_1::Info:: URGENCY_KEY ].should == @info.urgency
|
203
203
|
end
|
204
204
|
|
205
205
|
it( 'should export the severity' ) do
|
206
|
-
@info_hash[ RCAP::Info:: SEVERITY_KEY ].should == @info.severity
|
206
|
+
@info_hash[ RCAP::CAP_1_1::Info:: SEVERITY_KEY ].should == @info.severity
|
207
207
|
end
|
208
208
|
|
209
209
|
it( 'should export the certainty' ) do
|
210
|
-
@info_hash[ RCAP::Info:: CERTAINTY_KEY ].should == @info.certainty
|
210
|
+
@info_hash[ RCAP::CAP_1_1::Info:: CERTAINTY_KEY ].should == @info.certainty
|
211
211
|
end
|
212
212
|
|
213
213
|
it( 'should export the audience' ) do
|
214
|
-
@info_hash[ RCAP::Info:: AUDIENCE_KEY ].should == @info.audience
|
214
|
+
@info_hash[ RCAP::CAP_1_1::Info:: AUDIENCE_KEY ].should == @info.audience
|
215
215
|
end
|
216
216
|
|
217
217
|
it( 'should export the effective date' ) do
|
218
|
-
@info_hash[ RCAP::Info::EFFECTIVE_KEY ].should == @info.effective.to_s_for_cap
|
218
|
+
@info_hash[ RCAP::CAP_1_1::Info::EFFECTIVE_KEY ].should == @info.effective.to_s_for_cap
|
219
219
|
end
|
220
220
|
|
221
221
|
it( 'should export the onset date' ) do
|
222
|
-
@info_hash[ RCAP::Info::ONSET_KEY ].should == @info.onset.to_s_for_cap
|
222
|
+
@info_hash[ RCAP::CAP_1_1::Info::ONSET_KEY ].should == @info.onset.to_s_for_cap
|
223
223
|
end
|
224
224
|
|
225
225
|
it( 'should export the expires date' ) do
|
226
|
-
@info_hash[ RCAP::Info::EXPIRES_KEY ].should == @info.expires.to_s_for_cap
|
226
|
+
@info_hash[ RCAP::CAP_1_1::Info::EXPIRES_KEY ].should == @info.expires.to_s_for_cap
|
227
227
|
end
|
228
228
|
|
229
229
|
it( 'should export the sender name' ) do
|
230
|
-
@info_hash[ RCAP::Info::SENDER_NAME_KEY ].should == @info.sender_name
|
230
|
+
@info_hash[ RCAP::CAP_1_1::Info::SENDER_NAME_KEY ].should == @info.sender_name
|
231
231
|
end
|
232
232
|
|
233
233
|
it( 'should export the headline' ) do
|
234
|
-
@info_hash[ RCAP::Info::HEADLINE_KEY ].should == @info.headline
|
234
|
+
@info_hash[ RCAP::CAP_1_1::Info::HEADLINE_KEY ].should == @info.headline
|
235
235
|
end
|
236
236
|
|
237
237
|
it( 'should export the description' ) do
|
238
|
-
@info_hash[ RCAP::Info::DESCRIPTION_KEY ].should == @info.description
|
238
|
+
@info_hash[ RCAP::CAP_1_1::Info::DESCRIPTION_KEY ].should == @info.description
|
239
239
|
end
|
240
240
|
|
241
241
|
it( 'should export the instruction' ) do
|
242
|
-
@info_hash[ RCAP::Info::INSTRUCTION_KEY ].should == @info.instruction
|
242
|
+
@info_hash[ RCAP::CAP_1_1::Info::INSTRUCTION_KEY ].should == @info.instruction
|
243
243
|
end
|
244
244
|
|
245
245
|
it( 'should export the web address ' ) do
|
246
|
-
@info_hash[ RCAP::Info::WEB_KEY ].should == @info.web
|
246
|
+
@info_hash[ RCAP::CAP_1_1::Info::WEB_KEY ].should == @info.web
|
247
247
|
end
|
248
248
|
|
249
249
|
it( 'should export the contact' ) do
|
250
|
-
@info_hash[ RCAP::Info::CONTACT_KEY ].should == @info.contact
|
250
|
+
@info_hash[ RCAP::CAP_1_1::Info::CONTACT_KEY ].should == @info.contact
|
251
251
|
end
|
252
252
|
|
253
253
|
it( 'should export the event codes' ) do
|
254
|
-
@info_hash[ RCAP::Info::EVENT_CODES_KEY ].should == @info.event_codes.map{ |event_code| event_code.to_h }
|
254
|
+
@info_hash[ RCAP::CAP_1_1::Info::EVENT_CODES_KEY ].should == @info.event_codes.map{ |event_code| event_code.to_h }
|
255
255
|
end
|
256
256
|
|
257
257
|
it( 'should export the parameters ' ) do
|
258
|
-
@info_hash[ RCAP::Info::PARAMETERS_KEY ].should == @info.parameters.map{ |parameter| parameter.to_h }
|
258
|
+
@info_hash[ RCAP::CAP_1_1::Info::PARAMETERS_KEY ].should == @info.parameters.map{ |parameter| parameter.to_h }
|
259
259
|
end
|
260
260
|
|
261
261
|
it( 'should export the resources ' ) do
|
262
|
-
@info_hash[ RCAP::Info::RESOURCES_KEY ].should == @info.resources.map{ |resource| resource.to_h }
|
262
|
+
@info_hash[ RCAP::CAP_1_1::Info::RESOURCES_KEY ].should == @info.resources.map{ |resource| resource.to_h }
|
263
263
|
end
|
264
264
|
|
265
265
|
it( 'should export the areas' ) do
|
266
|
-
@info_hash[ RCAP::Info::AREAS_KEY ].should == @info.areas.map{ |area| area.to_h }
|
266
|
+
@info_hash[ RCAP::CAP_1_1::Info::AREAS_KEY ].should == @info.areas.map{ |area| area.to_h }
|
267
267
|
end
|
268
268
|
end
|
269
269
|
end
|
270
|
+
|
271
|
+
describe( 'instance methods' ) do
|
272
|
+
before( :each ) do
|
273
|
+
@info = RCAP::CAP_1_1::Info.new
|
274
|
+
end
|
275
|
+
|
276
|
+
describe( '#add_event_code' ) do
|
277
|
+
before( :each ) do
|
278
|
+
@event_code = @info.add_event_code( name: 'Event Code', value: '1234' )
|
279
|
+
end
|
280
|
+
|
281
|
+
it( 'should return a 1.1 EventCode' ) do
|
282
|
+
@event_code.class.should == RCAP::CAP_1_1::EventCode
|
283
|
+
@event_code.name.should == 'Event Code'
|
284
|
+
@event_code.value.should == '1234'
|
285
|
+
end
|
286
|
+
|
287
|
+
it( 'should add an EventCode to the event_codes attribute' ) do
|
288
|
+
@info.event_codes.size.should == 1
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe( '#add_parameter' ) do
|
293
|
+
before( :each ) do
|
294
|
+
@parameter = @info.add_parameter( name: 'Parameter', value: '1234' )
|
295
|
+
end
|
296
|
+
|
297
|
+
it( 'should return a 1.1 Parameter' ) do
|
298
|
+
@parameter.class.should == RCAP::CAP_1_1::Parameter
|
299
|
+
@parameter.name.should == 'Parameter'
|
300
|
+
@parameter.value.should == '1234'
|
301
|
+
end
|
302
|
+
|
303
|
+
it( 'should add a Parameter to the parameters attribute' ) do
|
304
|
+
@info.parameters.size.should == 1
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe( '#add_resource' ) do
|
309
|
+
before( :each ) do
|
310
|
+
@resource = @info.add_resource( resource_desc: 'Resource' )
|
311
|
+
end
|
312
|
+
|
313
|
+
it( 'should return a 1.1 Resource' ) do
|
314
|
+
@resource.class.should == RCAP::CAP_1_1::Resource
|
315
|
+
@resource.resource_desc.should == 'Resource'
|
316
|
+
end
|
317
|
+
|
318
|
+
it( 'should add a Resource to the resources attribute' ) do
|
319
|
+
@info.resources.size.should == 1
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
describe( '#add_area' ) do
|
324
|
+
before( :each ) do
|
325
|
+
@area = @info.add_area( area_desc: 'Area' )
|
326
|
+
end
|
327
|
+
|
328
|
+
it( 'should return a 1.1 area' ) do
|
329
|
+
@area.class.should == RCAP::CAP_1_1::Area
|
330
|
+
@area.area_desc.should == 'Area'
|
331
|
+
end
|
332
|
+
|
333
|
+
it( 'should add a Area to the areas attribute' ) do
|
334
|
+
@info.areas.size.should == 1
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
270
338
|
end
|