rcap 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/rcap/alert.rb +28 -29
  4. data/lib/rcap/base/alert.rb +192 -192
  5. data/lib/rcap/base/area.rb +84 -86
  6. data/lib/rcap/base/circle.rb +32 -32
  7. data/lib/rcap/base/info.rb +248 -253
  8. data/lib/rcap/base/parameter.rb +23 -24
  9. data/lib/rcap/base/point.rb +23 -23
  10. data/lib/rcap/base/polygon.rb +32 -32
  11. data/lib/rcap/base/resource.rb +57 -57
  12. data/lib/rcap/cap_1_0/alert.rb +79 -83
  13. data/lib/rcap/cap_1_0/area.rb +0 -2
  14. data/lib/rcap/cap_1_0/circle.rb +0 -1
  15. data/lib/rcap/cap_1_0/info.rb +1 -3
  16. data/lib/rcap/cap_1_0/parameter.rb +11 -12
  17. data/lib/rcap/cap_1_0/point.rb +0 -1
  18. data/lib/rcap/cap_1_0/polygon.rb +0 -2
  19. data/lib/rcap/cap_1_0/resource.rb +0 -3
  20. data/lib/rcap/cap_1_1/alert.rb +4 -6
  21. data/lib/rcap/cap_1_1/area.rb +0 -2
  22. data/lib/rcap/cap_1_1/circle.rb +0 -1
  23. data/lib/rcap/cap_1_1/info.rb +120 -129
  24. data/lib/rcap/cap_1_1/parameter.rb +0 -2
  25. data/lib/rcap/cap_1_1/point.rb +0 -1
  26. data/lib/rcap/cap_1_1/polygon.rb +0 -2
  27. data/lib/rcap/cap_1_1/resource.rb +32 -34
  28. data/lib/rcap/cap_1_2/alert.rb +4 -6
  29. data/lib/rcap/cap_1_2/area.rb +0 -2
  30. data/lib/rcap/cap_1_2/circle.rb +0 -1
  31. data/lib/rcap/cap_1_2/info.rb +114 -121
  32. data/lib/rcap/cap_1_2/parameter.rb +0 -2
  33. data/lib/rcap/cap_1_2/point.rb +0 -1
  34. data/lib/rcap/cap_1_2/polygon.rb +1 -3
  35. data/lib/rcap/cap_1_2/resource.rb +32 -34
  36. data/lib/rcap/config.rb +3 -3
  37. data/lib/rcap/custom_validators.rb +72 -76
  38. data/lib/rcap/extensions/array.rb +1 -1
  39. data/lib/rcap/extensions/date.rb +2 -2
  40. data/lib/rcap/extensions/date_time.rb +3 -3
  41. data/lib/rcap/extensions/string.rb +3 -3
  42. data/lib/rcap/extensions/time.rb +2 -3
  43. data/lib/rcap/info.rb +4 -5
  44. data/lib/rcap/utilities.rb +24 -25
  45. data/lib/rcap/validation.rb +19 -20
  46. data/lib/rcap/version.rb +1 -1
  47. data/spec/alert_spec.rb +141 -141
  48. data/spec/cap_1_0/alert_spec.rb +92 -94
  49. data/spec/cap_1_0/area_spec.rb +86 -86
  50. data/spec/cap_1_0/circle_spec.rb +39 -39
  51. data/spec/cap_1_0/event_code_spec.rb +15 -15
  52. data/spec/cap_1_0/geocode_spec.rb +16 -16
  53. data/spec/cap_1_0/info_spec.rb +175 -177
  54. data/spec/cap_1_0/parameter_spec.rb +27 -27
  55. data/spec/cap_1_0/point_spec.rb +18 -18
  56. data/spec/cap_1_0/polygon_spec.rb +38 -38
  57. data/spec/cap_1_0/resource_spec.rb +63 -64
  58. data/spec/cap_1_1/alert_spec.rb +107 -109
  59. data/spec/cap_1_1/area_spec.rb +90 -90
  60. data/spec/cap_1_1/circle_spec.rb +34 -34
  61. data/spec/cap_1_1/event_code_spec.rb +15 -16
  62. data/spec/cap_1_1/geocode_spec.rb +16 -16
  63. data/spec/cap_1_1/info_spec.rb +194 -196
  64. data/spec/cap_1_1/parameter_spec.rb +17 -17
  65. data/spec/cap_1_1/point_spec.rb +18 -18
  66. data/spec/cap_1_1/polygon_spec.rb +36 -36
  67. data/spec/cap_1_1/resource_spec.rb +106 -107
  68. data/spec/cap_1_2/alert_spec.rb +98 -99
  69. data/spec/cap_1_2/area_spec.rb +90 -90
  70. data/spec/cap_1_2/circle_spec.rb +43 -43
  71. data/spec/cap_1_2/event_code_spec.rb +19 -20
  72. data/spec/cap_1_2/geocode_spec.rb +20 -20
  73. data/spec/cap_1_2/info_spec.rb +196 -198
  74. data/spec/cap_1_2/parameter_spec.rb +19 -19
  75. data/spec/cap_1_2/point_spec.rb +21 -21
  76. data/spec/cap_1_2/polygon_spec.rb +47 -47
  77. data/spec/cap_1_2/resource_spec.rb +96 -97
  78. data/spec/extensions_spec.rb +29 -29
  79. data/spec/info_spec.rb +15 -15
  80. data/spec/spec_helper.rb +3 -3
  81. data/spec/validations_spec.rb +73 -73
  82. metadata +2 -2
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Parameter ) do
4
- context( 'when initialised' ) do
5
- context( 'from XML' ) do
6
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Parameter) do
4
+ context('when initialised') do
5
+ context('from XML') do
6
+ before(:each) do
7
7
  @original_parameter = RCAP::CAP_1_0::Parameter.new do |parameter|
8
8
  parameter.name = 'name'
9
9
  parameter.value = 'value'
@@ -11,74 +11,74 @@ describe( RCAP::CAP_1_0::Parameter ) do
11
11
  @alert = RCAP::CAP_1_0::Alert.new
12
12
  @alert.add_info.parameters << @original_parameter
13
13
  @xml_string = @alert.to_xml
14
- @xml_document = REXML::Document.new( @xml_string )
15
- @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
16
- @parameter_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_0::Parameter::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
17
- @parameter = RCAP::CAP_1_0::Parameter.from_xml_element( @parameter_xml_element )
14
+ @xml_document = REXML::Document.new(@xml_string)
15
+ @info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
16
+ @parameter_xml_element = RCAP.xpath_first(@info_xml_element, RCAP::CAP_1_0::Parameter::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
17
+ @parameter = RCAP::CAP_1_0::Parameter.from_xml_element(@parameter_xml_element)
18
18
  end
19
19
 
20
- it( 'should parse into the correct class' ) do
20
+ it('should parse into the correct class') do
21
21
  @parameter.class.should == RCAP::CAP_1_0::Parameter
22
22
  end
23
23
 
24
- it( 'should parse the name correctly' ) do
24
+ it('should parse the name correctly') do
25
25
  @parameter.name.should == @original_parameter.name
26
26
  end
27
27
 
28
- it( 'should parse the value correctly' ) do
28
+ it('should parse the value correctly') do
29
29
  @parameter.value.should == @original_parameter.value
30
30
  end
31
31
  end
32
32
  end
33
33
 
34
- context( 'when exported' ) do
35
- before( :each ) do
34
+ context('when exported') do
35
+ before(:each) do
36
36
  @parameter = RCAP::CAP_1_0::Parameter.new do |parameter|
37
37
  parameter.name = 'name'
38
38
  parameter.value = 'value'
39
39
  end
40
40
  end
41
41
 
42
- context( 'to a hash' ) do
43
- it( 'should export correctly' ) do
42
+ context('to a hash') do
43
+ it('should export correctly') do
44
44
  @parameter.to_h.should == { 'name' => 'value' }
45
45
  end
46
46
  end
47
47
  end
48
48
 
49
- describe( '.parse_parameter' ) do
50
- it( 'should parse valid content correctly' ) do
51
- RCAP::CAP_1_0::Parameter.parse_parameter( "name=value" ).should == { :name => 'name', :value => 'value' }
49
+ describe('.parse_parameter') do
50
+ it('should parse valid content correctly') do
51
+ RCAP::CAP_1_0::Parameter.parse_parameter('name=value').should == { name: 'name', value: 'value' }
52
52
  end
53
53
 
54
- it( 'should parse invalid content correctly' ) do
55
- RCAP::CAP_1_0::Parameter.parse_parameter( 'name' ).should == nil
54
+ it('should parse invalid content correctly') do
55
+ RCAP::CAP_1_0::Parameter.parse_parameter('name').should.nil?
56
56
  end
57
57
  end
58
58
 
59
- describe( '.to_xml_element' ) do
60
- before( :each ) do
59
+ describe('.to_xml_element') do
60
+ before(:each) do
61
61
  @parameter = RCAP::CAP_1_0::Parameter.new do |parameter|
62
62
  parameter.name = 'name'
63
63
  parameter.value = 'value'
64
64
  end
65
65
  end
66
66
 
67
- it( 'should generate an XML element correctly' ) do
67
+ it('should generate an XML element correctly') do
68
68
  @parameter.to_xml_element.text.should == 'name=value'
69
69
  end
70
70
  end
71
71
 
72
- describe( '.from_xml_element' ) do
73
- before( :each ) do
72
+ describe('.from_xml_element') do
73
+ before(:each) do
74
74
  @parameter = RCAP::CAP_1_0::Parameter.new do |parameter|
75
75
  parameter.name = 'name'
76
76
  parameter.value = 'value'
77
77
  end
78
78
  end
79
79
 
80
- it( 'should initialise correctly' ) do
81
- parameter = RCAP::CAP_1_0::Parameter.from_xml_element( @parameter.to_xml_element )
80
+ it('should initialise correctly') do
81
+ parameter = RCAP::CAP_1_0::Parameter.from_xml_element(@parameter.to_xml_element)
82
82
  parameter.name.should == @parameter.name
83
83
  parameter.value.should == @parameter.value
84
84
  end
@@ -1,51 +1,51 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Point ) do
4
- describe( 'is not valid if' ) do
5
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Point) do
4
+ describe('is not valid if') do
5
+ before(:each) do
6
6
  @point = RCAP::CAP_1_0::Point.new do |point|
7
7
  point.lattitude = 0
8
8
  point.longitude = 0
9
9
  end
10
10
 
11
- @point.should( be_valid )
11
+ @point.should(be_valid)
12
12
  end
13
13
 
14
- it( 'does not have a longitude defined' ) do
14
+ it('does not have a longitude defined') do
15
15
  @point.longitude = nil
16
- @point.should_not( be_valid )
16
+ @point.should_not(be_valid)
17
17
  end
18
18
 
19
- it( 'does not have a valid longitude' ) do
19
+ it('does not have a valid longitude') do
20
20
  @point.longitude = RCAP::CAP_1_0::Point::MAX_LONGITUDE + 1
21
- @point.should_not( be_valid )
21
+ @point.should_not(be_valid)
22
22
  @point.longitude = RCAP::CAP_1_0::Point::MIN_LONGITUDE - 1
23
- @point.should_not( be_valid )
23
+ @point.should_not(be_valid)
24
24
  end
25
25
 
26
- it( 'does not have a lattitude defined' ) do
26
+ it('does not have a lattitude defined') do
27
27
  @point.lattitude = nil
28
- @point.should_not( be_valid )
28
+ @point.should_not(be_valid)
29
29
  end
30
30
 
31
- it( 'does not have a valid lattitude' ) do
31
+ it('does not have a valid lattitude') do
32
32
  @point.lattitude = RCAP::CAP_1_0::Point::MAX_LATTITUDE + 1
33
- @point.should_not( be_valid )
33
+ @point.should_not(be_valid)
34
34
  @point.lattitude = RCAP::CAP_1_0::Point::MIN_LATTITUDE - 1
35
- @point.should_not( be_valid )
35
+ @point.should_not(be_valid)
36
36
  end
37
37
  end
38
38
 
39
- context( 'when exported' ) do
40
- before( :each ) do
39
+ context('when exported') do
40
+ before(:each) do
41
41
  @point = RCAP::CAP_1_0::Point.new do |p|
42
42
  p.lattitude = 1
43
43
  p.longitude = 1
44
44
  end
45
45
  end
46
46
 
47
- context( 'to hash' ) do
48
- it( 'should export correctly' ) do
47
+ context('to hash') do
48
+ it('should export correctly') do
49
49
  @point.to_h.should == { RCAP::CAP_1_0::Point::LATTITUDE_KEY => 1, RCAP::CAP_1_0::Point::LONGITUDE_KEY => 1 }
50
50
  end
51
51
  end
@@ -1,33 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Polygon ) do
4
- describe( 'is not valid if it' ) do
5
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Polygon) do
4
+ describe('is not valid if it') do
5
+ before(:each) do
6
6
  @polygon = RCAP::CAP_1_0::Polygon.new do |polygon|
7
- [1,2,1].each do |i|
7
+ [1, 2, 1].each do |i|
8
8
  polygon.add_point do |point|
9
9
  point.lattitude = i
10
10
  point.longitude = i
11
11
  end
12
12
  end
13
13
  end
14
- @polygon.should( be_valid )
14
+ @polygon.should(be_valid)
15
15
  end
16
16
 
17
- it( 'does not have any points' ) do
17
+ it('does not have any points') do
18
18
  @polygon.points.clear
19
- @polygon.should_not( be_valid )
19
+ @polygon.should_not(be_valid)
20
20
  end
21
21
 
22
- it( 'does not have a valid collection of points' ) do
22
+ it('does not have a valid collection of points') do
23
23
  @polygon.points.first.lattitude = nil
24
- @polygon.should_not( be_valid )
24
+ @polygon.should_not(be_valid)
25
25
  end
26
26
  end
27
27
 
28
- context( 'on initialization' ) do
29
- context( 'from XML' ) do
30
- before( :each ) do
28
+ context('on initialization') do
29
+ context('from XML') do
30
+ before(:each) do
31
31
  @original_polygon = RCAP::CAP_1_0::Polygon.new do |polygon|
32
32
  3.times do |i|
33
33
  polygon.add_point do |point|
@@ -36,11 +36,11 @@ describe( RCAP::CAP_1_0::Polygon ) do
36
36
  end
37
37
  end
38
38
  end
39
- @empty_original_polygon = RCAP::CAP_1_0::Polygon.new()
39
+ @empty_original_polygon = RCAP::CAP_1_0::Polygon.new
40
40
  @alert = RCAP::CAP_1_0::Alert.new
41
41
  @alert.add_info do |info|
42
42
  info.add_area do |area|
43
- [ @original_polygon, @empty_original_polygon ].each do |original_polygon|
43
+ [@original_polygon, @empty_original_polygon].each do |original_polygon|
44
44
  area.add_polygon do |polygon|
45
45
  original_polygon.points.each do |original_point|
46
46
  polygon.add_point do |point|
@@ -54,29 +54,29 @@ describe( RCAP::CAP_1_0::Polygon ) do
54
54
  end
55
55
 
56
56
  @xml_string = @alert.to_xml
57
- @xml_document = REXML::Document.new( @xml_string )
58
- @info_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
59
- @area_element = RCAP.xpath_first( @info_element, RCAP::CAP_1_0::Area::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
60
- @polygon_element = RCAP.xpath_first( @area_element, RCAP::CAP_1_0::Polygon::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
61
- @polygon = RCAP::CAP_1_0::Polygon.from_xml_element( @polygon_element )
57
+ @xml_document = REXML::Document.new(@xml_string)
58
+ @info_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
59
+ @area_element = RCAP.xpath_first(@info_element, RCAP::CAP_1_0::Area::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
60
+ @polygon_element = RCAP.xpath_first(@area_element, RCAP::CAP_1_0::Polygon::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
61
+ @polygon = RCAP::CAP_1_0::Polygon.from_xml_element(@polygon_element)
62
62
  end
63
63
 
64
- it( 'should parse all the points' ) do
65
- @polygon.points.zip( @original_polygon.points ).each do |point, original_point|
64
+ it('should parse all the points') do
65
+ @polygon.points.zip(@original_polygon.points).each do |point, original_point|
66
66
  point.lattitude.should == original_point.lattitude
67
67
  point.longitude.should == original_point.longitude
68
68
  end
69
69
  end
70
70
 
71
71
  it 'should allow empty polygon xml elements' do
72
- empty_polygon_element = RCAP.xpath_match( @area_element, RCAP::CAP_1_0::Polygon::XPATH, RCAP::CAP_1_0::Alert::XMLNS )[1]
73
- empty_polygon = RCAP::CAP_1_0::Polygon.from_xml_element( empty_polygon_element )
72
+ empty_polygon_element = RCAP.xpath_match(@area_element, RCAP::CAP_1_0::Polygon::XPATH, RCAP::CAP_1_0::Alert::XMLNS)[1]
73
+ empty_polygon = RCAP::CAP_1_0::Polygon.from_xml_element(empty_polygon_element)
74
74
  empty_polygon.should == @empty_original_polygon
75
75
  end
76
76
  end
77
77
 
78
- context( 'from a hash' ) do
79
- before( :each ) do
78
+ context('from a hash') do
79
+ before(:each) do
80
80
  @polygon = RCAP::CAP_1_0::Polygon.new do |polygon|
81
81
  3.times do |i|
82
82
  polygon.add_point do |point|
@@ -87,15 +87,15 @@ describe( RCAP::CAP_1_0::Polygon ) do
87
87
  end
88
88
  end
89
89
 
90
- it( 'should load all the points' ) do
91
- @new_polygon = RCAP::CAP_1_0::Polygon.from_h( @polygon.to_h )
90
+ it('should load all the points') do
91
+ @new_polygon = RCAP::CAP_1_0::Polygon.from_h(@polygon.to_h)
92
92
  @new_polygon.points.should == @polygon.points
93
93
  end
94
94
  end
95
95
  end
96
96
 
97
- context( 'when exported' ) do
98
- before( :each ) do
97
+ context('when exported') do
98
+ before(:each) do
99
99
  @polygon = RCAP::CAP_1_0::Polygon.new do |polygon|
100
100
  3.times do |i|
101
101
  polygon.add_point do |point|
@@ -106,33 +106,33 @@ describe( RCAP::CAP_1_0::Polygon ) do
106
106
  end
107
107
  end
108
108
 
109
- context( 'to a hash' ) do
110
- it( 'should export correctly' ) do
111
- @polygon.to_h.should == { RCAP::CAP_1_0::Polygon::POINTS_KEY => @polygon.points.map{ |point| point.to_a }}
109
+ context('to a hash') do
110
+ it('should export correctly') do
111
+ @polygon.to_h.should == { RCAP::CAP_1_0::Polygon::POINTS_KEY => @polygon.points.map { |point| point.to_a } }
112
112
  end
113
113
  end
114
114
  end
115
115
 
116
- describe( 'instance methods' ) do
117
- before( :each ) do
116
+ describe('instance methods') do
117
+ before(:each) do
118
118
  @polygon = RCAP::CAP_1_0::Polygon.new
119
119
  end
120
120
 
121
- describe( '#add_point' ) do
122
- before( :each ) do
121
+ describe('#add_point') do
122
+ before(:each) do
123
123
  @point = @polygon.add_point do |polygon|
124
124
  polygon.lattitude = 1
125
125
  polygon.longitude = 1
126
126
  end
127
127
  end
128
128
 
129
- it( 'should return a 1.0 Point' ) do
129
+ it('should return a 1.0 Point') do
130
130
  @point.class.should == RCAP::CAP_1_0::Point
131
131
  @point.lattitude.should == 1
132
132
  @point.longitude.should == 1
133
133
  end
134
134
 
135
- it( 'should add a Point to the points attribute' ) do
135
+ it('should add a Point to the points attribute') do
136
136
  @polygon.points.size.should == 1
137
137
  end
138
138
  end
@@ -1,152 +1,151 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Resource ) do
4
- context( 'on initialisation' ) do
5
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Resource) do
4
+ context('on initialisation') do
5
+ before(:each) do
6
6
  @resource = RCAP::CAP_1_0::Resource.new
7
7
  end
8
8
 
9
- it( 'should have no mime_type' ){ @resource.mime_type.should( be_nil )}
10
- it( 'should have no size' ){ @resource.size.should( be_nil )}
11
- it( 'should have no uri' ){ @resource.uri.should( be_nil )}
12
- it( 'should have no digest' ){ @resource.digest.should( be_nil )}
13
- it( 'should have no resource_desc' ){ @resource.resource_desc.should( be_nil )}
9
+ it('should have no mime_type') { @resource.mime_type.should(be_nil) }
10
+ it('should have no size') { @resource.size.should(be_nil) }
11
+ it('should have no uri') { @resource.uri.should(be_nil) }
12
+ it('should have no digest') { @resource.digest.should(be_nil) }
13
+ it('should have no resource_desc') { @resource.resource_desc.should(be_nil) }
14
14
 
15
- context( 'from XML' ) do
16
- before( :each ) do
15
+ context('from XML') do
16
+ before(:each) do
17
17
  @original_resource = RCAP::CAP_1_0::Resource.new do |resource|
18
- resource.resource_desc = "Image of incident"
19
- resource.uri = "http://capetown.gov.za/cap/resources/image.png"
18
+ resource.resource_desc = 'Image of incident'
19
+ resource.uri = 'http://capetown.gov.za/cap/resources/image.png'
20
20
  resource.mime_type = 'image/png'
21
- resource.size = 20480
22
- resource.digest = "2048"
21
+ resource.size = 20_480
22
+ resource.digest = '2048'
23
23
  end
24
24
 
25
25
  @alert = RCAP::CAP_1_0::Alert.new
26
26
  @alert.add_info.resources << @original_resource
27
27
  @xml_string = @alert.to_xml
28
- @xml_document = REXML::Document.new( @xml_string )
29
- @info_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
30
- @resource_element = RCAP.xpath_first( @info_element, RCAP::CAP_1_0::Resource::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
31
- @resource_element.should_not( be_nil )
32
- @resource = RCAP::CAP_1_0::Resource.from_xml_element( @resource_element )
28
+ @xml_document = REXML::Document.new(@xml_string)
29
+ @info_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
30
+ @resource_element = RCAP.xpath_first(@info_element, RCAP::CAP_1_0::Resource::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
31
+ @resource_element.should_not(be_nil)
32
+ @resource = RCAP::CAP_1_0::Resource.from_xml_element(@resource_element)
33
33
  end
34
34
 
35
- it( 'should parse resource_desc correctly' ) do
35
+ it('should parse resource_desc correctly') do
36
36
  @resource.resource_desc.should == @original_resource.resource_desc
37
37
  end
38
38
 
39
- it( 'should parse uri correctly' ) do
39
+ it('should parse uri correctly') do
40
40
  @resource.uri.should == @original_resource.uri
41
41
  end
42
42
 
43
- it( 'should parse mime_type correctly' ) do
43
+ it('should parse mime_type correctly') do
44
44
  @resource.mime_type.should == @original_resource.mime_type
45
45
  end
46
46
 
47
- it( 'should parse size correctly' ) do
47
+ it('should parse size correctly') do
48
48
  @resource.size.should == @original_resource.size
49
49
  end
50
50
 
51
- it( 'should parse digest correctly' ) do
51
+ it('should parse digest correctly') do
52
52
  @resource.digest.should == @original_resource.digest
53
53
  end
54
54
  end
55
55
 
56
-
57
- context( 'from a hash' ) do
58
- before( :each ) do
56
+ context('from a hash') do
57
+ before(:each) do
59
58
  @original_resource = RCAP::CAP_1_0::Resource.new do |resource|
60
- resource.resource_desc = "Image of incident"
61
- resource.uri = "http://capetown.gov.za/cap/resources/image.png"
59
+ resource.resource_desc = 'Image of incident'
60
+ resource.uri = 'http://capetown.gov.za/cap/resources/image.png'
62
61
  resource.mime_type = 'image/png'
63
- resource.size = 20480
64
- resource.digest = "2048"
62
+ resource.size = 20_480
63
+ resource.digest = '2048'
65
64
  end
66
65
 
67
- @resource = RCAP::CAP_1_0::Resource.from_h( @original_resource.to_h )
66
+ @resource = RCAP::CAP_1_0::Resource.from_h(@original_resource.to_h)
68
67
  end
69
68
 
70
- it( 'should parse resource_desc correctly' ) do
69
+ it('should parse resource_desc correctly') do
71
70
  @resource.resource_desc.should == @original_resource.resource_desc
72
71
  end
73
72
 
74
- it( 'should parse uri correctly' ) do
73
+ it('should parse uri correctly') do
75
74
  @resource.uri.should == @original_resource.uri
76
75
  end
77
76
 
78
- it( 'should parse mime_type correctly' ) do
77
+ it('should parse mime_type correctly') do
79
78
  @resource.mime_type.should == @original_resource.mime_type
80
79
  end
81
80
 
82
- it( 'should parse size correctly' ) do
81
+ it('should parse size correctly') do
83
82
  @resource.size.should == @original_resource.size
84
83
  end
85
84
 
86
- it( 'should parse digest correctly' ) do
85
+ it('should parse digest correctly') do
87
86
  @resource.digest.should == @original_resource.digest
88
87
  end
89
88
  end
90
89
 
91
90
  end
92
91
 
93
- context( 'when exported' ) do
94
- before( :each ) do
92
+ context('when exported') do
93
+ before(:each) do
95
94
  @resource = RCAP::CAP_1_0::Resource.new do |resource|
96
- resource.resource_desc = "Image of incident"
97
- resource.uri = "http://capetown.gov.za/cap/resources/image.png"
95
+ resource.resource_desc = 'Image of incident'
96
+ resource.uri = 'http://capetown.gov.za/cap/resources/image.png'
98
97
  resource.mime_type = 'image/png'
99
- resource.size = 20480
100
- resource.digest = "2048"
98
+ resource.size = 20_480
99
+ resource.digest = '2048'
101
100
  end
102
101
  end
103
102
 
104
- context( 'to a hash' ) do
105
- before( :each ) do
103
+ context('to a hash') do
104
+ before(:each) do
106
105
  @resource_hash = @resource.to_h
107
106
  end
108
107
 
109
- it( 'should set the resource description' ) do
110
- @resource_hash[ RCAP::CAP_1_0::Resource::RESOURCE_DESC_KEY ].should == @resource.resource_desc
108
+ it('should set the resource description') do
109
+ @resource_hash[ RCAP::CAP_1_0::Resource::RESOURCE_DESC_KEY].should == @resource.resource_desc
111
110
  end
112
111
 
113
- it( 'should set the mime type' ) do
114
- @resource_hash[ RCAP::CAP_1_0::Resource::MIME_TYPE_KEY ].should == @resource.mime_type
112
+ it('should set the mime type') do
113
+ @resource_hash[ RCAP::CAP_1_0::Resource::MIME_TYPE_KEY].should == @resource.mime_type
115
114
  end
116
115
 
117
- it( 'should set the size' ) do
118
- @resource_hash[ RCAP::CAP_1_0::Resource::SIZE_KEY ].should == @resource.size
116
+ it('should set the size') do
117
+ @resource_hash[ RCAP::CAP_1_0::Resource::SIZE_KEY].should == @resource.size
119
118
  end
120
119
 
121
- it( 'should set the URI' ) do
122
- @resource_hash[ RCAP::CAP_1_0::Resource::URI_KEY ].should == @resource.uri
120
+ it('should set the URI') do
121
+ @resource_hash[ RCAP::CAP_1_0::Resource::URI_KEY].should == @resource.uri
123
122
  end
124
123
 
125
- it( 'should set the digest' ) do
126
- @resource_hash[ RCAP::CAP_1_0::Resource::DIGEST_KEY ].should == @resource.digest
124
+ it('should set the digest') do
125
+ @resource_hash[ RCAP::CAP_1_0::Resource::DIGEST_KEY].should == @resource.digest
127
126
  end
128
127
  end
129
128
 
130
- context( 'to xml' ) do
131
- it( 'should be successful' ) do
132
- lambda{ @resource_xml = @resource.to_xml }.should_not( raise_exception )
129
+ context('to xml') do
130
+ it('should be successful') do
131
+ lambda { @resource_xml = @resource.to_xml }.should_not(raise_exception)
133
132
  end
134
133
  end
135
134
  end
136
135
 
137
- context( 'which is valid' ) do
138
- before( :each ) do
136
+ context('which is valid') do
137
+ before(:each) do
139
138
  @resource = RCAP::CAP_1_0::Resource.new do |resource|
140
139
  resource.resource_desc = 'Resource Description'
141
140
  end
142
141
 
143
- @resource.should( be_valid )
142
+ @resource.should(be_valid)
144
143
  end
145
144
 
146
- describe( 'should not be valid if it' ) do
147
- it( 'does not have a resource description (resource_desc)' ) do
145
+ describe('should not be valid if it') do
146
+ it('does not have a resource description (resource_desc)') do
148
147
  @resource.resource_desc = nil
149
- @resource.should_not( be_valid )
148
+ @resource.should_not(be_valid)
150
149
  end
151
150
  end
152
151
  end