defra_ruby_area 1.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +20 -11
  3. data/Rakefile +2 -2
  4. data/bin/console +3 -7
  5. data/lib/defra_ruby/area/area.rb +20 -7
  6. data/lib/defra_ruby/area/response.rb +3 -4
  7. data/lib/defra_ruby/area/services/base_area_service.rb +21 -20
  8. data/lib/defra_ruby/area/version.rb +1 -1
  9. data/spec/defra_ruby/area/area_spec.rb +25 -11
  10. data/spec/defra_ruby/area/response_spec.rb +11 -5
  11. data/spec/defra_ruby/area/services/public_face_area_service_spec.rb +43 -10
  12. data/spec/defra_ruby/area/services/water_management_area_service_spec.rb +43 -10
  13. data/spec/fixtures/public_face_area_invalid_blank.xml +5 -0
  14. data/spec/fixtures/public_face_area_invalid_coords.xml +8 -0
  15. data/spec/fixtures/public_face_area_valid.xml +18 -0
  16. data/spec/fixtures/public_face_area_valid_multiple.xml +28 -0
  17. data/spec/fixtures/water_management_area_invalid_blank.xml +5 -0
  18. data/spec/fixtures/water_management_area_invalid_coords.xml +8 -0
  19. data/spec/fixtures/water_management_area_valid.xml +20 -0
  20. data/spec/fixtures/water_management_area_valid_multiple.xml +32 -0
  21. data/spec/support/shared_examples/handle_request_errors.rb +2 -6
  22. metadata +31 -40
  23. data/spec/cassettes/public_face_area_invalid_blank.yml +0 -49
  24. data/spec/cassettes/public_face_area_invalid_coords.yml +0 -52
  25. data/spec/cassettes/public_face_area_valid.yml +0 -62
  26. data/spec/cassettes/water_management_area_invalid_blank.yml +0 -49
  27. data/spec/cassettes/water_management_area_invalid_coords.yml +0 -52
  28. data/spec/cassettes/water_management_area_valid.yml +0 -62
  29. data/spec/examples.txt +0 -24
  30. data/spec/support/vcr.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0c70a4243bf5fb3a988ebf2dee7ff7757758f605
4
- data.tar.gz: 6730c29aedc4227152101469d4325c36024f9522
2
+ SHA256:
3
+ metadata.gz: ae979716dbfa3c43991e2f21d67190c7bda4cfaef0dc5ae87dc2ac1beb746bae
4
+ data.tar.gz: df9ac3a40869869bd2bc32e2d9d713095cc529f84ff01aa1f7b31b18289d0108
5
5
  SHA512:
6
- metadata.gz: 85798b2577feb39b9853390f0bf243f271c4d7657a45769d88a1a35fea8cd38202b2b7a2a2464ee66ddda00207edf659d21c0b3a9adfed6e56fbc0fe430873b4
7
- data.tar.gz: bd9622f05d43ae590337b841d9e99b4e7e82ab327014ef2b6642fa87746daa085dbeb6b4640f82aac6f89d8c9245c15413a770c5a868a2d84c89e06f703ad9c3
6
+ metadata.gz: 89d81a16ac76041d7c92675b305da316863fe9bce4d592991198bd332cd27ee4f9912845e96c027687e4dc9467b06153cde550283fa3caa57e566a2a202bda48
7
+ data.tar.gz: 810ead2522a2fc25bd55b94917517cd597852405040dbe29ec2cb91883ef5e39affcffcee99b989daae27e7dd191358b2e85cfd0450a54526a169163f5dcc4a0
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Defra Ruby Area
2
2
 
3
- [![Build Status](https://travis-ci.com/DEFRA/defra-ruby-area.svg?branch=master)](https://travis-ci.com/DEFRA/defra-ruby-area)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/7aeffed0588d86a5e553/maintainability)](https://codeclimate.com/github/DEFRA/defra-ruby-area/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/7aeffed0588d86a5e553/test_coverage)](https://codeclimate.com/github/DEFRA/defra-ruby-area/test_coverage)
6
- [![security](https://hakiri.io/github/DEFRA/defra-ruby-area/master.svg)](https://hakiri.io/github/DEFRA/defra-ruby-area/master)
3
+ ![Build Status](https://github.com/DEFRA/defra-ruby-area/workflows/CI/badge.svg?branch=main)
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
+ [![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
7
  [![Gem Version](https://badge.fury.io/rb/defra_ruby_area.svg)](https://badge.fury.io/rb/defra_ruby_area)
8
8
  [![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
9
9
 
10
- This ruby gem provides a means of looking up an Environment Agency Administrative boundary from a GIS Web Feature Service (WFS). Provided with a valid [easting and northing](https://en.wikipedia.org/wiki/Easting_and_northing) it will query the WFS and return the long name for the area if a match is found.
10
+ This ruby gem provides a means of looking up Environment Agency Administrative boundary areas from a GIS Web Feature Service (WFS). Provided with a valid [easting and northing](https://en.wikipedia.org/wiki/Easting_and_northing) it will query the WFS and return various properties for each matching area found.
11
11
 
12
12
  ## Installation
13
13
 
@@ -33,20 +33,20 @@ Each WFS is called through a service that responds with a `DefraRuby::Area::Resp
33
33
 
34
34
  ```ruby
35
35
  response.successful?
36
- response.area
36
+ response.areas
37
37
  response.error
38
38
  ```
39
39
 
40
- If the call is successful (the query did not error and a match was found) then
40
+ If the call is successful then
41
41
 
42
42
  - `successful?()` will be `true`
43
- - `area` will contain an instance of `DefraRuby::Area::Area`. It contains the code, short name and long name of the matching administrative boundary
43
+ - `areas` will contain an array of `DefraRuby::Area::Area`. Each contains the area ID, area name, code, short name and long name of the matching administrative boundary
44
44
  - `error` will be `nil`
45
45
 
46
46
  If the call is unsuccessful (the query errored or no match was found) then
47
47
 
48
48
  - `successful?()` will be `false`
49
- - `area` will be `nil`
49
+ - `areas` will be `[]` (an empty array)
50
50
  - `error` will contain the error
51
51
 
52
52
  If it's a runtime error, or an error when calling the WFS `error` will contain whatever error was raised.
@@ -62,7 +62,7 @@ easting = 408_602.61
62
62
  northing = 257_535.31
63
63
  response = DefraRuby::Area::PublicFaceAreaService.run(easting, northing)
64
64
 
65
- puts response.area.long_name if response.successful? # West Midlands
65
+ puts response.areas.first.long_name if response.successful? # West Midlands
66
66
  ```
67
67
 
68
68
  ### Water Management Areas
@@ -74,9 +74,18 @@ easting = 408_602.61
74
74
  northing = 257_535.31
75
75
  response = DefraRuby::Area::WaterManagementAreaService.run(easting, northing)
76
76
 
77
- puts response.area.long_name if response.successful? # Staffordshire Warwickshire and West Midlands
77
+ puts response.areas.first.long_name if response.successful? # Staffordshire Warwickshire and West Midlands
78
78
  ```
79
79
 
80
+ ### Multiple results
81
+
82
+ In most cases we expect `response.areas` to contain a single result. It is possible though for a given easting and northing to return multiple administrative boundary areas. Where we see this is when a coordinate is on the boundary of 2 areas. This is why **defra-ruby-area** is setup to return multiple results.
83
+
84
+ Examples:
85
+
86
+ - **Public face areas** easting = `398056.684` and northing = `414748` (*Yorkshire* and *Greater Manchester Merseyside and Cheshire*)
87
+ - **Water management areas** easting = `456330` and northing = `267000` (*Lincolnshire and Northamptonshire* and *Staffordshire Warwickshire and West Midlands*)
88
+
80
89
  ## Web Feature Services
81
90
 
82
91
  A [Web Feature Service (WFS)](https://en.m.wikipedia.org/wiki/Web_Feature_Service) is simply a web service that implements the Open Geospatial Consortium Web Feature Service (WFS) Interface Standard.
data/Rakefile CHANGED
@@ -11,7 +11,6 @@ Bundler::GemHelper.install_tasks
11
11
  # This is wrapped to prevent an error when rake is called in environments where
12
12
  # rspec may not be available, e.g. production. As such we don't need to handle
13
13
  # the error.
14
- # rubocop:disable Lint/HandleExceptions
15
14
  begin
16
15
  require "rspec/core/rake_task"
17
16
 
@@ -26,8 +25,9 @@ begin
26
25
  require "github_changelog_generator/task"
27
26
 
28
27
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
28
+ config.user = "defra"
29
+ config.project = "defra-ruby-area"
29
30
  end
30
31
  rescue LoadError
31
32
  # no changelog available
32
33
  end
33
- # rubocop:enable Lint/HandleExceptions
data/bin/console CHANGED
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "defra/ruby/area"
4
+ require "defra_ruby/area"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
9
+ require "pry"
10
+ Pry.start
@@ -1,18 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "nokogiri"
4
+
3
5
  module DefraRuby
4
6
  module Area
5
7
  class Area
6
- attr_reader :code, :long_name, :short_name
8
+ attr_reader :area_id, :area_name, :code, :long_name, :short_name
9
+
10
+ def initialize(wfs_xml_element)
11
+ @xml = wfs_xml_element
12
+
13
+ validate_xml
14
+ parse_xml
15
+ end
16
+
17
+ private
7
18
 
8
- def initialize(code, long_name, short_name)
9
- @code = code
10
- @long_name = long_name
11
- @short_name = short_name
19
+ def validate_xml
20
+ raise(ArgumentError, "wfs_xml_element is invalid") unless @xml.is_a?(Nokogiri::XML::Element)
12
21
  end
13
22
 
14
- def matched?
15
- "#{@code}#{@long_name}#{@short_name}" != ""
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
16
29
  end
17
30
 
18
31
  end
@@ -3,12 +3,11 @@
3
3
  module DefraRuby
4
4
  module Area
5
5
  class Response
6
- attr_reader :error
7
- attr_reader :area
6
+ attr_reader :error, :areas
8
7
 
9
8
  def initialize(response_exe)
10
9
  @success = true
11
- @area = nil
10
+ @areas = []
12
11
  @error = nil
13
12
 
14
13
  capture_response(response_exe)
@@ -23,7 +22,7 @@ module DefraRuby
23
22
  attr_reader :success
24
23
 
25
24
  def capture_response(response_exe)
26
- @area = response_exe.call[:area]
25
+ @areas = response_exe.call[:areas]
27
26
  rescue StandardError => e
28
27
  @error = e
29
28
  @success = false
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
4
3
  require "rest-client"
5
4
 
6
5
  module DefraRuby
@@ -31,29 +30,25 @@ module DefraRuby
31
30
  url: url,
32
31
  timeout: DefraRuby::Area.configuration.timeout
33
32
  )
34
- area = parse_xml(response)
35
- raise NoMatchError unless area.matched?
33
+ areas = extract_areas(Nokogiri::XML(response))
36
34
 
37
- { area: area }
35
+ raise NoMatchError unless areas.any?
36
+
37
+ { areas: areas }
38
38
  end
39
39
  end
40
40
 
41
- def url
42
- "#{domain}/spatialdata/#{dataset}/wfs?#{url_params}"
43
- end
41
+ def extract_areas(xml_response)
42
+ areas = []
43
+ xml_response.xpath("//wfs:FeatureCollection/gml:featureMember").each do |parent|
44
+ areas << Area.new(parent.first_element_child)
45
+ end
44
46
 
45
- def parse_xml(response)
46
- xml = Nokogiri::XML(response)
47
- Area.new(
48
- xml.xpath(response_xml_path(:code)).text,
49
- xml.xpath(response_xml_path(:long_name)).text,
50
- xml.xpath(response_xml_path(:short_name)).text
51
- )
47
+ areas
52
48
  end
53
49
 
54
- # XML path to the value we wish to extract in the WFS query response.
55
- def response_xml_path(property)
56
- "//wfs:FeatureCollection/gml:featureMember/#{type_name}/ms:#{property}"
50
+ def url
51
+ "#{domain}/spatialdata/#{dataset}/wfs?#{url_params}"
57
52
  end
58
53
 
59
54
  # Domain where the WFS is hosted
@@ -130,10 +125,16 @@ module DefraRuby
130
125
  # https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType
131
126
  #
132
127
  # In our case the administrative boundary features contain a number of
133
- # properties, but we are only interested in +code+, +long_name+ and
134
- # +short_name+.
128
+ # properties, but we are only interested in
129
+ #
130
+ # - +area_id+
131
+ # - +area_name+
132
+ # - +code+
133
+ # - +long_name+
134
+ # - +short_name+
135
+ #
135
136
  def property_name
136
- "code,long_name,short_name"
137
+ "area_id,area_name,code,long_name,short_name"
137
138
  end
138
139
 
139
140
  # SRS stands for Spatial Reference System. It can also be known as a
@@ -2,6 +2,6 @@
2
2
 
3
3
  module DefraRuby
4
4
  module Area
5
- VERSION = "1.0.0"
5
+ VERSION = "2.0.2"
6
6
  end
7
7
  end
@@ -1,29 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
+ require "nokogiri"
4
5
 
5
6
  module DefraRuby
6
7
  module Area
7
8
  RSpec.describe Area do
8
- describe "#matched?" do
9
- context "when no attributes are populated" do
10
- let(:subject) { described_class.new(nil, nil, nil) }
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" }
11
14
 
12
- it "returns false" do
13
- expect(subject.matched?).to eq(false)
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")
14
25
  end
15
26
  end
16
- end
17
27
 
18
- describe "#matched?" do
19
- context "when at least one attribute is populated" do
20
- let(:subject) { described_class.new("foo", nil, nil) }
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)
21
31
 
22
- it "returns true" do
23
- expect(subject.matched?).to eq(true)
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")
24
37
  end
25
38
  end
26
39
  end
40
+
27
41
  end
28
42
  end
29
43
  end
@@ -6,7 +6,13 @@ module DefraRuby
6
6
  module Area
7
7
  RSpec.describe Response do
8
8
  subject(:response) { described_class.new(response_exe) }
9
- let(:successful) { -> { { area: Area.new("GFY", "Planet Gallifrey", "Gallifrey") } } }
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)] } } }
10
16
  let(:errored) { -> { raise "Boom!" } }
11
17
 
12
18
  describe "#successful?" do
@@ -18,7 +24,7 @@ module DefraRuby
18
24
  end
19
25
  end
20
26
 
21
- context "when the response don't throw an error" do
27
+ context "when the response doesn't throw an error" do
22
28
  let(:response_exe) { successful }
23
29
 
24
30
  it "returns true" do
@@ -32,7 +38,7 @@ module DefraRuby
32
38
  let(:response_exe) { errored }
33
39
 
34
40
  it "returns nothing" do
35
- expect(response.area).to be_nil
41
+ expect(response.areas).to be_empty
36
42
  end
37
43
  end
38
44
 
@@ -40,8 +46,8 @@ module DefraRuby
40
46
  let(:response_exe) { successful }
41
47
 
42
48
  it "returns an area" do
43
- expect(response.area).to be_instance_of(Area)
44
- expect(response.area.short_name).to eq("Gallifrey")
49
+ expect(response.areas[0]).to be_instance_of(Area)
50
+ expect(response.areas[0].short_name).to eq("Staffs Warks and West Mids")
45
51
  end
46
52
  end
47
53
  end
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "webmock/rspec"
3
4
  require "spec_helper"
4
5
 
5
6
  module DefraRuby
6
7
  module Area
7
8
  RSpec.describe PublicFaceAreaService do
8
- describe "#run" do
9
+ let(:host) { "https://environment.data.gov.uk" }
9
10
 
11
+ describe "#run" do
10
12
  context "when the coordinates are valid and in England" do
11
- before(:each) { VCR.insert_cassette("public_face_area_valid") }
12
- after(:each) { VCR.eject_cassette }
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
13
19
 
14
20
  let(:easting) { 408_602.61 }
15
21
  let(:northing) { 257_535.31 }
@@ -18,15 +24,38 @@ module DefraRuby
18
24
  response = described_class.run(easting, northing)
19
25
  expect(response).to be_a(Response)
20
26
  expect(response.successful?).to eq(true)
21
- expect(response.area.long_name).to eq("West Midlands")
27
+ expect(response.areas[0].long_name).to eq("West Midlands")
22
28
  end
23
29
 
24
30
  end
25
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
+
26
51
  context "when the coordinates are invalid" do
27
52
  context "because they are blank" do
28
- before(:each) { VCR.insert_cassette("public_face_area_invalid_blank") }
29
- after(:each) { VCR.eject_cassette }
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
30
59
 
31
60
  let(:easting) { nil }
32
61
  let(:northing) { nil }
@@ -35,14 +64,18 @@ module DefraRuby
35
64
  response = described_class.run(easting, northing)
36
65
  expect(response).to be_a(Response)
37
66
  expect(response).to_not be_successful
38
- expect(response.area).to be_nil
67
+ expect(response.areas).to be_empty
39
68
  expect(response.error).to_not be_nil
40
69
  end
41
70
  end
42
71
 
43
72
  context "because they are not in an area" do
44
- before(:each) { VCR.insert_cassette("public_face_area_invalid_coords") }
45
- after(:each) { VCR.eject_cassette }
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
46
79
 
47
80
  let(:easting) { 301_233.0 }
48
81
  let(:northing) { 221_592.0 }
@@ -51,7 +84,7 @@ module DefraRuby
51
84
  response = described_class.run(easting, northing)
52
85
  expect(response).to be_a(Response)
53
86
  expect(response).to_not be_successful
54
- expect(response.area).to be_nil
87
+ expect(response.areas).to be_empty
55
88
  expect(response.error).to_not be_nil
56
89
  end
57
90
  end
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "webmock/rspec"
3
4
  require "spec_helper"
4
5
 
5
6
  module DefraRuby
6
7
  module Area
7
8
  RSpec.describe WaterManagementAreaService do
8
- describe "#run" do
9
+ let(:host) { "https://environment.data.gov.uk" }
9
10
 
11
+ describe "#run" do
10
12
  context "when the coordinates are valid and in England" do
11
- before(:each) { VCR.insert_cassette("water_management_area_valid") }
12
- after(:each) { VCR.eject_cassette }
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
13
19
 
14
20
  let(:easting) { 408_602.61 }
15
21
  let(:northing) { 257_535.31 }
@@ -18,15 +24,38 @@ module DefraRuby
18
24
  response = described_class.run(easting, northing)
19
25
  expect(response).to be_a(Response)
20
26
  expect(response.successful?).to eq(true)
21
- expect(response.area.long_name).to eq("Staffordshire Warwickshire and West Midlands")
27
+ expect(response.areas[0].long_name).to eq("Staffordshire Warwickshire and West Midlands")
22
28
  end
23
29
 
24
30
  end
25
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
+
26
51
  context "when the coordinates are invalid" do
27
52
  context "because they are blank" do
28
- before(:each) { VCR.insert_cassette("water_management_area_invalid_blank") }
29
- after(:each) { VCR.eject_cassette }
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
30
59
 
31
60
  let(:easting) { nil }
32
61
  let(:northing) { nil }
@@ -35,14 +64,18 @@ module DefraRuby
35
64
  response = described_class.run(easting, northing)
36
65
  expect(response).to be_a(Response)
37
66
  expect(response).to_not be_successful
38
- expect(response.area).to be_nil
67
+ expect(response.areas).to be_empty
39
68
  expect(response.error).to_not be_nil
40
69
  end
41
70
  end
42
71
 
43
72
  context "because they are not in an area" do
44
- before(:each) { VCR.insert_cassette("water_management_area_invalid_coords") }
45
- after(:each) { VCR.eject_cassette }
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
46
79
 
47
80
  let(:easting) { 301_233.0 }
48
81
  let(:northing) { 221_592.0 }
@@ -51,7 +84,7 @@ module DefraRuby
51
84
  response = described_class.run(easting, northing)
52
85
  expect(response).to be_a(Response)
53
86
  expect(response).to_not be_successful
54
- expect(response.area).to be_nil
87
+ expect(response.areas).to be_empty
55
88
  expect(response.error).to_not be_nil
56
89
  end
57
90
  end
@@ -0,0 +1,5 @@
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>
@@ -0,0 +1,8 @@
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>
@@ -0,0 +1,18 @@
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>
@@ -0,0 +1,28 @@
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>
@@ -0,0 +1,5 @@
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>
@@ -0,0 +1,8 @@
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>
@@ -0,0 +1,20 @@
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>
@@ -0,0 +1,32 @@
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>
@@ -2,10 +2,6 @@
2
2
 
3
3
  RSpec.shared_examples "handle request errors" do
4
4
  context "when there is a problem with the Web Feature Service" do
5
- before(:each) { VCR.turn_off! }
6
- after(:each) { VCR.turn_on! }
7
-
8
- let(:host) { "https://environment.data.gov.uk/" }
9
5
  let(:easting) { 408_602.61 }
10
6
  let(:northing) { 257_535.31 }
11
7
 
@@ -16,7 +12,7 @@ RSpec.shared_examples "handle request errors" do
16
12
  response = described_class.run(easting, northing)
17
13
  expect(response).to be_a(DefraRuby::Area::Response)
18
14
  expect(response).to_not be_successful
19
- expect(response.area).to be_nil
15
+ expect(response.areas).to be_empty
20
16
  expect(response.error).to_not be_nil
21
17
  end
22
18
  end
@@ -28,7 +24,7 @@ RSpec.shared_examples "handle request errors" do
28
24
  response = described_class.run(easting, northing)
29
25
  expect(response).to be_a(DefraRuby::Area::Response)
30
26
  expect(response).to_not be_successful
31
- expect(response.area).to be_nil
27
+ expect(response.areas).to be_empty
32
28
  expect(response.error).to_not be_nil
33
29
  end
34
30
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defra_ruby_area
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Defra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-10 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.11.1
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 1.10.3
22
+ version: 1.13.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 1.10.3
29
+ version: 1.11.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 1.13.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rest-client
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -138,32 +144,18 @@ dependencies:
138
144
  version: '0'
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: simplecov
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: vcr
155
147
  requirement: !ruby/object:Gem::Requirement
156
148
  requirements:
157
149
  - - "~>"
158
150
  - !ruby/object:Gem::Version
159
- version: '4.0'
151
+ version: 0.17.1
160
152
  type: :development
161
153
  prerelease: false
162
154
  version_requirements: !ruby/object:Gem::Requirement
163
155
  requirements:
164
156
  - - "~>"
165
157
  - !ruby/object:Gem::Version
166
- version: '4.0'
158
+ version: 0.17.1
167
159
  - !ruby/object:Gem::Dependency
168
160
  name: webmock
169
161
  requirement: !ruby/object:Gem::Requirement
@@ -201,26 +193,26 @@ files:
201
193
  - lib/defra_ruby/area/services/public_face_area_service.rb
202
194
  - lib/defra_ruby/area/services/water_management_area_service.rb
203
195
  - lib/defra_ruby/area/version.rb
204
- - spec/cassettes/public_face_area_invalid_blank.yml
205
- - spec/cassettes/public_face_area_invalid_coords.yml
206
- - spec/cassettes/public_face_area_valid.yml
207
- - spec/cassettes/water_management_area_invalid_blank.yml
208
- - spec/cassettes/water_management_area_invalid_coords.yml
209
- - spec/cassettes/water_management_area_valid.yml
210
196
  - spec/defra_ruby/area/area_spec.rb
211
197
  - spec/defra_ruby/area/configuration_spec.rb
212
198
  - spec/defra_ruby/area/response_spec.rb
213
199
  - spec/defra_ruby/area/services/public_face_area_service_spec.rb
214
200
  - spec/defra_ruby/area/services/water_management_area_service_spec.rb
215
201
  - spec/defra_ruby/area_spec.rb
216
- - spec/examples.txt
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
217
210
  - spec/spec_helper.rb
218
211
  - spec/support/defra_ruby_area.rb
219
212
  - spec/support/dotenv.rb
220
213
  - spec/support/pry.rb
221
214
  - spec/support/shared_examples/handle_request_errors.rb
222
215
  - spec/support/simplecov.rb
223
- - spec/support/vcr.rb
224
216
  homepage: https://github.com/DEFRA/defra-ruby-area
225
217
  licenses:
226
218
  - The Open Government Licence (OGL) Version 3
@@ -241,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
233
  - !ruby/object:Gem::Version
242
234
  version: '0'
243
235
  requirements: []
244
- rubyforge_project:
245
- rubygems_version: 2.6.13
236
+ rubygems_version: 3.1.2
246
237
  signing_key:
247
238
  specification_version: 4
248
239
  summary: Defra ruby on rails EA administrative area lookup
@@ -254,16 +245,16 @@ test_files:
254
245
  - spec/defra_ruby/area/services/water_management_area_service_spec.rb
255
246
  - spec/defra_ruby/area/services/public_face_area_service_spec.rb
256
247
  - spec/defra_ruby/area_spec.rb
257
- - spec/examples.txt
258
- - spec/cassettes/water_management_area_invalid_coords.yml
259
- - spec/cassettes/public_face_area_invalid_coords.yml
260
- - spec/cassettes/water_management_area_invalid_blank.yml
261
- - spec/cassettes/public_face_area_valid.yml
262
- - spec/cassettes/water_management_area_valid.yml
263
- - spec/cassettes/public_face_area_invalid_blank.yml
264
248
  - spec/support/defra_ruby_area.rb
265
249
  - spec/support/simplecov.rb
266
- - spec/support/vcr.rb
267
250
  - spec/support/pry.rb
268
251
  - spec/support/dotenv.rb
269
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
@@ -1,49 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:26 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '349'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <ogc:ServiceExceptionReport xmlns:ogc="http://www.opengis.net/ogc" version="1.2.0">
44
- <ogc:ServiceException><![CDATA[The geometry was not recognized.]]></ogc:ServiceException>
45
- <ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
46
- </ogc:ServiceExceptionReport>
47
- http_version:
48
- recorded_at: Fri, 09 Aug 2019 17:08:26 GMT
49
- recorded_with: VCR 4.0.0
@@ -1,52 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:26 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '1070'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |-
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
44
- <gml:boundedBy>
45
- <gml:Box srsName="EPSG:27700">
46
- <gml:coordinates>0,0,0,0</gml:coordinates>
47
- </gml:Box>
48
- </gml:boundedBy>
49
- </wfs:FeatureCollection>
50
- http_version:
51
- recorded_at: Fri, 09 Aug 2019 17:08:26 GMT
52
- recorded_with: VCR 4.0.0
@@ -1,62 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:33 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '1693'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |-
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-environment-agency-and-natural-england-public-face-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
44
- <gml:boundedBy>
45
- <gml:Box srsName="EPSG:27700">
46
- <gml:coordinates>0,0,0,0</gml:coordinates>
47
- </gml:Box>
48
- </gml:boundedBy>
49
- <gml:featureMember>
50
- <ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas fid="Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas.23">
51
- <ms:OBJECTID>23</ms:OBJECTID>
52
- <ms:long_name>West Midlands</ms:long_name>
53
- <ms:short_name>West Midlands</ms:short_name>
54
- <ms:code>WMD</ms:code>
55
- <ms:st_area_shape_>14543741870.84492</ms:st_area_shape_>
56
- <ms:st_perimeter_shape_>1043376.795941756</ms:st_perimeter_shape_>
57
- </ms:Administrative_Boundaries_Environment_Agency_and_Natural_England_Public_Face_Areas>
58
- </gml:featureMember>
59
- </wfs:FeatureCollection>
60
- http_version:
61
- recorded_at: Fri, 09 Aug 2019 17:08:34 GMT
62
- recorded_with: VCR 4.0.0
@@ -1,49 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E,%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:21 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '349'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <ogc:ServiceExceptionReport xmlns:ogc="http://www.opengis.net/ogc" version="1.2.0">
44
- <ogc:ServiceException><![CDATA[The geometry was not recognized.]]></ogc:ServiceException>
45
- <ogc:ServiceException><![CDATA[Operator 'Intersects' can't parse geometry.]]></ogc:ServiceException>
46
- </ogc:ServiceExceptionReport>
47
- http_version:
48
- recorded_at: Fri, 09 Aug 2019 17:08:21 GMT
49
- recorded_with: VCR 4.0.0
@@ -1,52 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E301233.0,221592.0%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:14 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '968'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |-
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
44
- <gml:boundedBy>
45
- <gml:Box srsName="EPSG:27700">
46
- <gml:coordinates>0,0,0,0</gml:coordinates>
47
- </gml:Box>
48
- </gml:boundedBy>
49
- </wfs:FeatureCollection>
50
- http_version:
51
- recorded_at: Fri, 09 Aug 2019 17:08:14 GMT
52
- recorded_with: VCR 4.0.0
@@ -1,62 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?Filter=(%3CFilter%3E%3CIntersects%3E%3CPropertyName%3ESHAPE%3C/PropertyName%3E%3Cgml:Point%3E%3Cgml:coordinates%3E408602.61,257535.31%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Intersects%3E%3C/Filter%3E)&REQUEST=GetFeature&SERVICE=WFS&SRSName=EPSG:27700&VERSION=1.0.0&propertyName=code,long_name,short_name&typeName=ms:Administrative_Boundaries_Water_Management_Areas
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - rest-client/2.0.2 (darwin18.2.0 x86_64) ruby/2.4.2p198
16
- Host:
17
- - environment.data.gov.uk
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 09 Aug 2019 17:08:14 GMT
27
- Content-Type:
28
- - application/xml
29
- Content-Length:
30
- - '1530'
31
- Connection:
32
- - keep-alive
33
- Cache-Control:
34
- - private
35
- X-Aspnet-Version:
36
- - 4.0.30319
37
- X-Powered-By:
38
- - ASP.NET
39
- body:
40
- encoding: UTF-8
41
- string: |-
42
- <?xml version="1.0" encoding="utf-8" ?>
43
- <wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs https://environment.data.gov.uk/spatialdata/administrative-boundaries-water-management-areas/wfs?service=wfs%26version=1.0.0%26request=DescribeFeatureType">
44
- <gml:boundedBy>
45
- <gml:Box srsName="EPSG:27700">
46
- <gml:coordinates>0,0,0,0</gml:coordinates>
47
- </gml:Box>
48
- </gml:boundedBy>
49
- <gml:featureMember>
50
- <ms:Administrative_Boundaries_Water_Management_Areas fid="Administrative_Boundaries_Water_Management_Areas.15">
51
- <ms:OBJECTID>15</ms:OBJECTID>
52
- <ms:long_name>Staffordshire Warwickshire and West Midlands</ms:long_name>
53
- <ms:short_name>Staffs Warks and West Mids</ms:short_name>
54
- <ms:code>STWKWM</ms:code>
55
- <ms:st_area_shape_>6460280400.1</ms:st_area_shape_>
56
- <ms:st_perimeter_shape_>759189.708848595</ms:st_perimeter_shape_>
57
- </ms:Administrative_Boundaries_Water_Management_Areas>
58
- </gml:featureMember>
59
- </wfs:FeatureCollection>
60
- http_version:
61
- recorded_at: Fri, 09 Aug 2019 17:08:14 GMT
62
- recorded_with: VCR 4.0.0
data/spec/examples.txt DELETED
@@ -1,24 +0,0 @@
1
- example_id | status | run_time |
2
- -------------------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/defra_ruby/area/area_spec.rb[1:1:1:1] | passed | 0.00027 seconds |
4
- ./spec/defra_ruby/area/area_spec.rb[1:2:1:1] | passed | 0.00024 seconds |
5
- ./spec/defra_ruby/area/configuration_spec.rb[1:1] | passed | 0.00337 seconds |
6
- ./spec/defra_ruby/area/response_spec.rb[1:1:1:1] | passed | 0.00025 seconds |
7
- ./spec/defra_ruby/area/response_spec.rb[1:1:2:1] | passed | 0.00412 seconds |
8
- ./spec/defra_ruby/area/response_spec.rb[1:2:1:1] | passed | 0.00017 seconds |
9
- ./spec/defra_ruby/area/response_spec.rb[1:2:2:1] | passed | 0.00725 seconds |
10
- ./spec/defra_ruby/area/response_spec.rb[1:3:1:1] | passed | 0.0029 seconds |
11
- ./spec/defra_ruby/area/response_spec.rb[1:3:2:1] | passed | 0.00023 seconds |
12
- ./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:1:1] | passed | 0.03685 seconds |
13
- ./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:1:1] | passed | 0.06383 seconds |
14
- ./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:2:2:1] | passed | 0.03793 seconds |
15
- ./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:1:1] | passed | 0.06819 seconds |
16
- ./spec/defra_ruby/area/services/public_face_area_service_spec.rb[1:1:3:2:1] | passed | 0.02928 seconds |
17
- ./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:1:1] | passed | 0.03675 seconds |
18
- ./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:1:1] | passed | 0.03188 seconds |
19
- ./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:2:2:1] | passed | 0.03399 seconds |
20
- ./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:1:1] | passed | 0.02733 seconds |
21
- ./spec/defra_ruby/area/services/water_management_area_service_spec.rb[1:1:3:2:1] | passed | 0.04418 seconds |
22
- ./spec/defra_ruby/area_spec.rb[1:1:1] | passed | 0.00637 seconds |
23
- ./spec/defra_ruby/area_spec.rb[1:2:1:1] | passed | 0.00344 seconds |
24
- ./spec/defra_ruby/area_spec.rb[1:2:2:1] | passed | 0.00018 seconds |
data/spec/support/vcr.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Stubbing HTTP requests
4
- require "webmock/rspec"
5
- # Auto generate fake responses for web-requests
6
- require "vcr"
7
-
8
- VCR.configure do |c|
9
- c.cassette_library_dir = "spec/cassettes"
10
- c.hook_into :webmock
11
-
12
- c.ignore_hosts "127.0.0.1", "codeclimate.com"
13
-
14
- SECONDS_IN_DAY = 24 * 60 * 60
15
-
16
- c.default_cassette_options = { re_record_interval: (14 * SECONDS_IN_DAY) }
17
- end