tfl_api_client 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.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/.travis.yml +29 -0
  4. data/CHANGELOG.md +9 -0
  5. data/CONTRIBUTING.md +62 -0
  6. data/GETTING_STARTED.md +161 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE +22 -0
  9. data/README.md +62 -0
  10. data/Rakefile +30 -0
  11. data/lib/tfl_api_client/bike_point.rb +105 -0
  12. data/lib/tfl_api_client/client.rb +235 -0
  13. data/lib/tfl_api_client/exceptions.rb +91 -0
  14. data/lib/tfl_api_client/version.rb +28 -0
  15. data/lib/tfl_api_client.rb +33 -0
  16. data/spec/cassettes/bike_point/authorised_client_location.yml +83 -0
  17. data/spec/cassettes/bike_point/authorised_client_locations.yml +8179 -0
  18. data/spec/cassettes/bike_point/authorised_client_locations_within_bounding_box.yml +402 -0
  19. data/spec/cassettes/bike_point/authorised_client_locations_within_locus.yml +106 -0
  20. data/spec/cassettes/bike_point/authorised_client_search.yml +80 -0
  21. data/spec/cassettes/bike_point/unauthorised_client_location.yml +50 -0
  22. data/spec/cassettes/bike_point/unauthorised_client_locations.yml +50 -0
  23. data/spec/cassettes/bike_point/unauthorised_client_locations_within_bounding_box.yml +50 -0
  24. data/spec/cassettes/bike_point/unauthorised_client_locations_within_locus.yml +50 -0
  25. data/spec/cassettes/bike_point/unauthorised_client_search.yml +50 -0
  26. data/spec/integration/bike_point_spec.rb +158 -0
  27. data/spec/spec_helper.rb +114 -0
  28. data/spec/support/coverage.rb +36 -0
  29. data/spec/support/helpers.rb +81 -0
  30. data/spec/support/vcr.rb +43 -0
  31. data/spec/unit/bike_point_spec.rb +87 -0
  32. data/spec/unit/client_spec.rb +199 -0
  33. data/tfl_api_client.gemspec +36 -0
  34. metadata +222 -0
@@ -0,0 +1,106 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint?app_id=TFL_APP_ID&app_key=TFL_APP_KEY&lat=51.5007292&lon=-0.1246254&radius=500
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Headers:
24
+ - Content-Type
25
+ Access-Control-Allow-Methods:
26
+ - GET,POST,PUT,DELETE,OPTIONS
27
+ Access-Control-Allow-Origin:
28
+ - "*"
29
+ Age:
30
+ - '0'
31
+ Api-Entity-Payload:
32
+ - Place
33
+ Cache-Control:
34
+ - public, must-revalidate, max-age=150, s-maxage=300
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Date:
38
+ - Tue, 11 Aug 2015 16:55:11 GMT
39
+ Server:
40
+ - Microsoft-IIS/8.5
41
+ Via:
42
+ - 1.1 varnish
43
+ X-Aspnet-Version:
44
+ - 4.0.30319
45
+ X-Backend:
46
+ - api
47
+ X-Backend-Url:
48
+ - "/BikePoint?lat=51.500&lon=-0.124&radius=500"
49
+ X-Banning:
50
+ - ''
51
+ X-Cache:
52
+ - MISS
53
+ X-Cacheable:
54
+ - Yes. Cacheable
55
+ X-Hash-Url:
56
+ - "/bikepoint?lat=51.500&lon=-0.124&radius=500"
57
+ X-Ttl:
58
+ - '300.000'
59
+ X-Ttl-Rule:
60
+ - '0'
61
+ X-Varnish:
62
+ - 10.75.3.20
63
+ - '281675720'
64
+ Content-Length:
65
+ - '665'
66
+ Connection:
67
+ - keep-alive
68
+ body:
69
+ encoding: ASCII-8BIT
70
+ string: '{"$type":"Tfl.Api.Presentation.Entities.PlacesResponse, Tfl.Api.Presentation.Entities","centrePoint":[51.5,-0.124],"places":[{"$type":"Tfl.Api.Presentation.Entities.Place,
71
+ Tfl.Api.Presentation.Entities","id":"BikePoints_583","url":"https://api-prod5.tfl.gov.uk/Place/BikePoints_583","commonName":"Abingdon
72
+ Green, Westminster","distance":298.02591243579081,"placeType":"BikePoint","additionalProperties":[{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
73
+ Tfl.Api.Presentation.Entities","category":"Description","key":"TerminalName","sourceSystemKey":"BikePoints","value":"200231","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
74
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Installed","sourceSystemKey":"BikePoints","value":"true","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
75
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Locked","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
76
+ Tfl.Api.Presentation.Entities","category":"Description","key":"InstallDate","sourceSystemKey":"BikePoints","value":"","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
77
+ Tfl.Api.Presentation.Entities","category":"Description","key":"RemovalDate","sourceSystemKey":"BikePoints","value":"","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
78
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Temporary","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
79
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbBikes","sourceSystemKey":"BikePoints","value":"10","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
80
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbEmptyDocks","sourceSystemKey":"BikePoints","value":"9","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
81
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbDocks","sourceSystemKey":"BikePoints","value":"20","modified":"2015-08-11T16:47:52.26"}],"children":[],"lat":51.497622,"lon":-0.125978},{"$type":"Tfl.Api.Presentation.Entities.Place,
82
+ Tfl.Api.Presentation.Entities","id":"BikePoints_762","url":"https://api-prod5.tfl.gov.uk/Place/BikePoints_762","commonName":"Storey''s
83
+ Gate, Westminster","distance":402.434044794388,"placeType":"BikePoint","additionalProperties":[{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
84
+ Tfl.Api.Presentation.Entities","category":"Description","key":"TerminalName","sourceSystemKey":"BikePoints","value":"200202","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
85
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Installed","sourceSystemKey":"BikePoints","value":"true","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
86
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Locked","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
87
+ Tfl.Api.Presentation.Entities","category":"Description","key":"InstallDate","sourceSystemKey":"BikePoints","value":"1392039000000","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
88
+ Tfl.Api.Presentation.Entities","category":"Description","key":"RemovalDate","sourceSystemKey":"BikePoints","value":"","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
89
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Temporary","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
90
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbBikes","sourceSystemKey":"BikePoints","value":"3","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
91
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbEmptyDocks","sourceSystemKey":"BikePoints","value":"18","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
92
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbDocks","sourceSystemKey":"BikePoints","value":"21","modified":"2015-08-11T16:47:52.26"}],"children":[],"lat":51.500703,"lon":-0.129698},{"$type":"Tfl.Api.Presentation.Entities.Place,
93
+ Tfl.Api.Presentation.Entities","id":"BikePoints_641","url":"https://api-prod5.tfl.gov.uk/Place/BikePoints_641","commonName":"Archbishop''s
94
+ Park, Waterloo","distance":491.35693047938736,"placeType":"BikePoint","additionalProperties":[{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
95
+ Tfl.Api.Presentation.Entities","category":"Description","key":"TerminalName","sourceSystemKey":"BikePoints","value":"300025","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
96
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Installed","sourceSystemKey":"BikePoints","value":"true","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
97
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Locked","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
98
+ Tfl.Api.Presentation.Entities","category":"Description","key":"InstallDate","sourceSystemKey":"BikePoints","value":"1381926900000","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
99
+ Tfl.Api.Presentation.Entities","category":"Description","key":"RemovalDate","sourceSystemKey":"BikePoints","value":"","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
100
+ Tfl.Api.Presentation.Entities","category":"Description","key":"Temporary","sourceSystemKey":"BikePoints","value":"false","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
101
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbBikes","sourceSystemKey":"BikePoints","value":"13","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
102
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbEmptyDocks","sourceSystemKey":"BikePoints","value":"9","modified":"2015-08-11T16:47:52.26"},{"$type":"Tfl.Api.Presentation.Entities.AdditionalProperties,
103
+ Tfl.Api.Presentation.Entities","category":"Description","key":"NbDocks","sourceSystemKey":"BikePoints","value":"23","modified":"2015-08-11T16:47:52.26"}],"children":[],"lat":51.498241,"lon":-0.117495}]}'
104
+ http_version:
105
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
106
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,80 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint/Search?app_id=TFL_APP_ID&app_key=TFL_APP_KEY&query=St.%20James
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Access-Control-Allow-Headers:
26
+ - Content-Type
27
+ Access-Control-Allow-Methods:
28
+ - GET,POST,PUT,DELETE,OPTIONS
29
+ Access-Control-Allow-Origin:
30
+ - "*"
31
+ Age:
32
+ - '276888'
33
+ Api-Entity-Payload:
34
+ - Place
35
+ Cache-Control:
36
+ - public, must-revalidate, max-age=302400, s-maxage=604800
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Date:
40
+ - Tue, 11 Aug 2015 16:52:34 GMT
41
+ Server:
42
+ - Microsoft-IIS/8.5
43
+ Via:
44
+ - 1.1 varnish
45
+ X-Aspnet-Version:
46
+ - 4.0.30319
47
+ X-Backend:
48
+ - api
49
+ X-Backend-Url:
50
+ - "/BikePoint/Search?query=St.+James"
51
+ X-Banning:
52
+ - ''
53
+ X-Cache:
54
+ - HIT
55
+ X-Cache-Hits:
56
+ - '11'
57
+ X-Cacheable:
58
+ - Yes. Cacheable
59
+ X-Hash-Url:
60
+ - "/bikepoint/search?query=st.+james"
61
+ X-Ttl:
62
+ - '604800.000'
63
+ X-Ttl-Rule:
64
+ - '0'
65
+ X-Varnish:
66
+ - 10.75.2.167
67
+ - 395128512 302922170
68
+ Content-Length:
69
+ - '262'
70
+ Connection:
71
+ - keep-alive
72
+ body:
73
+ encoding: ASCII-8BIT
74
+ string: '[{"$type":"Tfl.Api.Presentation.Entities.Place, Tfl.Api.Presentation.Entities","id":"BikePoints_160","url":"https://api-prod5.tfl.gov.uk/Place/BikePoints_160","commonName":"Waterloo
75
+ Place, St. James''s","placeType":"BikePoint","additionalProperties":[],"children":[],"childrenUrls":[],"lat":51.506633,"lon":-0.131773},{"$type":"Tfl.Api.Presentation.Entities.Place,
76
+ Tfl.Api.Presentation.Entities","id":"BikePoints_228","url":"https://api-prod5.tfl.gov.uk/Place/BikePoints_228","commonName":"St.
77
+ James''s Square, St. James''s","placeType":"BikePoint","additionalProperties":[],"children":[],"childrenUrls":[],"lat":51.507424,"lon":-0.134621}]'
78
+ http_version:
79
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
80
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint/BikePoints_10?app_id=TFL_APP_ID&app_key=TFL_APP_KEY
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 302
21
+ message: Unauthorized
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Date:
28
+ - Tue, 11 Aug 2015 16:52:36 GMT
29
+ Location:
30
+ - "/static-messages/401.html"
31
+ Server:
32
+ - Varnish
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Banning:
36
+ - ''
37
+ X-Cache:
38
+ - MISS
39
+ X-Varnish:
40
+ - '478472293'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Connection:
44
+ - keep-alive
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Tue, 11 Aug 2015 16:52:37 GMT
50
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint?app_id=TFL_APP_ID&app_key=TFL_APP_KEY
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 302
21
+ message: Unauthorized
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Date:
28
+ - Tue, 11 Aug 2015 16:52:35 GMT
29
+ Location:
30
+ - "/static-messages/401.html"
31
+ Server:
32
+ - Varnish
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Banning:
36
+ - ''
37
+ X-Cache:
38
+ - MISS
39
+ X-Varnish:
40
+ - '395128672'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Connection:
44
+ - keep-alive
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
50
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint?app_id=TFL_APP_ID&app_key=TFL_APP_KEY&neLat=51.5138453&neLon=-0.0983506&swLat=51.5007292&swLon=-0.1246254
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 302
21
+ message: Unauthorized
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Date:
28
+ - Tue, 11 Aug 2015 16:55:11 GMT
29
+ Location:
30
+ - "/static-messages/401.html"
31
+ Server:
32
+ - Varnish
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Banning:
36
+ - ''
37
+ X-Cache:
38
+ - MISS
39
+ X-Varnish:
40
+ - '281675612'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Connection:
44
+ - keep-alive
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
50
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint?app_id=TFL_APP_ID&app_key=TFL_APP_KEY&lat=51.5007292&lon=-0.1246254&radius=500
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 302
21
+ message: Unauthorized
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Date:
28
+ - Tue, 11 Aug 2015 16:55:11 GMT
29
+ Location:
30
+ - "/static-messages/401.html"
31
+ Server:
32
+ - Varnish
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Banning:
36
+ - ''
37
+ X-Cache:
38
+ - MISS
39
+ X-Varnish:
40
+ - '281675686'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Connection:
44
+ - keep-alive
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
50
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/BikePoint/Search?app_id=TFL_APP_ID&app_key=TFL_APP_KEY&query=St.%20James
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 302
21
+ message: Unauthorized
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Date:
28
+ - Tue, 11 Aug 2015 16:55:11 GMT
29
+ Location:
30
+ - "/static-messages/401.html"
31
+ Server:
32
+ - Varnish
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Banning:
36
+ - ''
37
+ X-Cache:
38
+ - MISS
39
+ X-Varnish:
40
+ - '281675776'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Connection:
44
+ - keep-alive
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ http_version:
49
+ recorded_at: Tue, 11 Aug 2015 16:52:35 GMT
50
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,158 @@
1
+ #
2
+ # Copyright (c) 2015 Luke Hackett
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ require_relative '../spec_helper'
27
+
28
+
29
+ describe '/BikePoint Integration', type: :feature do
30
+ let!(:authorised_bike_point) { authorised_client.bike_point }
31
+ let!(:unauthorised_bike_point) { unauthorised_client.bike_point }
32
+
33
+ describe '#locations' do
34
+ context 'with an authorised client' do
35
+ it 'should return all locations' do
36
+ VCR.use_cassette('bike_point/authorised_client_locations') do
37
+ locations = authorised_bike_point.locations
38
+ expect(locations).to be_kind_of(Array)
39
+ expect(locations).to_not be_empty
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'with an unauthorised client' do
45
+ it 'should raise an exception' do
46
+ VCR.use_cassette('bike_point/unauthorised_client_locations') do
47
+ expect {
48
+ unauthorised_bike_point.locations
49
+ }.to raise_error(TflApi::Exceptions::ApiException)
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#location' do
56
+ let(:location_id) { 'BikePoints_10' }
57
+
58
+ context 'with an authorised client' do
59
+ it "should return the given location's details" do
60
+ VCR.use_cassette('bike_point/authorised_client_location') do
61
+ location = authorised_bike_point.location(location_id)
62
+ expect(location).to be_kind_of(Hash)
63
+ expect(location['id']).to eq(location_id)
64
+ expect(location['placeType']).to eq('BikePoint')
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'with an unauthorised client' do
70
+ it 'should raise an exception' do
71
+ VCR.use_cassette('bike_point/unauthorised_client_location') do
72
+ expect {
73
+ unauthorised_bike_point.location(location_id)
74
+ }.to raise_error(TflApi::Exceptions::ApiException)
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#locations_within_locus' do
81
+ let(:longitude) { 51.5007292 } # Big Ben
82
+ let(:latitude) { -0.1246254 }
83
+ let(:radius) { 500 }
84
+
85
+ context 'with an authorised client' do
86
+ it 'should return all BikePoints within the defined locus' do
87
+ VCR.use_cassette('bike_point/authorised_client_locations_within_locus') do
88
+ locations = authorised_bike_point.locations_within_locus(longitude, latitude, radius)
89
+ expect(locations).to be_kind_of(Hash)
90
+ expect(locations['centrePoint']).to eq([51.5, -0.124])
91
+ expect(locations['places']).to be_kind_of(Array)
92
+ expect(locations['places']).to_not be_empty
93
+ end
94
+ end
95
+ end
96
+
97
+ context 'with an unauthorised client' do
98
+ it 'should raise an exception' do
99
+ VCR.use_cassette('bike_point/unauthorised_client_locations_within_locus') do
100
+ expect {
101
+ unauthorised_bike_point.locations_within_locus(longitude, latitude, radius)
102
+ }.to raise_error(TflApi::Exceptions::ApiException)
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#locations_within_bounding_box' do
109
+ let(:sw_latitude) { 51.5007292 } # Big Ben
110
+ let(:sw_longitude) { -0.1246254 }
111
+ let(:ne_latitude) { 51.5138453 } # St. Paul's Cathedral
112
+ let(:ne_longitude) { -0.0983506 }
113
+
114
+ context 'with an authorised client' do
115
+ it 'should return all BikePoints within the defined bounding box' do
116
+ VCR.use_cassette('bike_point/authorised_client_locations_within_bounding_box') do
117
+ locations = authorised_bike_point.locations_within_bounding_box(sw_latitude, sw_longitude, ne_latitude, ne_longitude)
118
+ expect(locations).to be_kind_of(Array)
119
+ expect(locations).to_not be_empty
120
+ end
121
+ end
122
+ end
123
+
124
+ context 'with an unauthorised client' do
125
+ it 'should raise an exception' do
126
+ VCR.use_cassette('bike_point/unauthorised_client_locations_within_bounding_box') do
127
+ expect {
128
+ unauthorised_bike_point.locations_within_bounding_box(sw_latitude, sw_longitude, ne_latitude, ne_longitude)
129
+ }.to raise_error(TflApi::Exceptions::ApiException)
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+ describe '#search' do
136
+ let(:search_term) { 'St. James' }
137
+
138
+ context 'with an authorised client' do
139
+ it 'should return all BikePoint locations based upon the criteria' do
140
+ VCR.use_cassette('bike_point/authorised_client_search') do
141
+ locations = authorised_bike_point.search(search_term)
142
+ expect(locations).to be_kind_of(Array)
143
+ expect(locations).to_not be_empty
144
+ end
145
+ end
146
+ end
147
+
148
+ context 'with an unauthorised client' do
149
+ it 'should raise an exception' do
150
+ VCR.use_cassette('bike_point/unauthorised_client_search') do
151
+ expect {
152
+ unauthorised_bike_point.search(search_term)
153
+ }.to raise_error(TflApi::Exceptions::ApiException)
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end