defra_ruby_area 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -7
- data/lib/defra_ruby/area/area.rb +9 -28
- data/lib/defra_ruby/area/response.rb +3 -3
- data/lib/defra_ruby/area/services/base_area_service.rb +13 -3
- data/lib/defra_ruby/area/version.rb +1 -1
- data/spec/cassettes/public_face_area_invalid_blank.yml +5 -5
- data/spec/cassettes/public_face_area_invalid_coords.yml +5 -5
- data/spec/cassettes/public_face_area_valid.yml +5 -5
- data/spec/cassettes/public_face_area_valid_multiple.yml +72 -0
- data/spec/cassettes/water_management_area_invalid_blank.yml +5 -5
- data/spec/cassettes/water_management_area_invalid_coords.yml +5 -5
- data/spec/cassettes/water_management_area_valid.yml +5 -5
- data/spec/cassettes/water_management_area_valid_multiple.yml +76 -0
- data/spec/defra_ruby/area/area_spec.rb +18 -89
- data/spec/defra_ruby/area/response_spec.rb +8 -6
- data/spec/defra_ruby/area/services/public_face_area_service_spec.rb +18 -3
- data/spec/defra_ruby/area/services/water_management_area_service_spec.rb +18 -3
- data/spec/examples.txt +25 -30
- data/spec/support/shared_examples/handle_request_errors.rb +2 -2
- metadata +8 -6
- data/spec/fixtures/no_match.xml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bcadf14ad034b135923304cc09831767bad6e06
|
4
|
+
data.tar.gz: 98a662e1d55ea09410e266ba61fc00a45bf9dd14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faae971a1911a07d0b53d60ac6b83b5e5c6fd34a5283b787f9c4bc4537ff659a0668d117b7ba5cbf0975c7241666d6a4d848982d667c6893a8ebbfcb9c16d59b
|
7
|
+
data.tar.gz: 9198b827e537d4212e10ff9aafe61327fdaaaa867187140241e8a45da693521ea5e09ebeec4a10320a855173d16f7fa492ca217ff8125101450550fbf2136e55
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/defra_ruby_area.svg)](https://badge.fury.io/rb/defra_ruby_area)
|
8
8
|
[![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
|
9
9
|
|
10
|
-
This ruby gem provides a means of looking up
|
10
|
+
This ruby gem provides a means of looking up Environment Agency Administrative boundary areas from a GIS Web Feature Service (WFS). Provided with a valid [easting and northing](https://en.wikipedia.org/wiki/Easting_and_northing) it will query the WFS and return various properties for each matching area found.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -33,20 +33,20 @@ Each WFS is called through a service that responds with a `DefraRuby::Area::Resp
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
response.successful?
|
36
|
-
response.
|
36
|
+
response.areas
|
37
37
|
response.error
|
38
38
|
```
|
39
39
|
|
40
|
-
If the call is successful
|
40
|
+
If the call is successful then
|
41
41
|
|
42
42
|
- `successful?()` will be `true`
|
43
|
-
- `
|
43
|
+
- `areas` will contain an array of `DefraRuby::Area::Area`. Each contains the area ID, area name, code, short name and long name of the matching administrative boundary
|
44
44
|
- `error` will be `nil`
|
45
45
|
|
46
46
|
If the call is unsuccessful (the query errored or no match was found) then
|
47
47
|
|
48
48
|
- `successful?()` will be `false`
|
49
|
-
- `
|
49
|
+
- `areas` will be `[]` (an empty array)
|
50
50
|
- `error` will contain the error
|
51
51
|
|
52
52
|
If it's a runtime error, or an error when calling the WFS `error` will contain whatever error was raised.
|
@@ -62,7 +62,7 @@ easting = 408_602.61
|
|
62
62
|
northing = 257_535.31
|
63
63
|
response = DefraRuby::Area::PublicFaceAreaService.run(easting, northing)
|
64
64
|
|
65
|
-
puts response.
|
65
|
+
puts response.areas.first.long_name if response.successful? # West Midlands
|
66
66
|
```
|
67
67
|
|
68
68
|
### Water Management Areas
|
@@ -74,9 +74,18 @@ easting = 408_602.61
|
|
74
74
|
northing = 257_535.31
|
75
75
|
response = DefraRuby::Area::WaterManagementAreaService.run(easting, northing)
|
76
76
|
|
77
|
-
puts response.
|
77
|
+
puts response.areas.first.long_name if response.successful? # Staffordshire Warwickshire and West Midlands
|
78
78
|
```
|
79
79
|
|
80
|
+
### Multiple results
|
81
|
+
|
82
|
+
In most cases we expect `response.areas` to contain a single result. It is possible though for a given easting and northing to return multiple administrative boundary areas. Where we see this is when a coordinate is on the boundary of 2 areas. This is why **defra-ruby-area** is setup to return multiple results.
|
83
|
+
|
84
|
+
Examples:
|
85
|
+
|
86
|
+
- **Public face areas** easting = `398056.684` and northing = `414748` (*Yorkshire* and *Greater Manchester Merseyside and Cheshire*)
|
87
|
+
- **Water management areas** easting = `456330` and northing = `267000` (*Lincolnshire and Northamptonshire* and *Staffordshire Warwickshire and West Midlands*)
|
88
|
+
|
80
89
|
## Web Feature Services
|
81
90
|
|
82
91
|
A [Web Feature Service (WFS)](https://en.m.wikipedia.org/wiki/Web_Feature_Service) is simply a web service that implements the Open Geospatial Consortium Web Feature Service (WFS) Interface Standard.
|
data/lib/defra_ruby/area/area.rb
CHANGED
@@ -7,44 +7,25 @@ module DefraRuby
|
|
7
7
|
class Area
|
8
8
|
attr_reader :area_id, :area_name, :code, :long_name, :short_name
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@
|
12
|
-
@xml = wfs_xml_response
|
10
|
+
def initialize(wfs_xml_element)
|
11
|
+
@xml = wfs_xml_element
|
13
12
|
|
14
|
-
|
13
|
+
validate_xml
|
15
14
|
parse_xml
|
16
15
|
end
|
17
16
|
|
18
|
-
def matched?
|
19
|
-
"#{@area_name}#{@code}#{@long_name}#{@short_name}" != ""
|
20
|
-
end
|
21
|
-
|
22
17
|
private
|
23
18
|
|
24
|
-
def validate
|
25
|
-
validate_type_name
|
26
|
-
validate_xml
|
27
|
-
end
|
28
|
-
|
29
|
-
def validate_type_name
|
30
|
-
raise(ArgumentError, "type_name is invalid") unless @type_name && @type_name != ""
|
31
|
-
end
|
32
|
-
|
33
19
|
def validate_xml
|
34
|
-
raise(ArgumentError, "
|
20
|
+
raise(ArgumentError, "wfs_xml_element is invalid") unless @xml&.is_a?(Nokogiri::XML::Element)
|
35
21
|
end
|
36
22
|
|
37
23
|
def parse_xml
|
38
|
-
@area_id = @xml.xpath(
|
39
|
-
@area_name = @xml.xpath(
|
40
|
-
@code = @xml.xpath(
|
41
|
-
@long_name = @xml.xpath(
|
42
|
-
@short_name = @xml.xpath(
|
43
|
-
end
|
44
|
-
|
45
|
-
# XML path to the value we wish to extract in the WFS query response.
|
46
|
-
def response_xml_path(property)
|
47
|
-
"//wfs:FeatureCollection/gml:featureMember/#{@type_name}/ms:#{property}"
|
24
|
+
@area_id = @xml.xpath("ms:area_id").text.to_i
|
25
|
+
@area_name = @xml.xpath("ms:area_name").text
|
26
|
+
@code = @xml.xpath("ms:code").text
|
27
|
+
@long_name = @xml.xpath("ms:long_name").text
|
28
|
+
@short_name = @xml.xpath("ms:short_name").text
|
48
29
|
end
|
49
30
|
|
50
31
|
end
|
@@ -4,11 +4,11 @@ module DefraRuby
|
|
4
4
|
module Area
|
5
5
|
class Response
|
6
6
|
attr_reader :error
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :areas
|
8
8
|
|
9
9
|
def initialize(response_exe)
|
10
10
|
@success = true
|
11
|
-
@
|
11
|
+
@areas = []
|
12
12
|
@error = nil
|
13
13
|
|
14
14
|
capture_response(response_exe)
|
@@ -23,7 +23,7 @@ module DefraRuby
|
|
23
23
|
attr_reader :success
|
24
24
|
|
25
25
|
def capture_response(response_exe)
|
26
|
-
@
|
26
|
+
@areas = response_exe.call[:areas]
|
27
27
|
rescue StandardError => e
|
28
28
|
@error = e
|
29
29
|
@success = false
|
@@ -30,13 +30,23 @@ module DefraRuby
|
|
30
30
|
url: url,
|
31
31
|
timeout: DefraRuby::Area.configuration.timeout
|
32
32
|
)
|
33
|
-
|
34
|
-
raise NoMatchError unless area.matched?
|
33
|
+
areas = extract_areas(Nokogiri::XML(response))
|
35
34
|
|
36
|
-
|
35
|
+
raise NoMatchError unless areas.any?
|
36
|
+
|
37
|
+
{ areas: areas }
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
def extract_areas(xml_response)
|
42
|
+
areas = []
|
43
|
+
xml_response.xpath("//wfs:FeatureCollection/gml:featureMember").each do |parent|
|
44
|
+
areas << Area.new(parent.first_element_child)
|
45
|
+
end
|
46
|
+
|
47
|
+
areas
|
48
|
+
end
|
49
|
+
|
40
50
|
def url
|
41
51
|
"#{domain}/spatialdata/#{dataset}/wfs?#{url_params}"
|
42
52
|
end
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:25 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -45,5 +45,5 @@ http_interactions:
|
|
45
45
|
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
46
46
|
</ogc:ServiceExceptionReport>
|
47
47
|
http_version:
|
48
|
-
recorded_at:
|
48
|
+
recorded_at: Wed, 28 Aug 2019 22:48:25 GMT
|
49
49
|
recorded_with: VCR 4.0.0
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:25 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -48,5 +48,5 @@ http_interactions:
|
|
48
48
|
</gml:boundedBy>
|
49
49
|
</wfs:FeatureCollection>
|
50
50
|
http_version:
|
51
|
-
recorded_at:
|
51
|
+
recorded_at: Wed, 28 Aug 2019 22:48:25 GMT
|
52
52
|
recorded_with: VCR 4.0.0
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:25 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -58,5 +58,5 @@ http_interactions:
|
|
58
58
|
</gml:featureMember>
|
59
59
|
</wfs:FeatureCollection>
|
60
60
|
http_version:
|
61
|
-
recorded_at:
|
61
|
+
recorded_at: Wed, 28 Aug 2019 22:48:25 GMT
|
62
62
|
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E398056.684,414748%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=area_id,area_name,code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
User-Agent:
|
13
|
+
- rest-client/2.1.0 (darwin18.5.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Thu, 29 Aug 2019 09:52:19 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '2348'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
44
|
+
<gml:boundedBy>
|
45
|
+
<gml:Box srsName="EPSG:27700">
|
46
|
+
<gml:coordinates>0,0,0,0</gml:coordinates>
|
47
|
+
</gml:Box>
|
48
|
+
</gml:boundedBy>
|
49
|
+
<gml:featureMember>
|
50
|
+
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.19">
|
51
|
+
<ms:OBJECTID>19</ms:OBJECTID>
|
52
|
+
<ms:long_name>Yorkshire</ms:long_name>
|
53
|
+
<ms:short_name>Yorkshire</ms:short_name>
|
54
|
+
<ms:code>YOR</ms:code>
|
55
|
+
<ms:st_area_shape_>14482874597.24499</ms:st_area_shape_>
|
56
|
+
<ms:st_perimeter_shape_>820401.3233851442</ms:st_perimeter_shape_>
|
57
|
+
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
58
|
+
</gml:featureMember>
|
59
|
+
<gml:featureMember>
|
60
|
+
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.20">
|
61
|
+
<ms:OBJECTID>20</ms:OBJECTID>
|
62
|
+
<ms:long_name>Greater Manchester Merseyside and Cheshire</ms:long_name>
|
63
|
+
<ms:short_name>Gtr Mancs Mersey and Ches</ms:short_name>
|
64
|
+
<ms:code>GMC</ms:code>
|
65
|
+
<ms:st_area_shape_>4473822349.59001</ms:st_area_shape_>
|
66
|
+
<ms:st_perimeter_shape_>543689.9446941023</ms:st_perimeter_shape_>
|
67
|
+
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
68
|
+
</gml:featureMember>
|
69
|
+
</wfs:FeatureCollection>
|
70
|
+
http_version:
|
71
|
+
recorded_at: Thu, 29 Aug 2019 09:52:19 GMT
|
72
|
+
recorded_with: VCR 4.0.0
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:26 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -45,5 +45,5 @@ http_interactions:
|
|
45
45
|
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
46
46
|
</ogc:ServiceExceptionReport>
|
47
47
|
http_version:
|
48
|
-
recorded_at:
|
48
|
+
recorded_at: Wed, 28 Aug 2019 22:48:26 GMT
|
49
49
|
recorded_with: VCR 4.0.0
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:27 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -48,5 +48,5 @@ http_interactions:
|
|
48
48
|
</gml:boundedBy>
|
49
49
|
</wfs:FeatureCollection>
|
50
50
|
http_version:
|
51
|
-
recorded_at:
|
51
|
+
recorded_at: Wed, 28 Aug 2019 22:48:27 GMT
|
52
52
|
recorded_with: VCR 4.0.0
|
@@ -9,10 +9,10 @@ http_interactions:
|
|
9
9
|
headers:
|
10
10
|
Accept:
|
11
11
|
- "*/*"
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip, deflate
|
14
12
|
User-Agent:
|
15
|
-
- rest-client/2.0
|
13
|
+
- rest-client/2.1.0 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
Host:
|
17
17
|
- environment.data.gov.uk
|
18
18
|
response:
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Server:
|
24
24
|
- nginx
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Wed, 28 Aug 2019 22:48:26 GMT
|
27
27
|
Content-Type:
|
28
28
|
- application/xml
|
29
29
|
Content-Length:
|
@@ -60,5 +60,5 @@ http_interactions:
|
|
60
60
|
</gml:featureMember>
|
61
61
|
</wfs:FeatureCollection>
|
62
62
|
http_version:
|
63
|
-
recorded_at:
|
63
|
+
recorded_at: Wed, 28 Aug 2019 22:48:26 GMT
|
64
64
|
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,76 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E456330,267000%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=area_id,area_name,code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
|
16
|
+
Host:
|
17
|
+
- environment.data.gov.uk
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- nginx
|
25
|
+
Date:
|
26
|
+
- Wed, 28 Aug 2019 16:25:23 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/xml
|
29
|
+
Content-Length:
|
30
|
+
- '2234'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- private
|
35
|
+
X-Aspnet-Version:
|
36
|
+
- 4.0.30319
|
37
|
+
X-Powered-By:
|
38
|
+
- ASP.NET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
43
|
+
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
44
|
+
<gml:boundedBy>
|
45
|
+
<gml:Box srsName="EPSG:27700">
|
46
|
+
<gml:coordinates>0,0,0,0</gml:coordinates>
|
47
|
+
</gml:Box>
|
48
|
+
</gml:boundedBy>
|
49
|
+
<gml:featureMember>
|
50
|
+
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.11">
|
51
|
+
<ms:OBJECTID>11</ms:OBJECTID>
|
52
|
+
<ms:long_name>Lincolnshire and Northamptonshire</ms:long_name>
|
53
|
+
<ms:short_name>Lincs and Northants</ms:short_name>
|
54
|
+
<ms:code>LCNNTH</ms:code>
|
55
|
+
<ms:area_id>3</ms:area_id>
|
56
|
+
<ms:area_name>Northern</ms:area_name>
|
57
|
+
<ms:st_area_shape_>9270202427.530003</ms:st_area_shape_>
|
58
|
+
<ms:st_perimeter_shape_>1148848.464792307</ms:st_perimeter_shape_>
|
59
|
+
</ms:Administrative_Boundaries_Water_Management_Areas>
|
60
|
+
</gml:featureMember>
|
61
|
+
<gml:featureMember>
|
62
|
+
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
|
63
|
+
<ms:OBJECTID>15</ms:OBJECTID>
|
64
|
+
<ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
|
65
|
+
<ms:short_name>Staffs Warks and West Mids</ms:short_name>
|
66
|
+
<ms:code>STWKWM</ms:code>
|
67
|
+
<ms:area_id>29</ms:area_id>
|
68
|
+
<ms:area_name>Central</ms:area_name>
|
69
|
+
<ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
|
70
|
+
<ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
|
71
|
+
</ms:Administrative_Boundaries_Water_Management_Areas>
|
72
|
+
</gml:featureMember>
|
73
|
+
</wfs:FeatureCollection>
|
74
|
+
http_version:
|
75
|
+
recorded_at: Wed, 28 Aug 2019 16:25:23 GMT
|
76
|
+
recorded_with: VCR 4.0.0
|
@@ -6,109 +6,38 @@ require "nokogiri"
|
|
6
6
|
module DefraRuby
|
7
7
|
module Area
|
8
8
|
RSpec.describe Area do
|
9
|
-
let(:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
let(:valid_xml) { File.open("spec/fixtures/valid.xml") { |f| Nokogiri::XML(f) } }
|
9
|
+
let(:valid_xml) do
|
10
|
+
document = Nokogiri::XML(File.read("spec/fixtures/valid.xml"))
|
11
|
+
document.xpath("//wfs:FeatureCollection/gml:featureMember").first.first_element_child
|
12
|
+
end
|
14
13
|
let(:invalid_xml) { "foo" }
|
15
|
-
let(:no_match_xml) { File.open("spec/fixtures/no_match.xml") { |f| Nokogiri::XML(f) } }
|
16
|
-
|
17
|
-
let(:no_match_area) { described_class.new(valid_type_name, no_match_xml) }
|
18
|
-
let(:matched_area) { described_class.new(valid_type_name, valid_xml) }
|
19
14
|
|
20
15
|
describe "#initialize" do
|
21
|
-
context "when
|
22
|
-
|
23
|
-
|
24
|
-
it "raises an ArgumentError" do
|
25
|
-
expect { described_class.new(nil, nil) }.to raise_error(ArgumentError, "type_name is invalid")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "and `type_name` is missing" do
|
30
|
-
it "raises an ArgumentError" do
|
31
|
-
expect { described_class.new(nil, valid_xml) }.to raise_error(ArgumentError, "type_name is invalid")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "and `wfs_xml_response` is missing" do
|
36
|
-
it "raises an ArgumentError" do
|
37
|
-
expect { described_class.new(valid_type_name, nil) }.to raise_error(ArgumentError, "wfs_xml_response is invalid")
|
38
|
-
end
|
16
|
+
context "when `wfs_xml_element` is missing" do
|
17
|
+
it "raises an ArgumentError" do
|
18
|
+
expect { described_class.new(nil) }.to raise_error(ArgumentError, "wfs_xml_element is invalid")
|
39
19
|
end
|
40
20
|
end
|
41
21
|
|
42
|
-
context "when
|
43
|
-
|
44
|
-
|
45
|
-
it "raises an error" do
|
46
|
-
expect { described_class.new(valid_type_name, invalid_xml) }.to raise_error(ArgumentError, "wfs_xml_response is invalid")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "and passed an invalid type name" do
|
51
|
-
it "raises an error" do
|
52
|
-
expect { described_class.new(invalid_type_name, valid_xml) }.to raise_error(Nokogiri::XML::XPath::SyntaxError)
|
53
|
-
end
|
22
|
+
context "when `wfs_xml_element` is invalid" do
|
23
|
+
it "raises an error" do
|
24
|
+
expect { described_class.new(invalid_xml) }.to raise_error(ArgumentError, "wfs_xml_element is invalid")
|
54
25
|
end
|
55
26
|
end
|
56
27
|
|
57
|
-
context "when
|
58
|
-
|
59
|
-
|
60
|
-
it "populates all an Area's attributes" do
|
61
|
-
subject = described_class.new(valid_type_name, valid_xml)
|
62
|
-
|
63
|
-
expect(subject.area_id).to eq(29)
|
64
|
-
expect(subject.area_name).to eq("Central")
|
65
|
-
expect(subject.code).to eq("STWKWM")
|
66
|
-
expect(subject.short_name).to eq("Staffs Warks and West Mids")
|
67
|
-
expect(subject.long_name).to eq("Staffordshire Warwickshire and West Midlands")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "and type name does not match the xml" do
|
72
|
-
it "does not populate an Area's attributes" do
|
73
|
-
subject = described_class.new(no_match_type_name, valid_xml)
|
28
|
+
context "when `wfs_xml_element` is valid" do
|
29
|
+
it "populates all an Area's attributes" do
|
30
|
+
subject = described_class.new(valid_xml)
|
74
31
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "and the WFS responded with no match" do
|
84
|
-
it "does not populate an Area's attributes" do
|
85
|
-
subject = described_class.new(valid_type_name, no_match_xml)
|
86
|
-
|
87
|
-
expect(subject.area_id).to eq(0)
|
88
|
-
expect(subject.area_name).to eq("")
|
89
|
-
expect(subject.code).to eq("")
|
90
|
-
expect(subject.short_name).to eq("")
|
91
|
-
expect(subject.long_name).to eq("")
|
92
|
-
end
|
32
|
+
expect(subject.area_id).to eq(29)
|
33
|
+
expect(subject.area_name).to eq("Central")
|
34
|
+
expect(subject.code).to eq("STWKWM")
|
35
|
+
expect(subject.short_name).to eq("Staffs Warks and West Mids")
|
36
|
+
expect(subject.long_name).to eq("Staffordshire Warwickshire and West Midlands")
|
93
37
|
end
|
94
38
|
end
|
95
39
|
end
|
96
40
|
|
97
|
-
describe "#matched?" do
|
98
|
-
context "when no match was found" do
|
99
|
-
|
100
|
-
it "returns false" do
|
101
|
-
expect(no_match_area.matched?).to eq(false)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context "when a match was found" do
|
106
|
-
|
107
|
-
it "returns true" do
|
108
|
-
expect(matched_area.matched?).to eq(true)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
41
|
end
|
113
42
|
end
|
114
43
|
end
|
@@ -7,10 +7,12 @@ module DefraRuby
|
|
7
7
|
RSpec.describe Response do
|
8
8
|
subject(:response) { described_class.new(response_exe) }
|
9
9
|
|
10
|
-
let(:
|
11
|
-
|
10
|
+
let(:valid_xml) do
|
11
|
+
document = Nokogiri::XML(File.read("spec/fixtures/valid.xml"))
|
12
|
+
document.xpath("//wfs:FeatureCollection/gml:featureMember").first.first_element_child
|
13
|
+
end
|
12
14
|
|
13
|
-
let(:successful) { -> { {
|
15
|
+
let(:successful) { -> { { areas: [Area.new(valid_xml)] } } }
|
14
16
|
let(:errored) { -> { raise "Boom!" } }
|
15
17
|
|
16
18
|
describe "#successful?" do
|
@@ -36,7 +38,7 @@ module DefraRuby
|
|
36
38
|
let(:response_exe) { errored }
|
37
39
|
|
38
40
|
it "returns nothing" do
|
39
|
-
expect(response.
|
41
|
+
expect(response.areas).to be_empty
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -44,8 +46,8 @@ module DefraRuby
|
|
44
46
|
let(:response_exe) { successful }
|
45
47
|
|
46
48
|
it "returns an area" do
|
47
|
-
expect(response.
|
48
|
-
expect(response.
|
49
|
+
expect(response.areas[0]).to be_instance_of(Area)
|
50
|
+
expect(response.areas[0].short_name).to eq("Staffs Warks and West Mids")
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -18,11 +18,26 @@ module DefraRuby
|
|
18
18
|
response = described_class.run(easting, northing)
|
19
19
|
expect(response).to be_a(Response)
|
20
20
|
expect(response.successful?).to eq(true)
|
21
|
-
expect(response.
|
21
|
+
expect(response.areas[0].long_name).to eq("West Midlands")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
+
context "when the coordinates are valid, in England but match more than one area" do
|
27
|
+
before(:each) { VCR.insert_cassette("public_face_area_valid_multiple") }
|
28
|
+
after(:each) { VCR.eject_cassette }
|
29
|
+
|
30
|
+
let(:easting) { 398_056.684 }
|
31
|
+
let(:northing) { 414_748 }
|
32
|
+
|
33
|
+
it "returns a successful response" do
|
34
|
+
response = described_class.run(easting, northing)
|
35
|
+
expect(response).to be_a(Response)
|
36
|
+
expect(response.successful?).to eq(true)
|
37
|
+
expect(response.areas[0].long_name).to eq("Yorkshire")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
26
41
|
context "when the coordinates are invalid" do
|
27
42
|
context "because they are blank" do
|
28
43
|
before(:each) { VCR.insert_cassette("public_face_area_invalid_blank") }
|
@@ -35,7 +50,7 @@ module DefraRuby
|
|
35
50
|
response = described_class.run(easting, northing)
|
36
51
|
expect(response).to be_a(Response)
|
37
52
|
expect(response).to_not be_successful
|
38
|
-
expect(response.
|
53
|
+
expect(response.areas).to be_empty
|
39
54
|
expect(response.error).to_not be_nil
|
40
55
|
end
|
41
56
|
end
|
@@ -51,7 +66,7 @@ module DefraRuby
|
|
51
66
|
response = described_class.run(easting, northing)
|
52
67
|
expect(response).to be_a(Response)
|
53
68
|
expect(response).to_not be_successful
|
54
|
-
expect(response.
|
69
|
+
expect(response.areas).to be_empty
|
55
70
|
expect(response.error).to_not be_nil
|
56
71
|
end
|
57
72
|
end
|
@@ -18,11 +18,26 @@ module DefraRuby
|
|
18
18
|
response = described_class.run(easting, northing)
|
19
19
|
expect(response).to be_a(Response)
|
20
20
|
expect(response.successful?).to eq(true)
|
21
|
-
expect(response.
|
21
|
+
expect(response.areas[0].long_name).to eq("Staffordshire Warwickshire and West Midlands")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
+
context "when the coordinates are valid, in England but match more than one area" do
|
27
|
+
before(:each) { VCR.insert_cassette("water_management_area_valid_multiple") }
|
28
|
+
after(:each) { VCR.eject_cassette }
|
29
|
+
|
30
|
+
let(:easting) { 456_330 }
|
31
|
+
let(:northing) { 267_000 }
|
32
|
+
|
33
|
+
it "returns a successful response" do
|
34
|
+
response = described_class.run(easting, northing)
|
35
|
+
expect(response).to be_a(Response)
|
36
|
+
expect(response.successful?).to eq(true)
|
37
|
+
expect(response.areas[0].long_name).to eq("Lincolnshire and Northamptonshire")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
26
41
|
context "when the coordinates are invalid" do
|
27
42
|
context "because they are blank" do
|
28
43
|
before(:each) { VCR.insert_cassette("water_management_area_invalid_blank") }
|
@@ -35,7 +50,7 @@ module DefraRuby
|
|
35
50
|
response = described_class.run(easting, northing)
|
36
51
|
expect(response).to be_a(Response)
|
37
52
|
expect(response).to_not be_successful
|
38
|
-
expect(response.
|
53
|
+
expect(response.areas).to be_empty
|
39
54
|
expect(response.error).to_not be_nil
|
40
55
|
end
|
41
56
|
end
|
@@ -51,7 +66,7 @@ module DefraRuby
|
|
51
66
|
response = described_class.run(easting, northing)
|
52
67
|
expect(response).to be_a(Response)
|
53
68
|
expect(response).to_not be_successful
|
54
|
-
expect(response.
|
69
|
+
expect(response.areas).to be_empty
|
55
70
|
expect(response.error).to_not be_nil
|
56
71
|
end
|
57
72
|
end
|
data/spec/examples.txt
CHANGED
@@ -1,32 +1,27 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
-------------------------------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:1:1
|
4
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:
|
5
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:
|
6
|
-
./spec/defra_ruby/area/
|
7
|
-
./spec/defra_ruby/area/
|
8
|
-
./spec/defra_ruby/area/
|
9
|
-
./spec/defra_ruby/area/
|
10
|
-
./spec/defra_ruby/area/
|
11
|
-
./spec/defra_ruby/area/
|
12
|
-
./spec/defra_ruby/area/
|
13
|
-
./spec/defra_ruby/area/
|
14
|
-
./spec/defra_ruby/area/
|
15
|
-
./spec/defra_ruby/area/
|
16
|
-
./spec/defra_ruby/area/
|
17
|
-
./spec/defra_ruby/area/
|
18
|
-
./spec/defra_ruby/area/
|
19
|
-
./spec/defra_ruby/area/
|
20
|
-
./spec/defra_ruby/area/services/
|
21
|
-
./spec/defra_ruby/area/services/
|
22
|
-
./spec/defra_ruby/area/services/
|
23
|
-
./spec/defra_ruby/area/services/
|
24
|
-
./spec/defra_ruby/area/services/
|
25
|
-
./spec/defra_ruby/
|
26
|
-
./spec/defra_ruby/
|
27
|
-
./spec/defra_ruby/
|
28
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:1:1] | passed | 0.03075 seconds |
|
29
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:2:1] | passed | 0.04335 seconds |
|
30
|
-
./spec/defra_ruby/area_spec.rb[1:1:1] | passed | 0.01054 seconds |
|
31
|
-
./spec/defra_ruby/area_spec.rb[1:2:1:1] | passed | 0.00278 seconds |
|
32
|
-
./spec/defra_ruby/area_spec.rb[1:2:2:1] | passed | 0.00334 seconds |
|
3
|
+
./spec/defra_ruby/area/area_spec.rb[1:1:1:1] | passed | 0.00012 seconds |
|
4
|
+
./spec/defra_ruby/area/area_spec.rb[1:1:2:1] | passed | 0.00145 seconds |
|
5
|
+
./spec/defra_ruby/area/area_spec.rb[1:1:3:1] | passed | 0.00082 seconds |
|
6
|
+
./spec/defra_ruby/area/configuration_spec.rb[1:1] | passed | 0.0001 seconds |
|
7
|
+
./spec/defra_ruby/area/response_spec.rb[1:1:1:1] | passed | 0.00014 seconds |
|
8
|
+
./spec/defra_ruby/area/response_spec.rb[1:1:2:1] | passed | 0.00079 seconds |
|
9
|
+
./spec/defra_ruby/area/response_spec.rb[1:2:1:1] | passed | 0.00016 seconds |
|
10
|
+
./spec/defra_ruby/area/response_spec.rb[1:2:2:1] | passed | 0.00085 seconds |
|
11
|
+
./spec/defra_ruby/area/response_spec.rb[1:3:1:1] | passed | 0.00014 seconds |
|
12
|
+
./spec/defra_ruby/area/response_spec.rb[1:3:2:1] | passed | 0.00085 seconds |
|
13
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:1:1] | passed | 0.03742 seconds |
|
14
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:1] | passed | 0.02956 seconds |
|
15
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:1:1] | passed | 0.03033 seconds |
|
16
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:2:1] | passed | 0.02817 seconds |
|
17
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:4:1:1] | passed | 0.02708 seconds |
|
18
|
+
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:4:2:1] | passed | 0.02668 seconds |
|
19
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:1:1] | passed | 0.02484 seconds |
|
20
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:1] | passed | 0.03471 seconds |
|
21
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:1:1] | passed | 0.03063 seconds |
|
22
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:2:1] | passed | 0.03441 seconds |
|
23
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:4:1:1] | passed | 0.02612 seconds |
|
24
|
+
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:4:2:1] | passed | 0.03511 seconds |
|
25
|
+
./spec/defra_ruby/area_spec.rb[1:1:1] | passed | 0.00143 seconds |
|
26
|
+
./spec/defra_ruby/area_spec.rb[1:2:1:1] | passed | 0.00067 seconds |
|
27
|
+
./spec/defra_ruby/area_spec.rb[1:2:2:1] | passed | 0.00066 seconds |
|
@@ -16,7 +16,7 @@ RSpec.shared_examples "handle request errors" do
|
|
16
16
|
response = described_class.run(easting, northing)
|
17
17
|
expect(response).to be_a(DefraRuby::Area::Response)
|
18
18
|
expect(response).to_not be_successful
|
19
|
-
expect(response.
|
19
|
+
expect(response.areas).to be_empty
|
20
20
|
expect(response.error).to_not be_nil
|
21
21
|
end
|
22
22
|
end
|
@@ -28,7 +28,7 @@ RSpec.shared_examples "handle request errors" do
|
|
28
28
|
response = described_class.run(easting, northing)
|
29
29
|
expect(response).to be_a(DefraRuby::Area::Response)
|
30
30
|
expect(response).to_not be_successful
|
31
|
-
expect(response.
|
31
|
+
expect(response.areas).to be_empty
|
32
32
|
expect(response.error).to_not be_nil
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defra_ruby_area
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Defra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.10.
|
19
|
+
version: 1.10.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.10.
|
26
|
+
version: 1.10.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,9 +204,11 @@ files:
|
|
204
204
|
- spec/cassettes/public_face_area_invalid_blank.yml
|
205
205
|
- spec/cassettes/public_face_area_invalid_coords.yml
|
206
206
|
- spec/cassettes/public_face_area_valid.yml
|
207
|
+
- spec/cassettes/public_face_area_valid_multiple.yml
|
207
208
|
- spec/cassettes/water_management_area_invalid_blank.yml
|
208
209
|
- spec/cassettes/water_management_area_invalid_coords.yml
|
209
210
|
- spec/cassettes/water_management_area_valid.yml
|
211
|
+
- spec/cassettes/water_management_area_valid_multiple.yml
|
210
212
|
- spec/defra_ruby/area/area_spec.rb
|
211
213
|
- spec/defra_ruby/area/configuration_spec.rb
|
212
214
|
- spec/defra_ruby/area/response_spec.rb
|
@@ -214,7 +216,6 @@ files:
|
|
214
216
|
- spec/defra_ruby/area/services/water_management_area_service_spec.rb
|
215
217
|
- spec/defra_ruby/area_spec.rb
|
216
218
|
- spec/examples.txt
|
217
|
-
- spec/fixtures/no_match.xml
|
218
219
|
- spec/fixtures/valid.xml
|
219
220
|
- spec/spec_helper.rb
|
220
221
|
- spec/support/defra_ruby_area.rb
|
@@ -263,11 +264,12 @@ test_files:
|
|
263
264
|
- spec/cassettes/public_face_area_valid.yml
|
264
265
|
- spec/cassettes/water_management_area_valid.yml
|
265
266
|
- spec/cassettes/public_face_area_invalid_blank.yml
|
267
|
+
- spec/cassettes/public_face_area_valid_multiple.yml
|
268
|
+
- spec/cassettes/water_management_area_valid_multiple.yml
|
266
269
|
- spec/support/defra_ruby_area.rb
|
267
270
|
- spec/support/simplecov.rb
|
268
271
|
- spec/support/vcr.rb
|
269
272
|
- spec/support/pry.rb
|
270
273
|
- spec/support/dotenv.rb
|
271
274
|
- spec/support/shared_examples/handle_request_errors.rb
|
272
|
-
- spec/fixtures/no_match.xml
|
273
275
|
- spec/fixtures/valid.xml
|
data/spec/fixtures/no_match.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
-
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
|
3
|
-
<gml:boundedBy>
|
4
|
-
<gml:Box srsName="EPSG:27700">
|
5
|
-
<gml:coordinates>0,0,0,0</gml:coordinates>
|
6
|
-
</gml:Box>
|
7
|
-
</gml:boundedBy>
|
8
|
-
</wfs:FeatureCollection>
|