defra_ruby_area 2.0.2 → 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: ae979716dbfa3c43991e2f21d67190c7bda4cfaef0dc5ae87dc2ac1beb746bae
4
- data.tar.gz: df9ac3a40869869bd2bc32e2d9d713095cc529f84ff01aa1f7b31b18289d0108
3
+ metadata.gz: f8d89480d54dc8d9b14ee66e19ed637eabe76f6882ab44b4c2b8a3f23953951a
4
+ data.tar.gz: 41609ce1da6d6a4ec09e692d5a77509548edb756f27e3bf2f2681316c114adb2
5
5
  SHA512:
6
- metadata.gz: 89d81a16ac76041d7c92675b305da316863fe9bce4d592991198bd332cd27ee4f9912845e96c027687e4dc9467b06153cde550283fa3caa57e566a2a202bda48
7
- data.tar.gz: 810ead2522a2fc25bd55b94917517cd597852405040dbe29ec2cb91883ef5e39affcffcee99b989daae27e7dd191358b2e85cfd0450a54526a169163f5dcc4a0
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.2"
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.2
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: 2021-09-30 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
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.11.1
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 1.13.0
19
+ version: 1.13.2
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.11.1
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 1.13.0
26
+ version: 1.13.2
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rest-client
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,132 +38,6 @@ dependencies:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
40
  version: '2.0'
47
- - !ruby/object:Gem::Dependency
48
- name: defra_ruby_style
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: dotenv
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: github_changelog_generator
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- - !ruby/object:Gem::Dependency
90
- name: pry-byebug
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: rake
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: rspec
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '3.0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '3.0'
131
- - !ruby/object:Gem::Dependency
132
- name: rubocop
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- - !ruby/object:Gem::Dependency
146
- name: simplecov
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: 0.17.1
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: 0.17.1
159
- - !ruby/object:Gem::Dependency
160
- name: webmock
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '3.4'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '3.4'
173
41
  description: Use to query the EA's administrative boundary Web Feature Services for
174
42
  area names.
175
43
  email:
@@ -193,32 +61,13 @@ files:
193
61
  - lib/defra_ruby/area/services/public_face_area_service.rb
194
62
  - lib/defra_ruby/area/services/water_management_area_service.rb
195
63
  - lib/defra_ruby/area/version.rb
196
- - spec/defra_ruby/area/area_spec.rb
197
- - spec/defra_ruby/area/configuration_spec.rb
198
- - spec/defra_ruby/area/response_spec.rb
199
- - spec/defra_ruby/area/services/public_face_area_service_spec.rb
200
- - spec/defra_ruby/area/services/water_management_area_service_spec.rb
201
- - spec/defra_ruby/area_spec.rb
202
- - spec/fixtures/public_face_area_invalid_blank.xml
203
- - spec/fixtures/public_face_area_invalid_coords.xml
204
- - spec/fixtures/public_face_area_valid.xml
205
- - spec/fixtures/public_face_area_valid_multiple.xml
206
- - spec/fixtures/water_management_area_invalid_blank.xml
207
- - spec/fixtures/water_management_area_invalid_coords.xml
208
- - spec/fixtures/water_management_area_valid.xml
209
- - spec/fixtures/water_management_area_valid_multiple.xml
210
- - spec/spec_helper.rb
211
- - spec/support/defra_ruby_area.rb
212
- - spec/support/dotenv.rb
213
- - spec/support/pry.rb
214
- - spec/support/shared_examples/handle_request_errors.rb
215
- - spec/support/simplecov.rb
216
64
  homepage: https://github.com/DEFRA/defra-ruby-area
217
65
  licenses:
218
66
  - The Open Government Licence (OGL) Version 3
219
67
  metadata:
68
+ rubygems_mfa_required: 'true'
220
69
  allowed_push_host: https://rubygems.org
221
- post_install_message:
70
+ post_install_message:
222
71
  rdoc_options: []
223
72
  require_paths:
224
73
  - lib
@@ -226,35 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
75
  requirements:
227
76
  - - ">="
228
77
  - !ruby/object:Gem::Version
229
- version: '0'
78
+ version: '3.2'
230
79
  required_rubygems_version: !ruby/object:Gem::Requirement
231
80
  requirements:
232
81
  - - ">="
233
82
  - !ruby/object:Gem::Version
234
83
  version: '0'
235
84
  requirements: []
236
- rubygems_version: 3.1.2
237
- signing_key:
85
+ rubygems_version: 3.4.10
86
+ signing_key:
238
87
  specification_version: 4
239
88
  summary: Defra ruby on rails EA administrative area lookup
240
- test_files:
241
- - spec/spec_helper.rb
242
- - spec/defra_ruby/area/configuration_spec.rb
243
- - spec/defra_ruby/area/area_spec.rb
244
- - spec/defra_ruby/area/response_spec.rb
245
- - spec/defra_ruby/area/services/water_management_area_service_spec.rb
246
- - spec/defra_ruby/area/services/public_face_area_service_spec.rb
247
- - spec/defra_ruby/area_spec.rb
248
- - spec/support/defra_ruby_area.rb
249
- - spec/support/simplecov.rb
250
- - spec/support/pry.rb
251
- - spec/support/dotenv.rb
252
- - spec/support/shared_examples/handle_request_errors.rb
253
- - spec/fixtures/public_face_area_valid_multiple.xml
254
- - spec/fixtures/water_management_area_valid_multiple.xml
255
- - spec/fixtures/public_face_area_invalid_blank.xml
256
- - spec/fixtures/public_face_area_valid.xml
257
- - spec/fixtures/water_management_area_valid.xml
258
- - spec/fixtures/water_management_area_invalid_coords.xml
259
- - spec/fixtures/public_face_area_invalid_coords.xml
260
- - 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
@@ -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