rcap 1.0.1 → 1.1.0

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