my_society-map_it 0.0.5 → 0.0.6
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.
- data/Gemfile +3 -0
- data/README.md +7 -1
- data/Rakefile +10 -2
- data/lib/my_society/map_it.rb +93 -14
- data/lib/my_society/map_it/version.rb +1 -1
- data/my_society-map_it.gemspec +5 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/gives_a_correct_gss_code_for_a_ward.yml +184 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/gives_a_correct_lat/lng_for_a_postcode.yml +193 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/gives_a_correct_ward.yml +184 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/single_tier/correctly_identifies_a_single_tier_local_authority.yml +355 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/single_tier/returns_the_correct_local_authority.yml +355 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/single_tier/returns_the_correct_local_authority_gss_code.yml +355 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/correctly_identifies_a_two_tier_local_authority.yml +727 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/gives_a_correct_county_council.yml +365 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/gives_a_correct_county_council_gss_code.yml +365 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/gives_a_correct_district_council.yml +184 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/gives_a_correct_district_council_gss_code.yml +184 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/two_tier/returns_a_hash_when_asked_for_a_local_authority.yml +727 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/with_parish/returns_the_correct_parish.yml +184 -0
- data/spec/cassettes/MySociety_MapIt_Postcode/without_parish/returns_the_nil_for_a_parish.yml +179 -0
- data/spec/postcode_spec.rb +96 -0
- data/spec/spec_helper.rb +23 -0
- metadata +101 -5
@@ -0,0 +1,184 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://mapit.mysociety.org/postcode/B463LD
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
accept:
|
11
|
+
- ! '*/*'
|
12
|
+
user-agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
expires:
|
20
|
+
- Tue, 15 Oct 2013 13:20:51 GMT
|
21
|
+
vary:
|
22
|
+
- Cookie,Accept-Encoding
|
23
|
+
etag:
|
24
|
+
- ! '"40eca97e347e9ac2c1ce9caca6bfb5a2;gzip"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=2419200
|
27
|
+
access-control-allow-origin:
|
28
|
+
- ! '*'
|
29
|
+
last-modified:
|
30
|
+
- Tue, 17 Sep 2013 13:20:51 GMT
|
31
|
+
content-type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
x-url:
|
34
|
+
- /postcode/B463LD
|
35
|
+
transfer-encoding:
|
36
|
+
- chunked
|
37
|
+
date:
|
38
|
+
- Tue, 17 Sep 2013 14:44:17 GMT
|
39
|
+
age:
|
40
|
+
- '5006'
|
41
|
+
connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '{"wgs84_lat": 52.496789409955881, "coordsyst": "G", "shortcuts":
|
46
|
+
{"WMC": 66024, "ward": {"county": 15881, "district": 7606}, "council": {"county":
|
47
|
+
2243, "district": 2458}}, "wgs84_lon": -1.706805276569471, "postcode": "B46
|
48
|
+
3LD", "easting": 420002, "areas": {"40352": {"parent_area": null, "generation_high":
|
49
|
+
20, "all_names": {}, "id": 40352, "codes": {"ons": "E02006473"}, "name": "North
|
50
|
+
Warwickshire 006", "country": "E", "type_name": "Middle Layer Super Output
|
51
|
+
Area (Full)", "generation_low": 13, "country_name": "England", "type": "OMF"},
|
52
|
+
"11809": {"parent_area": null, "generation_high": 20, "all_names": {}, "id":
|
53
|
+
11809, "codes": {"ons": "05", "gss": "E15000005", "unit_id": "41426"}, "name":
|
54
|
+
"West Midlands", "country": "E", "type_name": "European region", "generation_low":
|
55
|
+
1, "country_name": "England", "type": "EUR"}, "2243": {"parent_area": null,
|
56
|
+
"generation_high": 20, "all_names": {}, "id": 2243, "codes": {"ons": "44",
|
57
|
+
"gss": "E10000031", "unit_id": "10049"}, "name": "Warwickshire County Council",
|
58
|
+
"country": "E", "type_name": "County council", "generation_low": 1, "country_name":
|
59
|
+
"England", "type": "CTY"}, "900001": {"parent_area": null, "generation_high":
|
60
|
+
20, "all_names": {}, "id": 900001, "codes": {}, "name": "European Parliament",
|
61
|
+
"country": "", "type_name": "European Parliament", "generation_low": 1, "country_name":
|
62
|
+
"-", "type": "EUP"}, "66024": {"parent_area": null, "generation_high": 20,
|
63
|
+
"all_names": {}, "id": 66024, "codes": {"gss": "E14000854", "unit_id": "24700"},
|
64
|
+
"name": "North Warwickshire", "country": "E", "type_name": "UK Parliament
|
65
|
+
constituency", "generation_low": 13, "country_name": "England", "type": "WMC"},
|
66
|
+
"15881": {"parent_area": 2243, "generation_high": 20, "all_names": {}, "id":
|
67
|
+
15881, "codes": {"unit_id": "10112"}, "name": "Coleshill", "country": "E",
|
68
|
+
"type_name": "County council electoral division", "generation_low": 3, "country_name":
|
69
|
+
"England", "type": "CED"}, "97162": {"parent_area": null, "generation_high":
|
70
|
+
20, "all_names": {}, "id": 97162, "codes": {"ons": "E01031021"}, "name": "North
|
71
|
+
Warwickshire 006C", "country": "E", "type_name": "Lower Layer Super Output
|
72
|
+
Area (Full)", "generation_low": 13, "country_name": "England", "type": "OLF"},
|
73
|
+
"131540": {"parent_area": null, "generation_high": 20, "all_names": {}, "id":
|
74
|
+
131540, "codes": {"ons": "E01031021"}, "name": "North Warwickshire 006C",
|
75
|
+
"country": "E", "type_name": "Lower Layer Super Output Area (Generalised)",
|
76
|
+
"generation_low": 13, "country_name": "England", "type": "OLG"}, "7606": {"parent_area":
|
77
|
+
2458, "generation_high": 20, "all_names": {}, "id": 7606, "codes": {"ons":
|
78
|
+
"44UBGC", "gss": "E05007463", "unit_id": "10113"}, "name": "Coleshill South",
|
79
|
+
"country": "E", "type_name": "District council ward", "generation_low": 1,
|
80
|
+
"country_name": "England", "type": "DIW"}, "55160": {"parent_area": 2458,
|
81
|
+
"generation_high": 20, "all_names": {}, "id": 55160, "codes": {"ons": "44UB010",
|
82
|
+
"gss": "E04009636", "unit_id": "10183"}, "name": "Coleshill", "country": "E",
|
83
|
+
"type_name": "Civil parish/community", "generation_low": 12, "country_name":
|
84
|
+
"England", "type": "CPC"}, "47546": {"parent_area": null, "generation_high":
|
85
|
+
20, "all_names": {}, "id": 47546, "codes": {"ons": "E02006473"}, "name": "North
|
86
|
+
Warwickshire 006", "country": "E", "type_name": "Middle Layer Super Output
|
87
|
+
Area (Generalised)", "generation_low": 13, "country_name": "England", "type":
|
88
|
+
"OMG"}, "2458": {"parent_area": null, "generation_high": 20, "all_names":
|
89
|
+
{}, "id": 2458, "codes": {"ons": "44UB", "gss": "E07000218", "unit_id": "10124"},
|
90
|
+
"name": "North Warwickshire Borough Council", "country": "E", "type_name":
|
91
|
+
"District council", "generation_low": 1, "country_name": "England", "type":
|
92
|
+
"DIS"}, "900000": {"parent_area": null, "generation_high": 19, "all_names":
|
93
|
+
{}, "id": 900000, "codes": {}, "name": "House of Commons", "country": "",
|
94
|
+
"type_name": "UK Parliament", "generation_low": 1, "country_name": "-", "type":
|
95
|
+
"WMP"}}, "northing": 288805}'
|
96
|
+
http_version: '1.1'
|
97
|
+
recorded_at: Tue, 17 Sep 2013 14:44:17 GMT
|
98
|
+
- request:
|
99
|
+
method: get
|
100
|
+
uri: http://mapit.mysociety.org/point/4326/-1.706805276569471,52.49678940995588
|
101
|
+
body:
|
102
|
+
encoding: US-ASCII
|
103
|
+
string: ''
|
104
|
+
headers:
|
105
|
+
accept:
|
106
|
+
- ! '*/*'
|
107
|
+
user-agent:
|
108
|
+
- Ruby
|
109
|
+
response:
|
110
|
+
status:
|
111
|
+
code: 200
|
112
|
+
message: OK
|
113
|
+
headers:
|
114
|
+
expires:
|
115
|
+
- Tue, 15 Oct 2013 13:20:51 GMT
|
116
|
+
vary:
|
117
|
+
- Cookie,Accept-Encoding
|
118
|
+
etag:
|
119
|
+
- ! '"dd54c79a7ffa9ada97f196e2b607b2e1;gzip"'
|
120
|
+
cache-control:
|
121
|
+
- max-age=2419200
|
122
|
+
access-control-allow-origin:
|
123
|
+
- ! '*'
|
124
|
+
last-modified:
|
125
|
+
- Tue, 17 Sep 2013 13:20:51 GMT
|
126
|
+
content-type:
|
127
|
+
- application/json; charset=utf-8
|
128
|
+
x-url:
|
129
|
+
- /point/4326/-1.706805276569471,52.49678940995588
|
130
|
+
transfer-encoding:
|
131
|
+
- chunked
|
132
|
+
date:
|
133
|
+
- Tue, 17 Sep 2013 14:44:17 GMT
|
134
|
+
age:
|
135
|
+
- '5006'
|
136
|
+
connection:
|
137
|
+
- keep-alive
|
138
|
+
body:
|
139
|
+
encoding: US-ASCII
|
140
|
+
string: ! '{"40352": {"parent_area": null, "generation_high": 20, "all_names":
|
141
|
+
{}, "id": 40352, "codes": {"ons": "E02006473"}, "name": "North Warwickshire
|
142
|
+
006", "country": "E", "type_name": "Middle Layer Super Output Area (Full)",
|
143
|
+
"generation_low": 13, "country_name": "England", "type": "OMF"}, "11809":
|
144
|
+
{"parent_area": null, "generation_high": 20, "all_names": {}, "id": 11809,
|
145
|
+
"codes": {"ons": "05", "gss": "E15000005", "unit_id": "41426"}, "name": "West
|
146
|
+
Midlands", "country": "E", "type_name": "European region", "generation_low":
|
147
|
+
1, "country_name": "England", "type": "EUR"}, "2243": {"parent_area": null,
|
148
|
+
"generation_high": 20, "all_names": {}, "id": 2243, "codes": {"ons": "44",
|
149
|
+
"gss": "E10000031", "unit_id": "10049"}, "name": "Warwickshire County Council",
|
150
|
+
"country": "E", "type_name": "County council", "generation_low": 1, "country_name":
|
151
|
+
"England", "type": "CTY"}, "66024": {"parent_area": null, "generation_high":
|
152
|
+
20, "all_names": {}, "id": 66024, "codes": {"gss": "E14000854", "unit_id":
|
153
|
+
"24700"}, "name": "North Warwickshire", "country": "E", "type_name": "UK Parliament
|
154
|
+
constituency", "generation_low": 13, "country_name": "England", "type": "WMC"},
|
155
|
+
"15881": {"parent_area": 2243, "generation_high": 20, "all_names": {}, "id":
|
156
|
+
15881, "codes": {"unit_id": "10112"}, "name": "Coleshill", "country": "E",
|
157
|
+
"type_name": "County council electoral division", "generation_low": 3, "country_name":
|
158
|
+
"England", "type": "CED"}, "97162": {"parent_area": null, "generation_high":
|
159
|
+
20, "all_names": {}, "id": 97162, "codes": {"ons": "E01031021"}, "name": "North
|
160
|
+
Warwickshire 006C", "country": "E", "type_name": "Lower Layer Super Output
|
161
|
+
Area (Full)", "generation_low": 13, "country_name": "England", "type": "OLF"},
|
162
|
+
"131540": {"parent_area": null, "generation_high": 20, "all_names": {}, "id":
|
163
|
+
131540, "codes": {"ons": "E01031021"}, "name": "North Warwickshire 006C",
|
164
|
+
"country": "E", "type_name": "Lower Layer Super Output Area (Generalised)",
|
165
|
+
"generation_low": 13, "country_name": "England", "type": "OLG"}, "7606": {"parent_area":
|
166
|
+
2458, "generation_high": 20, "all_names": {}, "id": 7606, "codes": {"ons":
|
167
|
+
"44UBGC", "gss": "E05007463", "unit_id": "10113"}, "name": "Coleshill South",
|
168
|
+
"country": "E", "type_name": "District council ward", "generation_low": 1,
|
169
|
+
"country_name": "England", "type": "DIW"}, "55160": {"parent_area": 2458,
|
170
|
+
"generation_high": 20, "all_names": {}, "id": 55160, "codes": {"ons": "44UB010",
|
171
|
+
"gss": "E04009636", "unit_id": "10183"}, "name": "Coleshill", "country": "E",
|
172
|
+
"type_name": "Civil parish/community", "generation_low": 12, "country_name":
|
173
|
+
"England", "type": "CPC"}, "47546": {"parent_area": null, "generation_high":
|
174
|
+
20, "all_names": {}, "id": 47546, "codes": {"ons": "E02006473"}, "name": "North
|
175
|
+
Warwickshire 006", "country": "E", "type_name": "Middle Layer Super Output
|
176
|
+
Area (Generalised)", "generation_low": 13, "country_name": "England", "type":
|
177
|
+
"OMG"}, "2458": {"parent_area": null, "generation_high": 20, "all_names":
|
178
|
+
{}, "id": 2458, "codes": {"ons": "44UB", "gss": "E07000218", "unit_id": "10124"},
|
179
|
+
"name": "North Warwickshire Borough Council", "country": "E", "type_name":
|
180
|
+
"District council", "generation_low": 1, "country_name": "England", "type":
|
181
|
+
"DIS"}}'
|
182
|
+
http_version: '1.1'
|
183
|
+
recorded_at: Tue, 17 Sep 2013 14:44:18 GMT
|
184
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,179 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://mapit.mysociety.org/postcode/SW1A1AA
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
accept:
|
11
|
+
- ! '*/*'
|
12
|
+
user-agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
expires:
|
20
|
+
- Thu, 26 Sep 2013 12:29:30 GMT
|
21
|
+
vary:
|
22
|
+
- Cookie,Accept-Encoding
|
23
|
+
etag:
|
24
|
+
- ! '"2e5ca6db5b6ac0a3f008b0293a20a095;gzip"'
|
25
|
+
cache-control:
|
26
|
+
- max-age=2419200
|
27
|
+
access-control-allow-origin:
|
28
|
+
- ! '*'
|
29
|
+
last-modified:
|
30
|
+
- Thu, 29 Aug 2013 12:29:30 GMT
|
31
|
+
content-type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
x-url:
|
34
|
+
- /postcode/SW1A1AA
|
35
|
+
transfer-encoding:
|
36
|
+
- chunked
|
37
|
+
date:
|
38
|
+
- Tue, 17 Sep 2013 14:44:15 GMT
|
39
|
+
age:
|
40
|
+
- '1649686'
|
41
|
+
connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: ! '{"wgs84_lat": 51.501009611553926, "coordsyst": "G", "shortcuts":
|
46
|
+
{"WMC": 65759, "ward": 8569, "council": 2504}, "wgs84_lon": -0.14158706711000901,
|
47
|
+
"postcode": "SW1A 1AA", "easting": 529090, "areas": {"900000": {"parent_area":
|
48
|
+
null, "generation_high": 19, "all_names": {}, "id": 900000, "codes": {}, "name":
|
49
|
+
"House of Commons", "country": "", "type_name": "UK Parliament", "generation_low":
|
50
|
+
1, "country_name": "-", "type": "WMP"}, "900001": {"parent_area": null, "generation_high":
|
51
|
+
20, "all_names": {}, "id": 900001, "codes": {}, "name": "European Parliament",
|
52
|
+
"country": "", "type_name": "European Parliament", "generation_low": 1, "country_name":
|
53
|
+
"-", "type": "EUP"}, "42050": {"parent_area": null, "generation_high": 20,
|
54
|
+
"all_names": {}, "id": 42050, "codes": {"ons": "E02000977"}, "name": "Westminster
|
55
|
+
018", "country": "E", "type_name": "Middle Layer Super Output Area (Generalised)",
|
56
|
+
"generation_low": 13, "country_name": "England", "type": "OMG"}, "900006":
|
57
|
+
{"parent_area": null, "generation_high": 20, "all_names": {}, "id": 900006,
|
58
|
+
"codes": {}, "name": "London Assembly", "country": "E", "type_name": "London
|
59
|
+
Assembly area", "generation_low": 1, "country_name": "England", "type": "LAS"},
|
60
|
+
"2247": {"parent_area": null, "generation_high": 20, "all_names": {}, "id":
|
61
|
+
2247, "codes": {"unit_id": "41441"}, "name": "Greater London Authority", "country":
|
62
|
+
"E", "type_name": "Greater London Authority", "generation_low": 1, "country_name":
|
63
|
+
"England", "type": "GLA"}, "34856": {"parent_area": null, "generation_high":
|
64
|
+
20, "all_names": {}, "id": 34856, "codes": {"ons": "E02000977"}, "name": "Westminster
|
65
|
+
018", "country": "E", "type_name": "Middle Layer Super Output Area (Full)",
|
66
|
+
"generation_low": 13, "country_name": "England", "type": "OMF"}, "105255":
|
67
|
+
{"parent_area": null, "generation_high": 20, "all_names": {}, "id": 105255,
|
68
|
+
"codes": {"ons": "E01004736"}, "name": "Westminster 018C", "country": "E",
|
69
|
+
"type_name": "Lower Layer Super Output Area (Generalised)", "generation_low":
|
70
|
+
13, "country_name": "England", "type": "OLG"}, "900002": {"parent_area": 900006,
|
71
|
+
"generation_high": 20, "all_names": {}, "id": 900002, "codes": {}, "name":
|
72
|
+
"London Assembly", "country": "E", "type_name": "London Assembly area (shared)",
|
73
|
+
"generation_low": 1, "country_name": "England", "type": "LAE"}, "2504": {"parent_area":
|
74
|
+
null, "generation_high": 20, "all_names": {}, "id": 2504, "codes": {"ons":
|
75
|
+
"00BK", "gss": "E09000033", "unit_id": "11164"}, "name": "Westminster City
|
76
|
+
Council", "country": "E", "type_name": "London borough", "generation_low":
|
77
|
+
1, "country_name": "England", "type": "LBO"}, "11828": {"parent_area": 2247,
|
78
|
+
"generation_high": 20, "all_names": {}, "id": 11828, "codes": {"gss": "E32000014",
|
79
|
+
"unit_id": "41449"}, "name": "West Central", "country": "E", "type_name":
|
80
|
+
"London Assembly constituency", "generation_low": 1, "country_name": "England",
|
81
|
+
"type": "LAC"}, "8569": {"parent_area": 2504, "generation_high": 20, "all_names":
|
82
|
+
{}, "id": 8569, "codes": {"ons": "00BKGQ", "gss": "E05000644", "unit_id":
|
83
|
+
"11162"}, "name": "St James''s", "country": "E", "type_name": "London borough
|
84
|
+
ward", "generation_low": 1, "country_name": "England", "type": "LBW"}, "70877":
|
85
|
+
{"parent_area": null, "generation_high": 20, "all_names": {}, "id": 70877,
|
86
|
+
"codes": {"ons": "E01004736"}, "name": "Westminster 018C", "country": "E",
|
87
|
+
"type_name": "Lower Layer Super Output Area (Full)", "generation_low": 13,
|
88
|
+
"country_name": "England", "type": "OLF"}, "11806": {"parent_area": null,
|
89
|
+
"generation_high": 20, "all_names": {}, "id": 11806, "codes": {"ons": "07",
|
90
|
+
"gss": "E15000007", "unit_id": "41428"}, "name": "London", "country": "E",
|
91
|
+
"type_name": "European region", "generation_low": 1, "country_name": "England",
|
92
|
+
"type": "EUR"}, "65759": {"parent_area": null, "generation_high": 20, "all_names":
|
93
|
+
{}, "id": 65759, "codes": {"gss": "E14000639", "unit_id": "25040"}, "name":
|
94
|
+
"Cities of London and Westminster", "country": "E", "type_name": "UK Parliament
|
95
|
+
constituency", "generation_low": 13, "country_name": "England", "type": "WMC"}},
|
96
|
+
"northing": 179645}'
|
97
|
+
http_version: '1.1'
|
98
|
+
recorded_at: Tue, 17 Sep 2013 14:44:15 GMT
|
99
|
+
- request:
|
100
|
+
method: get
|
101
|
+
uri: http://mapit.mysociety.org/point/4326/-0.141587067110009,51.501009611553926
|
102
|
+
body:
|
103
|
+
encoding: US-ASCII
|
104
|
+
string: ''
|
105
|
+
headers:
|
106
|
+
accept:
|
107
|
+
- ! '*/*'
|
108
|
+
user-agent:
|
109
|
+
- Ruby
|
110
|
+
response:
|
111
|
+
status:
|
112
|
+
code: 200
|
113
|
+
message: OK
|
114
|
+
headers:
|
115
|
+
expires:
|
116
|
+
- Tue, 15 Oct 2013 11:11:05 GMT
|
117
|
+
vary:
|
118
|
+
- Cookie,Accept-Encoding
|
119
|
+
etag:
|
120
|
+
- ! '"017a7a0a2be950c74ec3e27e78a9de30;gzip"'
|
121
|
+
cache-control:
|
122
|
+
- max-age=2419200
|
123
|
+
access-control-allow-origin:
|
124
|
+
- ! '*'
|
125
|
+
last-modified:
|
126
|
+
- Tue, 17 Sep 2013 11:11:05 GMT
|
127
|
+
content-type:
|
128
|
+
- application/json; charset=utf-8
|
129
|
+
x-url:
|
130
|
+
- /point/4326/-0.141587067110009,51.501009611553926
|
131
|
+
transfer-encoding:
|
132
|
+
- chunked
|
133
|
+
date:
|
134
|
+
- Tue, 17 Sep 2013 14:44:15 GMT
|
135
|
+
age:
|
136
|
+
- '12791'
|
137
|
+
connection:
|
138
|
+
- keep-alive
|
139
|
+
body:
|
140
|
+
encoding: US-ASCII
|
141
|
+
string: ! '{"42050": {"parent_area": null, "generation_high": 20, "all_names":
|
142
|
+
{}, "id": 42050, "codes": {"ons": "E02000977"}, "name": "Westminster 018",
|
143
|
+
"country": "E", "type_name": "Middle Layer Super Output Area (Generalised)",
|
144
|
+
"generation_low": 13, "country_name": "England", "type": "OMG"}, "2247": {"parent_area":
|
145
|
+
null, "generation_high": 20, "all_names": {}, "id": 2247, "codes": {"unit_id":
|
146
|
+
"41441"}, "name": "Greater London Authority", "country": "E", "type_name":
|
147
|
+
"Greater London Authority", "generation_low": 1, "country_name": "England",
|
148
|
+
"type": "GLA"}, "34856": {"parent_area": null, "generation_high": 20, "all_names":
|
149
|
+
{}, "id": 34856, "codes": {"ons": "E02000977"}, "name": "Westminster 018",
|
150
|
+
"country": "E", "type_name": "Middle Layer Super Output Area (Full)", "generation_low":
|
151
|
+
13, "country_name": "England", "type": "OMF"}, "105255": {"parent_area": null,
|
152
|
+
"generation_high": 20, "all_names": {}, "id": 105255, "codes": {"ons": "E01004736"},
|
153
|
+
"name": "Westminster 018C", "country": "E", "type_name": "Lower Layer Super
|
154
|
+
Output Area (Generalised)", "generation_low": 13, "country_name": "England",
|
155
|
+
"type": "OLG"}, "2504": {"parent_area": null, "generation_high": 20, "all_names":
|
156
|
+
{}, "id": 2504, "codes": {"ons": "00BK", "gss": "E09000033", "unit_id": "11164"},
|
157
|
+
"name": "Westminster City Council", "country": "E", "type_name": "London borough",
|
158
|
+
"generation_low": 1, "country_name": "England", "type": "LBO"}, "11828": {"parent_area":
|
159
|
+
2247, "generation_high": 20, "all_names": {}, "id": 11828, "codes": {"gss":
|
160
|
+
"E32000014", "unit_id": "41449"}, "name": "West Central", "country": "E",
|
161
|
+
"type_name": "London Assembly constituency", "generation_low": 1, "country_name":
|
162
|
+
"England", "type": "LAC"}, "8569": {"parent_area": 2504, "generation_high":
|
163
|
+
20, "all_names": {}, "id": 8569, "codes": {"ons": "00BKGQ", "gss": "E05000644",
|
164
|
+
"unit_id": "11162"}, "name": "St James''s", "country": "E", "type_name": "London
|
165
|
+
borough ward", "generation_low": 1, "country_name": "England", "type": "LBW"},
|
166
|
+
"70877": {"parent_area": null, "generation_high": 20, "all_names": {}, "id":
|
167
|
+
70877, "codes": {"ons": "E01004736"}, "name": "Westminster 018C", "country":
|
168
|
+
"E", "type_name": "Lower Layer Super Output Area (Full)", "generation_low":
|
169
|
+
13, "country_name": "England", "type": "OLF"}, "11806": {"parent_area": null,
|
170
|
+
"generation_high": 20, "all_names": {}, "id": 11806, "codes": {"ons": "07",
|
171
|
+
"gss": "E15000007", "unit_id": "41428"}, "name": "London", "country": "E",
|
172
|
+
"type_name": "European region", "generation_low": 1, "country_name": "England",
|
173
|
+
"type": "EUR"}, "65759": {"parent_area": null, "generation_high": 20, "all_names":
|
174
|
+
{}, "id": 65759, "codes": {"gss": "E14000639", "unit_id": "25040"}, "name":
|
175
|
+
"Cities of London and Westminster", "country": "E", "type_name": "UK Parliament
|
176
|
+
constituency", "generation_low": 13, "country_name": "England", "type": "WMC"}}'
|
177
|
+
http_version: '1.1'
|
178
|
+
recorded_at: Tue, 17 Sep 2013 14:44:16 GMT
|
179
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MySociety::MapIt::Postcode do
|
4
|
+
|
5
|
+
it "correctly normalises a postcode", :vcr do
|
6
|
+
p = MySociety::MapIt::Postcode.new 'b46 3ld'
|
7
|
+
p.normalised_postcode.should == "B463LD"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gives a correct lat/lng for a postcode", :vcr do
|
11
|
+
p = MySociety::MapIt::Postcode.new 'b463ld'
|
12
|
+
p.to_point.y.should == -1.706805276569471
|
13
|
+
p.to_point.x.should == 52.49678940995588
|
14
|
+
end
|
15
|
+
|
16
|
+
it "gives a correct ward", :vcr do
|
17
|
+
p = MySociety::MapIt::Postcode.new 'b463ld'
|
18
|
+
p.ward.name.should == "Coleshill South"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "gives a correct gss code for a ward", :vcr do
|
22
|
+
p = MySociety::MapIt::Postcode.new 'b463ld'
|
23
|
+
p.ward.gss.should == "E05007463"
|
24
|
+
end
|
25
|
+
|
26
|
+
context "two tier" do
|
27
|
+
|
28
|
+
before :all, :vcr do
|
29
|
+
@p = MySociety::MapIt::Postcode.new 'b463ld'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "correctly identifies a two tier local authority", :vcr do
|
33
|
+
@p.two_tier?.should be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "gives a correct district council", :vcr do
|
37
|
+
@p.district.name.should == "North Warwickshire Borough Council"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "gives a correct district council gss code", :vcr do
|
41
|
+
@p.district.gss.should == "E07000218"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "gives a correct county council", :vcr do
|
45
|
+
@p.county.name.should == "Warwickshire County Council"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "gives a correct county council gss code", :vcr do
|
49
|
+
@p.county.gss.should == "E10000031"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns a hash when asked for a local authority", :vcr do
|
53
|
+
@p.local_authority.kind_of?(Hash).should be_true
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context "single tier" do
|
59
|
+
|
60
|
+
before :all, :vcr do
|
61
|
+
@p = MySociety::MapIt::Postcode.new 'sw1a1aa'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "correctly identifies a single tier local authority", :vcr do
|
65
|
+
@p.two_tier?.should be_false
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns the correct local authority", :vcr do
|
69
|
+
@p.local_authority.name.should == "Westminster City Council"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns the correct local authority gss code", :vcr do
|
73
|
+
@p.local_authority.gss.should == "E09000033"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with parish" do
|
79
|
+
|
80
|
+
it "returns the correct parish", :vcr do
|
81
|
+
p = MySociety::MapIt::Postcode.new 'b463ld'
|
82
|
+
p.parish.name.should == "Coleshill"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
context "without parish" do
|
88
|
+
|
89
|
+
it "returns the nil for a parish", :vcr do
|
90
|
+
p = MySociety::MapIt::Postcode.new 'sw1a1aa'
|
91
|
+
p.parish.should be_nil
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|