defra_ruby_address 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +8 -0
- data/README.md +233 -0
- data/Rakefile +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/defra_ruby.rb +7 -0
- data/lib/defra_ruby/address.rb +28 -0
- data/lib/defra_ruby/address/configuration.rb +15 -0
- data/lib/defra_ruby/address/ea_address_facade_request.rb +49 -0
- data/lib/defra_ruby/address/no_match_error.rb +11 -0
- data/lib/defra_ruby/address/response.rb +33 -0
- data/lib/defra_ruby/address/services/base_service.rb +14 -0
- data/lib/defra_ruby/address/services/ea_address_facade_v1_1_service.rb +16 -0
- data/lib/defra_ruby/address/services/ea_address_facade_v1_service.rb +16 -0
- data/lib/defra_ruby/address/services/os_places_address_lookup_service.rb +51 -0
- data/lib/defra_ruby/address/version.rb +7 -0
- data/spec/defra_ruby/address/configuration_spec.rb +18 -0
- data/spec/defra_ruby/address/response_spec.rb +70 -0
- data/spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb +73 -0
- data/spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb +73 -0
- data/spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb +72 -0
- data/spec/defra_ruby/address_spec.rb +30 -0
- data/spec/examples.txt +27 -0
- data/spec/fixtures/ea_address_facade_v1_1_blank.json +8 -0
- data/spec/fixtures/ea_address_facade_v1_1_not_found.json +14 -0
- data/spec/fixtures/ea_address_facade_v1_1_valid.json +83 -0
- data/spec/fixtures/ea_address_facade_v1_blank.json +13 -0
- data/spec/fixtures/ea_address_facade_v1_not_found.json +8 -0
- data/spec/fixtures/ea_address_facade_v1_valid.json +45 -0
- data/spec/fixtures/os_places_address_lookup_blank.json +5 -0
- data/spec/fixtures/os_places_address_lookup_not_found.json +6 -0
- data/spec/fixtures/os_places_address_lookup_valid.json +56 -0
- data/spec/spec_helper.rb +83 -0
- data/spec/support/defra_ruby_address.rb +4 -0
- data/spec/support/dotenv.rb +4 -0
- data/spec/support/pry.rb +7 -0
- data/spec/support/shared_examples/handle_request_errors.rb +32 -0
- data/spec/support/simplecov.rb +17 -0
- data/spec/support/webmock.rb +4 -0
- metadata +248 -0
data/spec/examples.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
-------------------------------------------------------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/defra_ruby/address/configuration_spec.rb[1:1] | passed | 0.00888 seconds |
|
4
|
+
./spec/defra_ruby/address/response_spec.rb[1:1:1:1] | passed | 0.00013 seconds |
|
5
|
+
./spec/defra_ruby/address/response_spec.rb[1:1:2:1] | passed | 0.0003 seconds |
|
6
|
+
./spec/defra_ruby/address/response_spec.rb[1:2:1:1] | passed | 0.0001 seconds |
|
7
|
+
./spec/defra_ruby/address/response_spec.rb[1:2:2:1] | passed | 0.00014 seconds |
|
8
|
+
./spec/defra_ruby/address/response_spec.rb[1:3:1:1] | passed | 0.00011 seconds |
|
9
|
+
./spec/defra_ruby/address/response_spec.rb[1:3:2:1] | passed | 0.0001 seconds |
|
10
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb[1:1:1:1:1] | passed | 0.00301 seconds |
|
11
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb[1:1:1:2:1] | passed | 0.00311 seconds |
|
12
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb[1:1:2:1] | passed | 0.01005 seconds |
|
13
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb[1:1:3:1:1] | passed | 0.01183 seconds |
|
14
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb[1:1:3:2:1] | passed | 0.00571 seconds |
|
15
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb[1:1:1:1:1] | passed | 0.00323 seconds |
|
16
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb[1:1:1:2:1] | passed | 0.00337 seconds |
|
17
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb[1:1:2:1] | passed | 0.02025 seconds |
|
18
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb[1:1:3:1:1] | passed | 0.0075 seconds |
|
19
|
+
./spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb[1:1:3:2:1] | passed | 0.00576 seconds |
|
20
|
+
./spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb[1:1:1:1:1] | passed | 0.0035 seconds |
|
21
|
+
./spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb[1:1:1:2:1] | passed | 0.00558 seconds |
|
22
|
+
./spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb[1:1:2:1] | passed | 0.0041 seconds |
|
23
|
+
./spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb[1:1:3:1:1] | passed | 0.00572 seconds |
|
24
|
+
./spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb[1:1:3:2:1] | passed | 0.00559 seconds |
|
25
|
+
./spec/defra_ruby/address_spec.rb[1:1:1] | passed | 0.00494 seconds |
|
26
|
+
./spec/defra_ruby/address_spec.rb[1:2:1:1] | passed | 0.00262 seconds |
|
27
|
+
./spec/defra_ruby/address_spec.rb[1:2:2:1] | passed | 0.00014 seconds |
|
@@ -0,0 +1,8 @@
|
|
1
|
+
{
|
2
|
+
"facade_status_code": 400,
|
3
|
+
"facade_error_message": "bad request to facade service, no request made to supplier service. required paramater missing.",
|
4
|
+
"facade_error_code": "address_service_error_13",
|
5
|
+
"supplier_was_called": false,
|
6
|
+
"supplier_status_code": null,
|
7
|
+
"supplier_response": null
|
8
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"header": {
|
3
|
+
"totalMatches": 0,
|
4
|
+
"startMatch": null,
|
5
|
+
"endMatch": null,
|
6
|
+
"query": "postcode=BS1 9XX",
|
7
|
+
"language": "EN",
|
8
|
+
"dataset": "DPA",
|
9
|
+
"epoch": "70",
|
10
|
+
"uriToSupplier": "https://api.ordnancesurvey.co.uk/places/v1/addresses/postcode?lr=EN&postcode=BS1%209XX&fq=logical_status_code%3A1&dataset=DPA",
|
11
|
+
"uriFromClient": ""
|
12
|
+
},
|
13
|
+
"results": []
|
14
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
{
|
2
|
+
"header": {
|
3
|
+
"totalMatches": 2,
|
4
|
+
"startMatch": 1,
|
5
|
+
"endMatch": 2,
|
6
|
+
"query": "postcode=BS1 5AH",
|
7
|
+
"language": "EN",
|
8
|
+
"dataset": "DPA",
|
9
|
+
"epoch": "70",
|
10
|
+
"uriToSupplier": "https://api.ordnancesurvey.co.uk/places/v1/addresses/postcode?lr=EN&postcode=BS1%205AH&fq=logical_status_code%3A1&dataset=DPA",
|
11
|
+
"uriFromClient": ""
|
12
|
+
},
|
13
|
+
"results": [
|
14
|
+
{
|
15
|
+
"uprn": 340116,
|
16
|
+
"address": "ENVIRONMENT AGENCY, HORIZON HOUSE, DEANERY ROAD, BRISTOL, BS1 5AH",
|
17
|
+
"organisation": "ENVIRONMENT AGENCY",
|
18
|
+
"premises": "HORIZON HOUSE",
|
19
|
+
"street_address": "DEANERY ROAD",
|
20
|
+
"locality": null,
|
21
|
+
"city": "BRISTOL",
|
22
|
+
"postcode": "BS1 5AH",
|
23
|
+
"country": "United Kingdom",
|
24
|
+
"x": 358205.03,
|
25
|
+
"y": 172708.06,
|
26
|
+
"coordinate_system": null,
|
27
|
+
"blpu_state_date": "12/10/2009",
|
28
|
+
"blpu_state_code": 2,
|
29
|
+
"postal_address_code": "D",
|
30
|
+
"logical_status_code": 1,
|
31
|
+
"source_data_type": "dpa",
|
32
|
+
"blpu_state_code_description": "In use",
|
33
|
+
"classification_code": "CO01",
|
34
|
+
"classification_code_description": "Office / Work Studio",
|
35
|
+
"lpi_logical_status_code": null,
|
36
|
+
"lpi_logical_status_code_description": null,
|
37
|
+
"match": 1.0,
|
38
|
+
"match_description": "EXACT",
|
39
|
+
"topography_layer_toid": "osgb1000002529079737",
|
40
|
+
"parent_uprn": null,
|
41
|
+
"last_update_date": "10/02/2016",
|
42
|
+
"status": "APPROVED",
|
43
|
+
"entry_date": "12/10/2009",
|
44
|
+
"postal_address_code_description": "A record which is linked to PAF",
|
45
|
+
"usrn": null,
|
46
|
+
"language": "EN"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"uprn": 340117,
|
50
|
+
"address": "THRIVE RENEWABLES PLC, DEANERY ROAD, BRISTOL, BS1 5AH",
|
51
|
+
"organisation": "THRIVE RENEWABLES PLC",
|
52
|
+
"premises": null,
|
53
|
+
"street_address": "DEANERY ROAD",
|
54
|
+
"locality": null,
|
55
|
+
"city": "BRISTOL",
|
56
|
+
"postcode": "BS1 5AH",
|
57
|
+
"country": "United Kingdom",
|
58
|
+
"x": 358130.1,
|
59
|
+
"y": 172687.88,
|
60
|
+
"coordinate_system": null,
|
61
|
+
"blpu_state_date": "12/10/2009",
|
62
|
+
"blpu_state_code": 2,
|
63
|
+
"postal_address_code": "D",
|
64
|
+
"logical_status_code": 1,
|
65
|
+
"source_data_type": "dpa",
|
66
|
+
"blpu_state_code_description": "In use",
|
67
|
+
"classification_code": "CO01",
|
68
|
+
"classification_code_description": "Office / Work Studio",
|
69
|
+
"lpi_logical_status_code": null,
|
70
|
+
"lpi_logical_status_code_description": null,
|
71
|
+
"match": 1.0,
|
72
|
+
"match_description": "EXACT",
|
73
|
+
"topography_layer_toid": "osgb1000002529079753",
|
74
|
+
"parent_uprn": null,
|
75
|
+
"last_update_date": "14/03/2019",
|
76
|
+
"status": "APPROVED",
|
77
|
+
"entry_date": "12/10/2009",
|
78
|
+
"postal_address_code_description": "A record which is linked to PAF",
|
79
|
+
"usrn": null,
|
80
|
+
"language": "EN"
|
81
|
+
}
|
82
|
+
]
|
83
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"facade_status_code": 400,
|
3
|
+
"facade_error_message": "bad request to supplier service",
|
4
|
+
"facade_error_code": "address_service_error_1",
|
5
|
+
"supplier_was_called": true,
|
6
|
+
"supplier_status_code": 400,
|
7
|
+
"supplier_response": {
|
8
|
+
"error": {
|
9
|
+
"statuscode": 400,
|
10
|
+
"message": "Parameter postcode cannot be empty."
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"totalMatches": 2,
|
3
|
+
"startMatch": 1,
|
4
|
+
"endMatch": 2,
|
5
|
+
"uri_to_supplier": "https://api.ordnancesurvey.co.uk/places/v1/addresses/postcode?lr=EN&postcode=bs15ah&maxresults=100&dataset=DPA",
|
6
|
+
"uri_from_client": "stub",
|
7
|
+
"results": [
|
8
|
+
{
|
9
|
+
"uprn": 340116,
|
10
|
+
"address": "ENVIRONMENT AGENCY, HORIZON HOUSE, DEANERY ROAD, BRISTOL, BS1 5AH",
|
11
|
+
"organisation": "ENVIRONMENT AGENCY",
|
12
|
+
"premises": "HORIZON HOUSE",
|
13
|
+
"street_address": "DEANERY ROAD",
|
14
|
+
"locality": null,
|
15
|
+
"city": "BRISTOL",
|
16
|
+
"postcode": "BS1 5AH",
|
17
|
+
"x": "358205.03",
|
18
|
+
"y": "172708.07",
|
19
|
+
"coordinate_system": null,
|
20
|
+
"state_date": "12/10/2009",
|
21
|
+
"blpu_state_code": null,
|
22
|
+
"postal_address_code": null,
|
23
|
+
"logical_status_code": null,
|
24
|
+
"source_data_type": "dpa"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"uprn": 340117,
|
28
|
+
"address": "THRIVE RENEWABLES PLC, DEANERY ROAD, BRISTOL, BS1 5AH",
|
29
|
+
"organisation": "THRIVE RENEWABLES PLC",
|
30
|
+
"premises": null,
|
31
|
+
"street_address": "DEANERY ROAD",
|
32
|
+
"locality": null,
|
33
|
+
"city": "BRISTOL",
|
34
|
+
"postcode": "BS1 5AH",
|
35
|
+
"x": "358130.1",
|
36
|
+
"y": "172687.87",
|
37
|
+
"coordinate_system": null,
|
38
|
+
"state_date": "12/10/2009",
|
39
|
+
"blpu_state_code": null,
|
40
|
+
"postal_address_code": null,
|
41
|
+
"logical_status_code": null,
|
42
|
+
"source_data_type": "dpa"
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"moniker": "340116",
|
4
|
+
"uprn": "340116",
|
5
|
+
"lines": [
|
6
|
+
"ENVIRONMENT AGENCY",
|
7
|
+
"DEANERY ROAD"
|
8
|
+
],
|
9
|
+
"town": "BRISTOL",
|
10
|
+
"postcode": "BS1 5AH",
|
11
|
+
"easting": "358205",
|
12
|
+
"northing": "172708",
|
13
|
+
"country": "",
|
14
|
+
"dependentLocality": "",
|
15
|
+
"dependentThroughfare": "",
|
16
|
+
"administrativeArea": "BRISTOL",
|
17
|
+
"localAuthorityUpdateDate": "",
|
18
|
+
"royalMailUpdateDate": "",
|
19
|
+
"partial": "ENVIRONMENT AGENCY, HORIZON HOUSE, DEANERY ROAD, BRISTOL, BS1 5AH",
|
20
|
+
"subBuildingName": "",
|
21
|
+
"buildingName": "HORIZON HOUSE",
|
22
|
+
"thoroughfareName": "DEANERY ROAD",
|
23
|
+
"organisationName": "ENVIRONMENT AGENCY",
|
24
|
+
"buildingNumber": "",
|
25
|
+
"postOfficeBoxNumber": "",
|
26
|
+
"departmentName": "",
|
27
|
+
"doubleDependentLocality": ""
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"moniker": "340117",
|
31
|
+
"uprn": "340117",
|
32
|
+
"lines": [
|
33
|
+
"THRIVE RENEWABLES PLC",
|
34
|
+
"DEANERY ROAD"
|
35
|
+
],
|
36
|
+
"town": "BRISTOL",
|
37
|
+
"postcode": "BS1 5AH",
|
38
|
+
"easting": "358130",
|
39
|
+
"northing": "172687",
|
40
|
+
"country": "",
|
41
|
+
"dependentLocality": "",
|
42
|
+
"dependentThroughfare": "",
|
43
|
+
"administrativeArea": "BRISTOL",
|
44
|
+
"localAuthorityUpdateDate": "",
|
45
|
+
"royalMailUpdateDate": "",
|
46
|
+
"partial": "THRIVE RENEWABLES PLC, DEANERY ROAD, BRISTOL, BS1 5AH",
|
47
|
+
"subBuildingName": "",
|
48
|
+
"buildingName": "",
|
49
|
+
"thoroughfareName": "DEANERY ROAD",
|
50
|
+
"organisationName": "THRIVE RENEWABLES PLC",
|
51
|
+
"buildingNumber": "",
|
52
|
+
"postOfficeBoxNumber": "",
|
53
|
+
"departmentName": "",
|
54
|
+
"doubleDependentLocality": ""
|
55
|
+
}
|
56
|
+
]
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
# Require and run our simplecov initializer as the very first thing we do.
|
6
|
+
# This is as per its docs https://github.com/colszowka/simplecov#getting-started
|
7
|
+
require "./spec/support/simplecov"
|
8
|
+
|
9
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
10
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
11
|
+
# run as spec files by default. This means that files in spec/support that end
|
12
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
13
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
14
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
15
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
16
|
+
#
|
17
|
+
# We make an exception for simplecov because that will already have been
|
18
|
+
# required and run at the very top of spec_helper.rb
|
19
|
+
support_files = Dir["./spec/support/**/*.rb"].reject { |file| file == "./spec/support/simplecov.rb" }
|
20
|
+
support_files.each { |f| require f }
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# rspec-expectations config goes here. You can use an alternate
|
24
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
25
|
+
# assertions if you prefer.
|
26
|
+
config.expect_with :rspec do |expectations|
|
27
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
28
|
+
# and `failure_message` of custom matchers include text for helper methods
|
29
|
+
# defined using `chain`, e.g.:
|
30
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
31
|
+
# # => "be bigger than 2 and smaller than 4"
|
32
|
+
# ...rather than:
|
33
|
+
# # => "be bigger than 2"
|
34
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
35
|
+
end
|
36
|
+
|
37
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
38
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
39
|
+
config.mock_with :rspec do |mocks|
|
40
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
41
|
+
# a real object. This is generally recommended, and will default to
|
42
|
+
# `true` in RSpec 4.
|
43
|
+
mocks.verify_partial_doubles = true
|
44
|
+
end
|
45
|
+
|
46
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
47
|
+
# have no way to turn it off -- the option exists only for backwards
|
48
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
49
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
50
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
51
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
52
|
+
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# Run specs in random order to surface order dependencies. If you find an
|
73
|
+
# order dependency and want to debug it, you can fix the order by providing
|
74
|
+
# the seed, which is printed after each run.
|
75
|
+
# --seed 1234
|
76
|
+
config.order = :random
|
77
|
+
|
78
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
79
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
80
|
+
# test failures related to randomization by passing the same `--seed` value
|
81
|
+
# as the one that triggered the failure.
|
82
|
+
Kernel.srand config.seed
|
83
|
+
end
|
data/spec/support/pry.rb
ADDED
@@ -0,0 +1,7 @@
|
|
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"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples "handle request errors" do
|
4
|
+
context "when there is a problem with the address lookup" do
|
5
|
+
|
6
|
+
context "and the request times out" do
|
7
|
+
before { stub_request(:get, url).to_timeout }
|
8
|
+
|
9
|
+
it "returns a failed response" do
|
10
|
+
response = described_class.run(postcode)
|
11
|
+
|
12
|
+
expect(response).to be_a(DefraRuby::Address::Response)
|
13
|
+
expect(response).to_not be_successful
|
14
|
+
expect(response.results).to be_empty
|
15
|
+
expect(response.error).to_not be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "and the request returns an error" do
|
20
|
+
before { stub_request(:get, url).to_raise(SocketError) }
|
21
|
+
|
22
|
+
it "returns a failed response" do
|
23
|
+
response = described_class.run(postcode)
|
24
|
+
|
25
|
+
expect(response).to be_a(DefraRuby::Address::Response)
|
26
|
+
expect(response).to_not be_successful
|
27
|
+
expect(response.results).to be_empty
|
28
|
+
expect(response.error).to_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: defra_ruby_address
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Defra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: defra_ruby_style
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: github_changelog_generator
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.4'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.4'
|
153
|
+
description: Provides a single source of functionality for querying Defra's various
|
154
|
+
address lookup services.
|
155
|
+
email:
|
156
|
+
- alan.cruikshanks@environment-agency.gov.uk
|
157
|
+
executables: []
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- LICENSE
|
162
|
+
- README.md
|
163
|
+
- Rakefile
|
164
|
+
- bin/console
|
165
|
+
- bin/setup
|
166
|
+
- lib/defra_ruby.rb
|
167
|
+
- lib/defra_ruby/address.rb
|
168
|
+
- lib/defra_ruby/address/configuration.rb
|
169
|
+
- lib/defra_ruby/address/ea_address_facade_request.rb
|
170
|
+
- lib/defra_ruby/address/no_match_error.rb
|
171
|
+
- lib/defra_ruby/address/response.rb
|
172
|
+
- lib/defra_ruby/address/services/base_service.rb
|
173
|
+
- lib/defra_ruby/address/services/ea_address_facade_v1_1_service.rb
|
174
|
+
- lib/defra_ruby/address/services/ea_address_facade_v1_service.rb
|
175
|
+
- lib/defra_ruby/address/services/os_places_address_lookup_service.rb
|
176
|
+
- lib/defra_ruby/address/version.rb
|
177
|
+
- spec/defra_ruby/address/configuration_spec.rb
|
178
|
+
- spec/defra_ruby/address/response_spec.rb
|
179
|
+
- spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb
|
180
|
+
- spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb
|
181
|
+
- spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb
|
182
|
+
- spec/defra_ruby/address_spec.rb
|
183
|
+
- spec/examples.txt
|
184
|
+
- spec/fixtures/ea_address_facade_v1_1_blank.json
|
185
|
+
- spec/fixtures/ea_address_facade_v1_1_not_found.json
|
186
|
+
- spec/fixtures/ea_address_facade_v1_1_valid.json
|
187
|
+
- spec/fixtures/ea_address_facade_v1_blank.json
|
188
|
+
- spec/fixtures/ea_address_facade_v1_not_found.json
|
189
|
+
- spec/fixtures/ea_address_facade_v1_valid.json
|
190
|
+
- spec/fixtures/os_places_address_lookup_blank.json
|
191
|
+
- spec/fixtures/os_places_address_lookup_not_found.json
|
192
|
+
- spec/fixtures/os_places_address_lookup_valid.json
|
193
|
+
- spec/spec_helper.rb
|
194
|
+
- spec/support/defra_ruby_address.rb
|
195
|
+
- spec/support/dotenv.rb
|
196
|
+
- spec/support/pry.rb
|
197
|
+
- spec/support/shared_examples/handle_request_errors.rb
|
198
|
+
- spec/support/simplecov.rb
|
199
|
+
- spec/support/webmock.rb
|
200
|
+
homepage: https://github.com/DEFRA/defra-ruby-address
|
201
|
+
licenses:
|
202
|
+
- The Open Government Licence (OGL) Version 3
|
203
|
+
metadata:
|
204
|
+
allowed_push_host: https://rubygems.org
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.6.13
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Defra ruby on rails address lookup gem
|
225
|
+
test_files:
|
226
|
+
- spec/spec_helper.rb
|
227
|
+
- spec/defra_ruby/address/configuration_spec.rb
|
228
|
+
- spec/defra_ruby/address/response_spec.rb
|
229
|
+
- spec/defra_ruby/address/services/os_places_address_lookup_service_spec.rb
|
230
|
+
- spec/defra_ruby/address/services/ea_address_facade_v1_service_spec.rb
|
231
|
+
- spec/defra_ruby/address/services/ea_address_facade_v1_1_service_spec.rb
|
232
|
+
- spec/defra_ruby/address_spec.rb
|
233
|
+
- spec/examples.txt
|
234
|
+
- spec/support/defra_ruby_address.rb
|
235
|
+
- spec/support/simplecov.rb
|
236
|
+
- spec/support/webmock.rb
|
237
|
+
- spec/support/pry.rb
|
238
|
+
- spec/support/dotenv.rb
|
239
|
+
- spec/support/shared_examples/handle_request_errors.rb
|
240
|
+
- spec/fixtures/ea_address_facade_v1_1_not_found.json
|
241
|
+
- spec/fixtures/os_places_address_lookup_blank.json
|
242
|
+
- spec/fixtures/ea_address_facade_v1_1_valid.json
|
243
|
+
- spec/fixtures/ea_address_facade_v1_valid.json
|
244
|
+
- spec/fixtures/ea_address_facade_v1_blank.json
|
245
|
+
- spec/fixtures/ea_address_facade_v1_1_blank.json
|
246
|
+
- spec/fixtures/os_places_address_lookup_valid.json
|
247
|
+
- spec/fixtures/ea_address_facade_v1_not_found.json
|
248
|
+
- spec/fixtures/os_places_address_lookup_not_found.json
|