defra_ruby_area 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5908506eabe199212907116e64473c18716458801d5b43f11509e16d1451643
4
- data.tar.gz: 0b9283fd5bb2c9388d2e20e95fac64e5932e79934545af47d37f26076fa9fccf
3
+ metadata.gz: f8d89480d54dc8d9b14ee66e19ed637eabe76f6882ab44b4c2b8a3f23953951a
4
+ data.tar.gz: 41609ce1da6d6a4ec09e692d5a77509548edb756f27e3bf2f2681316c114adb2
5
5
  SHA512:
6
- metadata.gz: 75a49b0479dfb1926d0009cd7dafea43d37595db6a4356b403cd864e2966fa58c7641dbbf5e2e680553f24ef6b1bd4fa0431414957c7ae903f72a134654fe68e
7
- data.tar.gz: bccfb6f2ac0cec7ab2462d060bd34e4cdb37b0ffd5cee28250f4f54f57e2191fa80ed1a61ef99131948574b9c71bd818da366a2641938afaa3feb99b3c669dcc
6
+ metadata.gz: 291c9a85168a3ebd8b7407c9d1ed2cb69a33ed6ebbc0f67e981ce0fcaa77283b75cde0a1dc861528892ec8fbbf701688ad71badf79a0a1d048691e00f7c4dfea
7
+ data.tar.gz: 898852ee546a6ef9db708639d0f034cd4cbab2c45a5ddb56657a0719133f6a1cdb108ace33e4fda03ae32308ec8c4270623bb5bb4048bcbddfa3381df1ecfc4a
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,25 +91,27 @@ 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=1.0.0&REQUEST=GetFeature&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas&propertyName=long_name&SRSName=EPSG:27700&Filter=(<Filter><Intersects><PropertyName>SHAPE</PropertyName><gml:Point><gml:coordinates>408602.61,257535.31</gml:coordinates></gml:Point></Intersects></Filter>)`
94
+ `https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typeNames=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas&propertyName=long_name&SRSName=EPSG:27700&Filter=(<ogc:Filter><ogc:Intersects><ogc:PropertyName>SHAPE</ogc:PropertyName><gml:Point><gml:coordinates>408602.61,257535.31</gml:coordinates></gml:Point></ogc:Intersects></ogc:Filter>)`
96
95
 
97
96
  As you can see it uses XML within query, and will return the result in XML.
98
97
 
99
98
  ```xml
100
99
  <?xml version="1.0" encoding="utf-8" ?>
101
- <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">
102
- <gml:boundedBy>
103
- <gml:Box srsName="EPSG:27700">
104
- <gml:coordinates>0,0,0,0</gml:coordinates>
105
- </gml:Box>
106
- </gml:boundedBy>
100
+ <wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:dataset-91d0fb43-209c-477f-91e3-74e756296268="https://environment.data.gov.uk/spatialdata/dataset-91d0fb43-209c-477f-91e3-74e756296268/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://environment.data.gov.uk/spatialdata/dataset-91d0fb43-209c-477f-91e3-74e756296268/wfs https://environment.data.gov.uk/geoservices/datasets/91d0fb43-209c-477f-91e3-74e756296268/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=dataset-91d0fb43-209c-477f-91e3-74e756296268%3AAdministrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
101
+ <gml:boundedBy>
102
+ <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#27700">
103
+ <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">57821.0086,-17164.8096 680640.9677,669368.5003</gml:coordinates>
104
+ </gml:Box>
105
+ </gml:boundedBy>
107
106
  <gml:featureMember>
108
- <ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
109
- <ms:OBJECTID>23</ms:OBJECTID>
110
- <ms:long_name>West Midlands</ms:long_name>
111
- <ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
112
- <ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
113
- </ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
107
+ <dataset-91d0fb43-209c-477f-91e3-74e756296268:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.1">
108
+ <gml:boundedBy>
109
+ <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#27700">
110
+ <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">280034.5456,45980.9664 421821.4,182101.3994</gml:coordinates>
111
+ </gml:Box>
112
+ </gml:boundedBy>
113
+ <dataset-91d0fb43-209c-477f-91e3-74e756296268:long_name>Wessex</dataset-91d0fb43-209c-477f-91e3-74e756296268:long_name>
114
+ </dataset-91d0fb43-209c-477f-91e3-74e756296268:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
114
115
  </gml:featureMember>
115
116
  </wfs:FeatureCollection>
116
117
  ```
@@ -130,7 +131,7 @@ We don't know if its just a characteristic of WFS's, GIS, or just the EA impleme
130
131
 
131
132
  A WFS will often go down, sometimes for maintenance (_hopefully_ on a weekend 😀) sometimes just for 'reasons'.
132
133
 
133
- Also though this gem is new, we have worked with these services before and this is approximately the 5th time the format of the query has changed in the space of a 3 years.
134
+ 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
135
 
135
136
  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
137
 
@@ -21,11 +21,11 @@ module DefraRuby
21
21
  end
22
22
 
23
23
  def parse_xml
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
24
+ @area_id = @xml.xpath("*[local-name()='identifier']").text.to_i
25
+ @code = @xml.xpath("*[local-name()='code']").text
26
+ @long_name = @xml.xpath("*[local-name()='long_name']").text
27
+ @short_name = @xml.xpath("*[local-name()='short_name']").text
28
+ @area_name = @long_name
29
29
  end
30
30
 
31
31
  end
@@ -127,14 +127,13 @@ module DefraRuby
127
127
  # In our case the administrative boundary features contain a number of
128
128
  # properties, but we are only interested in
129
129
  #
130
- # - +area_id+
131
- # - +area_name+
132
- # - +code+
130
+ # - +identifier+
133
131
  # - +long_name+
132
+ # - +code+
134
133
  # - +short_name+
135
134
  #
136
135
  def property_name
137
- "area_id,area_name,code,long_name,short_name"
136
+ "identifier,long_name,code,short_name"
138
137
  end
139
138
 
140
139
  # SRS stands for Spatial Reference System. It can also be known as a
@@ -181,14 +180,14 @@ module DefraRuby
181
180
  # better.
182
181
  filter = <<-XML
183
182
  (
184
- <Filter>
185
- <Intersects>
186
- <PropertyName>SHAPE</PropertyName>
183
+ <ogc:Filter>
184
+ <ogc:Intersects>
185
+ <ogc:PropertyName>SHAPE</ogc:PropertyName>
187
186
  <gml:Point>
188
187
  <gml:coordinates>#{easting},#{northing}</gml:coordinates>
189
188
  </gml:Point>
190
- </Intersects>
191
- </Filter>
189
+ </ogc:Intersects>
190
+ </ogc:Filter>
192
191
  )
193
192
  XML
194
193
  filter.strip.squeeze(" ").gsub(/\s+/, "")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module DefraRuby
4
4
  module Area
5
- VERSION = "2.0.3"
5
+ VERSION = "2.1.0"
6
6
  end
7
7
  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: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Defra
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-03 00:00:00.000000000 Z
11
+ date: 2023-11-24 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,33 +61,13 @@ 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
- post_install_message:
70
+ post_install_message:
217
71
  rdoc_options: []
218
72
  require_paths:
219
73
  - lib
@@ -221,36 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
75
  requirements:
222
76
  - - ">="
223
77
  - !ruby/object:Gem::Version
224
- version: '0'
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.1.2
232
- signing_key:
85
+ rubygems_version: 3.4.10
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
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Need to require our actual code files.
4
- require "defra_ruby/area"
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Load env vars from a text file
4
- require "dotenv/load"
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
@@ -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