defra_ruby_area 2.0.3 → 2.2.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 +33 -23
- data/lib/defra_ruby/area/area.rb +18 -12
- data/lib/defra_ruby/area/services/base_area_service.rb +16 -40
- data/lib/defra_ruby/area/version.rb +1 -1
- metadata +6 -173
- data/spec/defra_ruby/area/area_spec.rb +0 -43
- data/spec/defra_ruby/area/configuration_spec.rb +0 -15
- data/spec/defra_ruby/area/response_spec.rb +0 -74
- data/spec/defra_ruby/area/services/public_face_area_service_spec.rb +0 -98
- data/spec/defra_ruby/area/services/water_management_area_service_spec.rb +0 -98
- data/spec/defra_ruby/area_spec.rb +0 -30
- data/spec/examples.txt +0 -27
- data/spec/fixtures/public_face_area_invalid_blank.xml +0 -5
- data/spec/fixtures/public_face_area_invalid_coords.xml +0 -8
- data/spec/fixtures/public_face_area_valid.xml +0 -18
- data/spec/fixtures/public_face_area_valid_multiple.xml +0 -28
- data/spec/fixtures/water_management_area_invalid_blank.xml +0 -5
- data/spec/fixtures/water_management_area_invalid_coords.xml +0 -8
- data/spec/fixtures/water_management_area_valid.xml +0 -20
- data/spec/fixtures/water_management_area_valid_multiple.xml +0 -32
- data/spec/spec_helper.rb +0 -83
- data/spec/support/defra_ruby_area.rb +0 -4
- data/spec/support/dotenv.rb +0 -4
- data/spec/support/pry.rb +0 -7
- data/spec/support/shared_examples/handle_request_errors.rb +0 -32
- data/spec/support/simplecov.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23956bd4e1621ffa7cf04a30b4096e33e990e83b6738c79d6ef11956589df6dc
|
4
|
+
data.tar.gz: 87fbeb2e00e7c88eb2212c6ef6216c3bd4b615a88fc256a289fae8f25797f758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbc060baebb90675695021b2e23ba9d25e977eed08fa8269cb3b87c7cb8a6dc229cbf43dbbc8baabf3915fadd8e3e029a1e3df15af6807d40915db904fa3f8cd
|
7
|
+
data.tar.gz: e91c6dc5995437f46aaaaa0d2225278170d471b919881872c6f7afd330a351f48874f37eba0de11f5d113e7a75601aa5a11715ecf176006e073ad2af70abf6c2
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
![Build Status](https://github.com/DEFRA/defra-ruby-area/workflows/CI/badge.svg?branch=main)
|
4
4
|
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-area&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-area)
|
5
5
|
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-area&metric=coverage)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-area)
|
6
|
-
[![security](https://hakiri.io/github/DEFRA/defra-ruby-area/main.svg)](https://hakiri.io/github/DEFRA/defra-ruby-area/main)
|
7
6
|
[![Gem Version](https://badge.fury.io/rb/defra_ruby_area.svg)](https://badge.fury.io/rb/defra_ruby_area)
|
8
7
|
[![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
|
9
8
|
|
@@ -92,27 +91,38 @@ A [Web Feature Service (WFS)](https://en.m.wikipedia.org/wiki/Web_Feature_Servic
|
|
92
91
|
|
93
92
|
Calls are made using url query params. For example behind the scenes `DefraRuby::Area::PublicFaceAreaService` is hitting the following URL
|
94
93
|
|
95
|
-
`https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?SERVICE=WFS&VERSION=
|
96
|
-
|
97
|
-
As you can see
|
98
|
-
|
99
|
-
```
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
94
|
+
`https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?outputformat=json&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas&propertyName=identifier,long_name,code,short_name&SRSName=EPSG:27700&cql_filter=bbox(shape,408602.61,257535.31,408602.61,257535.31)`
|
95
|
+
|
96
|
+
As you can see output requested in JSON, and will return the result in JSON format.
|
97
|
+
|
98
|
+
```json
|
99
|
+
{
|
100
|
+
"type": "FeatureCollection",
|
101
|
+
"features": [
|
102
|
+
{
|
103
|
+
"type": "Feature",
|
104
|
+
"id": "Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23",
|
105
|
+
"geometry": null,
|
106
|
+
"properties": {
|
107
|
+
"identifier": 51,
|
108
|
+
"long_name": "West Midlands",
|
109
|
+
"short_name": "West Midlands",
|
110
|
+
"code": "WMD"
|
111
|
+
},
|
112
|
+
"bbox": [
|
113
|
+
316114.5,
|
114
|
+
187934.4,
|
115
|
+
456472.5,
|
116
|
+
369909.5
|
117
|
+
]
|
118
|
+
}
|
119
|
+
],
|
120
|
+
"totalFeatures": 1,
|
121
|
+
"numberMatched": 1,
|
122
|
+
"numberReturned": 1,
|
123
|
+
"timeStamp": "2023-11-30T11:06:46.945Z",
|
124
|
+
"crs": null
|
125
|
+
}
|
116
126
|
```
|
117
127
|
|
118
128
|
### Further reading
|
@@ -130,7 +140,7 @@ We don't know if its just a characteristic of WFS's, GIS, or just the EA impleme
|
|
130
140
|
|
131
141
|
A WFS will often go down, sometimes for maintenance (_hopefully_ on a weekend 😀) sometimes just for 'reasons'.
|
132
142
|
|
133
|
-
Also though this gem is new, we have worked with these services before and this is approximately the
|
143
|
+
Also though this gem is new, we have worked with these services before and this is approximately the 6th time the format of the query has changed in the space of a 5 years.
|
134
144
|
|
135
145
|
For example the period of December 2018 to June 2019 both services were completely down whilst we waited for fixes to be implemented, then confirmation of what query would actually work!
|
136
146
|
|
data/lib/defra_ruby/area/area.rb
CHANGED
@@ -7,25 +7,31 @@ 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
|
-
@
|
10
|
+
def initialize(area_record)
|
11
|
+
@area_record = area_record
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
validate_area_record
|
14
|
+
parse_area_record
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def validate_area_record
|
20
|
+
unless @area_record && @area_record["properties"]&.keys&.sort == %w[
|
21
|
+
code identifier long_name short_name
|
22
|
+
]
|
23
|
+
raise(ArgumentError,
|
24
|
+
"area_record is invalid")
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
@area_id = @
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
28
|
+
def parse_area_record
|
29
|
+
@area_id = @area_record.dig("properties", "identifier").to_i
|
30
|
+
@code = @area_record.dig("properties", "code")
|
31
|
+
@long_name = @area_record.dig("properties", "long_name")
|
32
|
+
@short_name = @area_record.dig("properties", "short_name")
|
33
|
+
# area_name is no longer part of the response, but we're keeping it for backwards compatibility
|
34
|
+
@area_name = @long_name
|
29
35
|
end
|
30
36
|
|
31
37
|
end
|
@@ -30,7 +30,8 @@ module DefraRuby
|
|
30
30
|
url: url,
|
31
31
|
timeout: DefraRuby::Area.configuration.timeout
|
32
32
|
)
|
33
|
-
|
33
|
+
|
34
|
+
areas = extract_areas(JSON.parse(response))
|
34
35
|
|
35
36
|
raise NoMatchError unless areas.any?
|
36
37
|
|
@@ -38,10 +39,10 @@ module DefraRuby
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
def extract_areas(
|
42
|
+
def extract_areas(json_response)
|
42
43
|
areas = []
|
43
|
-
|
44
|
-
areas << Area.new(
|
44
|
+
json_response["features"].each do |area_record|
|
45
|
+
areas << Area.new(area_record)
|
45
46
|
end
|
46
47
|
|
47
48
|
areas
|
@@ -69,10 +70,11 @@ module DefraRuby
|
|
69
70
|
"SERVICE" => service,
|
70
71
|
"VERSION" => version,
|
71
72
|
"REQUEST" => request,
|
72
|
-
"
|
73
|
+
"typeNames" => type_name,
|
73
74
|
"propertyName" => property_name,
|
74
75
|
"SRSName" => srs_name,
|
75
|
-
"
|
76
|
+
"cql_filter" => filter,
|
77
|
+
"outputformat" => "json"
|
76
78
|
}.map { |k, v| "#{k}=#{v}" }.join("&")
|
77
79
|
end
|
78
80
|
|
@@ -98,7 +100,7 @@ module DefraRuby
|
|
98
100
|
# suppport multiple versions hence you need to state the version in the
|
99
101
|
# request.
|
100
102
|
def version
|
101
|
-
"
|
103
|
+
"2.0.0"
|
102
104
|
end
|
103
105
|
|
104
106
|
# Used to tell the WFS what kind of request you are making. In the case
|
@@ -127,14 +129,13 @@ module DefraRuby
|
|
127
129
|
# In our case the administrative boundary features contain a number of
|
128
130
|
# properties, but we are only interested in
|
129
131
|
#
|
130
|
-
# - +
|
131
|
-
# - +area_name+
|
132
|
-
# - +code+
|
132
|
+
# - +identifier+
|
133
133
|
# - +long_name+
|
134
|
+
# - +code+
|
134
135
|
# - +short_name+
|
135
136
|
#
|
136
137
|
def property_name
|
137
|
-
"
|
138
|
+
"identifier,long_name,code,short_name"
|
138
139
|
end
|
139
140
|
|
140
141
|
# SRS stands for Spatial Reference System. It can also be known as a
|
@@ -158,40 +159,15 @@ module DefraRuby
|
|
158
159
|
# WFS's use filters in GetFeature requests to return data that only
|
159
160
|
# matches a certain criteria.
|
160
161
|
#
|
161
|
-
# https://docs.geoserver.org/latest/en/user/
|
162
|
+
# https://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html
|
162
163
|
#
|
163
|
-
# There are various formats you can use for doing those, though it will be
|
164
|
-
# dependent on what the WFS supports. In our case we use XML-based Filter
|
165
|
-
# Encoding language because
|
166
|
-
#
|
167
|
-
# * this was how the team that manage the WFS have always provided their
|
168
|
-
# examples
|
169
|
-
# * we know this format is supported by the WFS's we are interacting with
|
170
|
-
#
|
171
|
-
# The others are CQL and ECQL. https://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html
|
172
164
|
#
|
173
165
|
# Our filter is looking for the result where our coordinates intersect
|
174
|
-
# with the
|
175
|
-
# +MultiPolygonPropertyType+.
|
166
|
+
# with the bounding box
|
176
167
|
#
|
177
|
-
#
|
168
|
+
# https://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html#geometric-filters
|
178
169
|
def filter
|
179
|
-
|
180
|
-
# as easily been a one line string statement, but we think this is
|
181
|
-
# better.
|
182
|
-
filter = <<-XML
|
183
|
-
(
|
184
|
-
<Filter>
|
185
|
-
<Intersects>
|
186
|
-
<PropertyName>SHAPE</PropertyName>
|
187
|
-
<gml:Point>
|
188
|
-
<gml:coordinates>#{easting},#{northing}</gml:coordinates>
|
189
|
-
</gml:Point>
|
190
|
-
</Intersects>
|
191
|
-
</Filter>
|
192
|
-
)
|
193
|
-
XML
|
194
|
-
filter.strip.squeeze(" ").gsub(/\s+/, "")
|
170
|
+
"bbox(shape,#{easting},#{northing},#{easting},#{northing})"
|
195
171
|
end
|
196
172
|
|
197
173
|
def implemented_in_subclass
|
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: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Defra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,132 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: defra_ruby_style
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: dotenv
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: github_changelog_generator
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '3.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '3.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: simplecov
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.17.1
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.17.1
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: webmock
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '3.4'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '3.4'
|
167
41
|
description: Use to query the EA's administrative boundary Web Feature Services for
|
168
42
|
area names.
|
169
43
|
email:
|
@@ -187,31 +61,11 @@ files:
|
|
187
61
|
- lib/defra_ruby/area/services/public_face_area_service.rb
|
188
62
|
- lib/defra_ruby/area/services/water_management_area_service.rb
|
189
63
|
- lib/defra_ruby/area/version.rb
|
190
|
-
- spec/defra_ruby/area/area_spec.rb
|
191
|
-
- spec/defra_ruby/area/configuration_spec.rb
|
192
|
-
- spec/defra_ruby/area/response_spec.rb
|
193
|
-
- spec/defra_ruby/area/services/public_face_area_service_spec.rb
|
194
|
-
- spec/defra_ruby/area/services/water_management_area_service_spec.rb
|
195
|
-
- spec/defra_ruby/area_spec.rb
|
196
|
-
- spec/examples.txt
|
197
|
-
- spec/fixtures/public_face_area_invalid_blank.xml
|
198
|
-
- spec/fixtures/public_face_area_invalid_coords.xml
|
199
|
-
- spec/fixtures/public_face_area_valid.xml
|
200
|
-
- spec/fixtures/public_face_area_valid_multiple.xml
|
201
|
-
- spec/fixtures/water_management_area_invalid_blank.xml
|
202
|
-
- spec/fixtures/water_management_area_invalid_coords.xml
|
203
|
-
- spec/fixtures/water_management_area_valid.xml
|
204
|
-
- spec/fixtures/water_management_area_valid_multiple.xml
|
205
|
-
- spec/spec_helper.rb
|
206
|
-
- spec/support/defra_ruby_area.rb
|
207
|
-
- spec/support/dotenv.rb
|
208
|
-
- spec/support/pry.rb
|
209
|
-
- spec/support/shared_examples/handle_request_errors.rb
|
210
|
-
- spec/support/simplecov.rb
|
211
64
|
homepage: https://github.com/DEFRA/defra-ruby-area
|
212
65
|
licenses:
|
213
66
|
- The Open Government Licence (OGL) Version 3
|
214
67
|
metadata:
|
68
|
+
rubygems_mfa_required: 'true'
|
215
69
|
allowed_push_host: https://rubygems.org
|
216
70
|
post_install_message:
|
217
71
|
rdoc_options: []
|
@@ -221,36 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
75
|
requirements:
|
222
76
|
- - ">="
|
223
77
|
- !ruby/object:Gem::Version
|
224
|
-
version: '
|
78
|
+
version: '3.2'
|
225
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
80
|
requirements:
|
227
81
|
- - ">="
|
228
82
|
- !ruby/object:Gem::Version
|
229
83
|
version: '0'
|
230
84
|
requirements: []
|
231
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.4.10
|
232
86
|
signing_key:
|
233
87
|
specification_version: 4
|
234
88
|
summary: Defra ruby on rails EA administrative area lookup
|
235
|
-
test_files:
|
236
|
-
- spec/spec_helper.rb
|
237
|
-
- spec/defra_ruby/area/configuration_spec.rb
|
238
|
-
- spec/defra_ruby/area/area_spec.rb
|
239
|
-
- spec/defra_ruby/area/response_spec.rb
|
240
|
-
- spec/defra_ruby/area/services/water_management_area_service_spec.rb
|
241
|
-
- spec/defra_ruby/area/services/public_face_area_service_spec.rb
|
242
|
-
- spec/defra_ruby/area_spec.rb
|
243
|
-
- spec/examples.txt
|
244
|
-
- spec/support/defra_ruby_area.rb
|
245
|
-
- spec/support/simplecov.rb
|
246
|
-
- spec/support/pry.rb
|
247
|
-
- spec/support/dotenv.rb
|
248
|
-
- spec/support/shared_examples/handle_request_errors.rb
|
249
|
-
- spec/fixtures/public_face_area_valid_multiple.xml
|
250
|
-
- spec/fixtures/water_management_area_valid_multiple.xml
|
251
|
-
- spec/fixtures/public_face_area_invalid_blank.xml
|
252
|
-
- spec/fixtures/public_face_area_valid.xml
|
253
|
-
- spec/fixtures/water_management_area_valid.xml
|
254
|
-
- spec/fixtures/water_management_area_invalid_coords.xml
|
255
|
-
- spec/fixtures/public_face_area_invalid_coords.xml
|
256
|
-
- spec/fixtures/water_management_area_invalid_blank.xml
|
89
|
+
test_files: []
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "nokogiri"
|
5
|
-
|
6
|
-
module DefraRuby
|
7
|
-
module Area
|
8
|
-
RSpec.describe Area do
|
9
|
-
let(:valid_xml) do
|
10
|
-
document = Nokogiri::XML(File.read("spec/fixtures/water_management_area_valid.xml"))
|
11
|
-
document.xpath("//wfs:FeatureCollection/gml:featureMember").first.first_element_child
|
12
|
-
end
|
13
|
-
let(:invalid_xml) { "foo" }
|
14
|
-
|
15
|
-
describe "#initialize" do
|
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")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
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")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
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)
|
31
|
-
|
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")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
module DefraRuby
|
6
|
-
module Area
|
7
|
-
RSpec.describe Configuration do
|
8
|
-
it "sets the appropriate default config settings" do
|
9
|
-
fresh_config = described_class.new
|
10
|
-
|
11
|
-
expect(fresh_config.timeout).to eq(3)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
module DefraRuby
|
6
|
-
module Area
|
7
|
-
RSpec.describe Response do
|
8
|
-
subject(:response) { described_class.new(response_exe) }
|
9
|
-
|
10
|
-
let(:valid_xml) do
|
11
|
-
document = Nokogiri::XML(File.read("spec/fixtures/water_management_area_valid.xml"))
|
12
|
-
document.xpath("//wfs:FeatureCollection/gml:featureMember").first.first_element_child
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:successful) { -> { { areas: [Area.new(valid_xml)] } } }
|
16
|
-
let(:errored) { -> { raise "Boom!" } }
|
17
|
-
|
18
|
-
describe "#successful?" do
|
19
|
-
context "when the response throws an error" do
|
20
|
-
let(:response_exe) { errored }
|
21
|
-
|
22
|
-
it "returns false" do
|
23
|
-
expect(response).to_not be_successful
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when the response doesn't throw an error" do
|
28
|
-
let(:response_exe) { successful }
|
29
|
-
|
30
|
-
it "returns true" do
|
31
|
-
expect(response).to be_successful
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#area" do
|
37
|
-
context "when the response throws an error" do
|
38
|
-
let(:response_exe) { errored }
|
39
|
-
|
40
|
-
it "returns nothing" do
|
41
|
-
expect(response.areas).to be_empty
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "when the response does not throw an error" do
|
46
|
-
let(:response_exe) { successful }
|
47
|
-
|
48
|
-
it "returns an area" do
|
49
|
-
expect(response.areas[0]).to be_instance_of(Area)
|
50
|
-
expect(response.areas[0].short_name).to eq("Staffs Warks and West Mids")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#error" do
|
56
|
-
context "when the response throws an error" do
|
57
|
-
let(:response_exe) { errored }
|
58
|
-
|
59
|
-
it "returns the error" do
|
60
|
-
expect(response.error).to be_a(StandardError)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "when the response don't throw an error" do
|
65
|
-
let(:response_exe) { successful }
|
66
|
-
|
67
|
-
it "returns a nil object" do
|
68
|
-
expect(response.error).to be_nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "webmock/rspec"
|
4
|
-
require "spec_helper"
|
5
|
-
|
6
|
-
module DefraRuby
|
7
|
-
module Area
|
8
|
-
RSpec.describe PublicFaceAreaService do
|
9
|
-
let(:host) { "https://environment.data.gov.uk" }
|
10
|
-
|
11
|
-
describe "#run" do
|
12
|
-
context "when the coordinates are valid and in England" do
|
13
|
-
before do
|
14
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
15
|
-
status: 200,
|
16
|
-
body: File.read("./spec/fixtures/public_face_area_valid.xml")
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:easting) { 408_602.61 }
|
21
|
-
let(:northing) { 257_535.31 }
|
22
|
-
|
23
|
-
it "returns a successful response" do
|
24
|
-
response = described_class.run(easting, northing)
|
25
|
-
expect(response).to be_a(Response)
|
26
|
-
expect(response.successful?).to eq(true)
|
27
|
-
expect(response.areas[0].long_name).to eq("West Midlands")
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when the coordinates are valid, in England but match more than one area" do
|
33
|
-
before do
|
34
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
35
|
-
status: 200,
|
36
|
-
body: File.read("./spec/fixtures/public_face_area_valid_multiple.xml")
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
let(:easting) { 398_056.684 }
|
41
|
-
let(:northing) { 414_748 }
|
42
|
-
|
43
|
-
it "returns a successful response" do
|
44
|
-
response = described_class.run(easting, northing)
|
45
|
-
expect(response).to be_a(Response)
|
46
|
-
expect(response.successful?).to eq(true)
|
47
|
-
expect(response.areas[0].long_name).to eq("Yorkshire")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when the coordinates are invalid" do
|
52
|
-
context "because they are blank" do
|
53
|
-
before do
|
54
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
55
|
-
status: 200,
|
56
|
-
body: File.read("./spec/fixtures/public_face_area_invalid_blank.xml")
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
let(:easting) { nil }
|
61
|
-
let(:northing) { nil }
|
62
|
-
|
63
|
-
it "returns a failed response" do
|
64
|
-
response = described_class.run(easting, northing)
|
65
|
-
expect(response).to be_a(Response)
|
66
|
-
expect(response).to_not be_successful
|
67
|
-
expect(response.areas).to be_empty
|
68
|
-
expect(response.error).to_not be_nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "because they are not in an area" do
|
73
|
-
before do
|
74
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
75
|
-
status: 200,
|
76
|
-
body: File.read("./spec/fixtures/public_face_area_invalid_coords.xml")
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
let(:easting) { 301_233.0 }
|
81
|
-
let(:northing) { 221_592.0 }
|
82
|
-
|
83
|
-
it "returns a failed response" do
|
84
|
-
response = described_class.run(easting, northing)
|
85
|
-
expect(response).to be_a(Response)
|
86
|
-
expect(response).to_not be_successful
|
87
|
-
expect(response.areas).to be_empty
|
88
|
-
expect(response.error).to_not be_nil
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
include_examples "handle request errors"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "webmock/rspec"
|
4
|
-
require "spec_helper"
|
5
|
-
|
6
|
-
module DefraRuby
|
7
|
-
module Area
|
8
|
-
RSpec.describe WaterManagementAreaService do
|
9
|
-
let(:host) { "https://environment.data.gov.uk" }
|
10
|
-
|
11
|
-
describe "#run" do
|
12
|
-
context "when the coordinates are valid and in England" do
|
13
|
-
before do
|
14
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
15
|
-
status: 200,
|
16
|
-
body: File.read("./spec/fixtures/water_management_area_valid.xml")
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:easting) { 408_602.61 }
|
21
|
-
let(:northing) { 257_535.31 }
|
22
|
-
|
23
|
-
it "returns a successful response" do
|
24
|
-
response = described_class.run(easting, northing)
|
25
|
-
expect(response).to be_a(Response)
|
26
|
-
expect(response.successful?).to eq(true)
|
27
|
-
expect(response.areas[0].long_name).to eq("Staffordshire Warwickshire and West Midlands")
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when the coordinates are valid, in England but match more than one area" do
|
33
|
-
before do
|
34
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
35
|
-
status: 200,
|
36
|
-
body: File.read("./spec/fixtures/water_management_area_valid_multiple.xml")
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
let(:easting) { 456_330 }
|
41
|
-
let(:northing) { 267_000 }
|
42
|
-
|
43
|
-
it "returns a successful response" do
|
44
|
-
response = described_class.run(easting, northing)
|
45
|
-
expect(response).to be_a(Response)
|
46
|
-
expect(response.successful?).to eq(true)
|
47
|
-
expect(response.areas[0].long_name).to eq("Lincolnshire and Northamptonshire")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when the coordinates are invalid" do
|
52
|
-
context "because they are blank" do
|
53
|
-
before do
|
54
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
55
|
-
status: 200,
|
56
|
-
body: File.read("./spec/fixtures/water_management_area_invalid_blank.xml")
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
let(:easting) { nil }
|
61
|
-
let(:northing) { nil }
|
62
|
-
|
63
|
-
it "returns a failed response" do
|
64
|
-
response = described_class.run(easting, northing)
|
65
|
-
expect(response).to be_a(Response)
|
66
|
-
expect(response).to_not be_successful
|
67
|
-
expect(response.areas).to be_empty
|
68
|
-
expect(response.error).to_not be_nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "because they are not in an area" do
|
73
|
-
before do
|
74
|
-
stub_request(:any, /.*#{host}.*/).to_return(
|
75
|
-
status: 200,
|
76
|
-
body: File.read("./spec/fixtures/water_management_area_invalid_coords.xml")
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
let(:easting) { 301_233.0 }
|
81
|
-
let(:northing) { 221_592.0 }
|
82
|
-
|
83
|
-
it "returns a failed response" do
|
84
|
-
response = described_class.run(easting, northing)
|
85
|
-
expect(response).to be_a(Response)
|
86
|
-
expect(response).to_not be_successful
|
87
|
-
expect(response.areas).to be_empty
|
88
|
-
expect(response.error).to_not be_nil
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
include_examples "handle request errors"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe DefraRuby::Area do
|
6
|
-
describe "VERSION" do
|
7
|
-
it "is a version string in the correct format" do
|
8
|
-
expect(DefraRuby::Area::VERSION).to be_a(String)
|
9
|
-
expect(DefraRuby::Area::VERSION).to match(/\d+\.\d+\.\d+/)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#configuration" do
|
14
|
-
context "when the host app has not provided configuration" do
|
15
|
-
it "returns a DefraRuby::Area::Configuration instance" do
|
16
|
-
expect(described_class.configuration).to be_an_instance_of(DefraRuby::Area::Configuration)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when the host app has provided configuration" do
|
21
|
-
let(:timeout) { 10 }
|
22
|
-
|
23
|
-
it "returns an DefraRuby::Area::Configuration instance with a matching timeout" do
|
24
|
-
described_class.configure { |config| config.timeout = timeout }
|
25
|
-
|
26
|
-
expect(described_class.configuration.timeout).to eq(timeout)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/examples.txt
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
-------------------------------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:1:1] | passed | 0.0021 seconds |
|
4
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:2:1] | passed | 0.00021 seconds |
|
5
|
-
./spec/defra_ruby/area/area_spec.rb[1:1:3:1] | passed | 0.00121 seconds |
|
6
|
-
./spec/defra_ruby/area/configuration_spec.rb[1:1] | passed | 0.00021 seconds |
|
7
|
-
./spec/defra_ruby/area/response_spec.rb[1:1:1:1] | passed | 0.00035 seconds |
|
8
|
-
./spec/defra_ruby/area/response_spec.rb[1:1:2:1] | passed | 0.00203 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.00097 seconds |
|
11
|
-
./spec/defra_ruby/area/response_spec.rb[1:3:1:1] | passed | 0.00016 seconds |
|
12
|
-
./spec/defra_ruby/area/response_spec.rb[1:3:2:1] | passed | 0.00083 seconds |
|
13
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:1:1] | passed | 0.01808 seconds |
|
14
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:1] | passed | 0.02628 seconds |
|
15
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:1:1] | passed | 0.02936 seconds |
|
16
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:2:1] | passed | 0.0289 seconds |
|
17
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:4:1:1] | passed | 0.03718 seconds |
|
18
|
-
./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:4:2:1] | passed | 0.01739 seconds |
|
19
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:1:1] | passed | 0.03459 seconds |
|
20
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:1] | passed | 0.03187 seconds |
|
21
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:1:1] | passed | 0.02805 seconds |
|
22
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:2:1] | passed | 0.02501 seconds |
|
23
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:4:1:1] | passed | 0.03049 seconds |
|
24
|
-
./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:4:2:1] | passed | 0.01929 seconds |
|
25
|
-
./spec/defra_ruby/area_spec.rb[1:1:1] | passed | 0.00126 seconds |
|
26
|
-
./spec/defra_ruby/area_spec.rb[1:2:1:1] | passed | 0.00088 seconds |
|
27
|
-
./spec/defra_ruby/area_spec.rb[1:2:2:1] | passed | 0.00024 seconds |
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
-
<ogc:ServiceExceptionReport xmlns:ogc="http://www.opengis.net/ogc" version="1.2.0">
|
3
|
-
<ogc:ServiceException><![CDATA[The geometry was not recognized.]]></ogc:ServiceException>
|
4
|
-
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
5
|
-
</ogc:ServiceExceptionReport>
|
@@ -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-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">
|
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>
|
@@ -1,18 +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-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">
|
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
|
-
<gml:featureMember>
|
9
|
-
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
|
10
|
-
<ms:OBJECTID>23</ms:OBJECTID>
|
11
|
-
<ms:long_name>West Midlands</ms:long_name>
|
12
|
-
<ms:short_name>West Midlands</ms:short_name>
|
13
|
-
<ms:code>WMD</ms:code>
|
14
|
-
<ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
|
15
|
-
<ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
|
16
|
-
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
17
|
-
</gml:featureMember>
|
18
|
-
</wfs:FeatureCollection>
|
@@ -1,28 +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-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">
|
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
|
-
<gml:featureMember>
|
9
|
-
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.19">
|
10
|
-
<ms:OBJECTID>19</ms:OBJECTID>
|
11
|
-
<ms:long_name>Yorkshire</ms:long_name>
|
12
|
-
<ms:short_name>Yorkshire</ms:short_name>
|
13
|
-
<ms:code>YOR</ms:code>
|
14
|
-
<ms:st_area_shape_>14482874597.24499</ms:st_area_shape_>
|
15
|
-
<ms:st_perimeter_shape_>820401.3233851442</ms:st_perimeter_shape_>
|
16
|
-
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
17
|
-
</gml:featureMember>
|
18
|
-
<gml:featureMember>
|
19
|
-
<ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.20">
|
20
|
-
<ms:OBJECTID>20</ms:OBJECTID>
|
21
|
-
<ms:long_name>Greater Manchester Merseyside and Cheshire</ms:long_name>
|
22
|
-
<ms:short_name>Gtr Mancs Mersey and Ches</ms:short_name>
|
23
|
-
<ms:code>GMC</ms:code>
|
24
|
-
<ms:st_area_shape_>4473822349.59001</ms:st_area_shape_>
|
25
|
-
<ms:st_perimeter_shape_>543689.9446941023</ms:st_perimeter_shape_>
|
26
|
-
</ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
|
27
|
-
</gml:featureMember>
|
28
|
-
</wfs:FeatureCollection>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
-
<ogc:ServiceExceptionReport xmlns:ogc="http://www.opengis.net/ogc" version="1.2.0">
|
3
|
-
<ogc:ServiceException><![CDATA[The geometry was not recognized.]]></ogc:ServiceException>
|
4
|
-
<ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
|
5
|
-
</ogc:ServiceExceptionReport>
|
@@ -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>
|
@@ -1,20 +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
|
-
<gml:featureMember>
|
9
|
-
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
|
10
|
-
<ms:OBJECTID>15</ms:OBJECTID>
|
11
|
-
<ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
|
12
|
-
<ms:short_name>Staffs Warks and West Mids</ms:short_name>
|
13
|
-
<ms:code>STWKWM</ms:code>
|
14
|
-
<ms:area_id>29</ms:area_id>
|
15
|
-
<ms:area_name>Central</ms:area_name>
|
16
|
-
<ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
|
17
|
-
<ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
|
18
|
-
</ms:Administrative_Boundaries_Water_Management_Areas>
|
19
|
-
</gml:featureMember>
|
20
|
-
</wfs:FeatureCollection>
|
@@ -1,32 +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
|
-
<gml:featureMember>
|
9
|
-
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.11">
|
10
|
-
<ms:OBJECTID>11</ms:OBJECTID>
|
11
|
-
<ms:long_name>Lincolnshire and Northamptonshire</ms:long_name>
|
12
|
-
<ms:short_name>Lincs and Northants</ms:short_name>
|
13
|
-
<ms:code>LCNNTH</ms:code>
|
14
|
-
<ms:area_id>3</ms:area_id>
|
15
|
-
<ms:area_name>Northern</ms:area_name>
|
16
|
-
<ms:st_area_shape_>9270202427.530003</ms:st_area_shape_>
|
17
|
-
<ms:st_perimeter_shape_>1148848.464792307</ms:st_perimeter_shape_>
|
18
|
-
</ms:Administrative_Boundaries_Water_Management_Areas>
|
19
|
-
</gml:featureMember>
|
20
|
-
<gml:featureMember>
|
21
|
-
<ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
|
22
|
-
<ms:OBJECTID>15</ms:OBJECTID>
|
23
|
-
<ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
|
24
|
-
<ms:short_name>Staffs Warks and West Mids</ms:short_name>
|
25
|
-
<ms:code>STWKWM</ms:code>
|
26
|
-
<ms:area_id>29</ms:area_id>
|
27
|
-
<ms:area_name>Central</ms:area_name>
|
28
|
-
<ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
|
29
|
-
<ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
|
30
|
-
</ms:Administrative_Boundaries_Water_Management_Areas>
|
31
|
-
</gml:featureMember>
|
32
|
-
</wfs:FeatureCollection>
|
data/spec/spec_helper.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
|
5
|
-
# Require and run our simplecov initializer as the very first thing we do.
|
6
|
-
# This is as per its docs https://github.com/colszowka/simplecov#getting-started
|
7
|
-
require "./spec/support/simplecov"
|
8
|
-
|
9
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
10
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
11
|
-
# run as spec files by default. This means that files in spec/support that end
|
12
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
13
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
14
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
15
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
16
|
-
#
|
17
|
-
# We make an exception for simplecov because that will already have been
|
18
|
-
# required and run at the very top of spec_helper.rb
|
19
|
-
support_files = Dir["./spec/support/**/*.rb"].reject { |file| file == "./spec/support/simplecov.rb" }
|
20
|
-
support_files.each { |f| require f }
|
21
|
-
|
22
|
-
RSpec.configure do |config|
|
23
|
-
# rspec-expectations config goes here. You can use an alternate
|
24
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
25
|
-
# assertions if you prefer.
|
26
|
-
config.expect_with :rspec do |expectations|
|
27
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
28
|
-
# and `failure_message` of custom matchers include text for helper methods
|
29
|
-
# defined using `chain`, e.g.:
|
30
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
31
|
-
# # => "be bigger than 2 and smaller than 4"
|
32
|
-
# ...rather than:
|
33
|
-
# # => "be bigger than 2"
|
34
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
35
|
-
end
|
36
|
-
|
37
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
38
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
39
|
-
config.mock_with :rspec do |mocks|
|
40
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
41
|
-
# a real object. This is generally recommended, and will default to
|
42
|
-
# `true` in RSpec 4.
|
43
|
-
mocks.verify_partial_doubles = true
|
44
|
-
end
|
45
|
-
|
46
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
47
|
-
# have no way to turn it off -- the option exists only for backwards
|
48
|
-
# compatibility in RSpec 3). It causes shared context metadata to be
|
49
|
-
# inherited by the metadata hash of host groups and examples, rather than
|
50
|
-
# triggering implicit auto-inclusion in groups with matching metadata.
|
51
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
52
|
-
|
53
|
-
# This allows you to limit a spec run to individual examples or groups
|
54
|
-
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
-
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
-
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
-
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
-
config.filter_run_when_matching :focus
|
59
|
-
|
60
|
-
# Allows RSpec to persist some state between runs in order to support
|
61
|
-
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
-
# you configure your source control system to ignore this file.
|
63
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
-
|
65
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
-
# recommended. For more details, see:
|
67
|
-
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
-
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
-
config.disable_monkey_patching!
|
71
|
-
|
72
|
-
# Run specs in random order to surface order dependencies. If you find an
|
73
|
-
# order dependency and want to debug it, you can fix the order by providing
|
74
|
-
# the seed, which is printed after each run.
|
75
|
-
# --seed 1234
|
76
|
-
config.order = :random
|
77
|
-
|
78
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
79
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
80
|
-
# test failures related to randomization by passing the same `--seed` value
|
81
|
-
# as the one that triggered the failure.
|
82
|
-
Kernel.srand config.seed
|
83
|
-
end
|
data/spec/support/dotenv.rb
DELETED
data/spec/support/pry.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Support debugging in the tests. Add `binding.pry` wherever you want execution
|
4
|
-
# to stop and the debugger to kick in.
|
5
|
-
# Details on the debugging commands can be found here
|
6
|
-
# https://github.com/deivid-rodriguez/pry-byebug#commands
|
7
|
-
require "pry-byebug"
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.shared_examples "handle request errors" do
|
4
|
-
context "when there is a problem with the Web Feature Service" do
|
5
|
-
let(:easting) { 408_602.61 }
|
6
|
-
let(:northing) { 257_535.31 }
|
7
|
-
|
8
|
-
context "and the request times out" do
|
9
|
-
before(:each) { stub_request(:any, /.*#{host}.*/).to_timeout }
|
10
|
-
|
11
|
-
it "returns a failed response" do
|
12
|
-
response = described_class.run(easting, northing)
|
13
|
-
expect(response).to be_a(DefraRuby::Area::Response)
|
14
|
-
expect(response).to_not be_successful
|
15
|
-
expect(response.areas).to be_empty
|
16
|
-
expect(response.error).to_not be_nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "and the request returns an error" do
|
21
|
-
before(:each) { stub_request(:any, /.*#{host}.*/).to_raise(SocketError) }
|
22
|
-
|
23
|
-
it "returns a failed response" do
|
24
|
-
response = described_class.run(easting, northing)
|
25
|
-
expect(response).to be_a(DefraRuby::Area::Response)
|
26
|
-
expect(response).to_not be_successful
|
27
|
-
expect(response.areas).to be_empty
|
28
|
-
expect(response.error).to_not be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/support/simplecov.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "simplecov"
|
4
|
-
|
5
|
-
# We start it with the rails param to ensure it includes coverage for all code
|
6
|
-
# started by the rails app, and not just the files touched by our unit tests.
|
7
|
-
# This gives us the most accurate assessment of our unit test coverage
|
8
|
-
# https://github.com/colszowka/simplecov#getting-started
|
9
|
-
SimpleCov.start do
|
10
|
-
# We filter the spec folder, mainly to ensure that any dummy apps don't get
|
11
|
-
# included in the coverage report. However our intent is that nothing in the
|
12
|
-
# spec folder should be included
|
13
|
-
add_filter "/spec/"
|
14
|
-
# The version file is simply just that, so we do not feel the need to ensure
|
15
|
-
# we have a test for it
|
16
|
-
add_filter "lib/defra_ruby/validators/version"
|
17
|
-
end
|