tfl_api_client 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/lib/tfl_api_client.rb +2 -0
  6. data/{spec/support/coverage.rb → lib/tfl_api_client/accident_stats.rb} +27 -8
  7. data/{spec/support/vcr.rb → lib/tfl_api_client/air_quality.rb} +25 -14
  8. data/lib/tfl_api_client/bike_point.rb +0 -1
  9. data/lib/tfl_api_client/client.rb +16 -0
  10. data/lib/tfl_api_client/version.rb +1 -1
  11. metadata +4 -55
  12. data/.gitignore +0 -37
  13. data/.travis.yml +0 -31
  14. data/.yardopts +0 -4
  15. data/GETTING_STARTED.md +0 -231
  16. data/Gemfile +0 -4
  17. data/Rakefile +0 -36
  18. data/spec/cassettes/bike_point/authorised_client_location.yml +0 -83
  19. data/spec/cassettes/bike_point/authorised_client_locations.yml +0 -8179
  20. data/spec/cassettes/bike_point/authorised_client_locations_within_bounding_box.yml +0 -402
  21. data/spec/cassettes/bike_point/authorised_client_locations_within_locus.yml +0 -106
  22. data/spec/cassettes/bike_point/authorised_client_search.yml +0 -80
  23. data/spec/cassettes/bike_point/unauthorised_client_location.yml +0 -50
  24. data/spec/cassettes/bike_point/unauthorised_client_locations.yml +0 -50
  25. data/spec/cassettes/bike_point/unauthorised_client_locations_within_bounding_box.yml +0 -50
  26. data/spec/cassettes/bike_point/unauthorised_client_locations_within_locus.yml +0 -50
  27. data/spec/cassettes/bike_point/unauthorised_client_search.yml +0 -50
  28. data/spec/cassettes/cycle/authorised_client_superhighway.yml +0 -75
  29. data/spec/cassettes/cycle/authorised_client_superhighways.yml +0 -99
  30. data/spec/cassettes/cycle/unauthorised_client_superhighway.yml +0 -50
  31. data/spec/cassettes/cycle/unauthorised_client_superhighways.yml +0 -50
  32. data/spec/integration/bike_point_spec.rb +0 -158
  33. data/spec/integration/cycle_spec.rb +0 -79
  34. data/spec/spec_helper.rb +0 -114
  35. data/spec/support/helpers.rb +0 -81
  36. data/spec/unit/bike_point_spec.rb +0 -87
  37. data/spec/unit/client_spec.rb +0 -199
  38. data/spec/unit/cycle_spec.rb +0 -66
  39. data/tfl_api_client.gemspec +0 -37
@@ -1,50 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.tfl.gov.uk/CycleSuperhighway/RMP-006?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
- - Sun, 17 Apr 2016 17:00:44 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
- - '1504412725'
41
- Transfer-Encoding:
42
- - chunked
43
- Connection:
44
- - keep-alive
45
- body:
46
- encoding: UTF-8
47
- string: ''
48
- http_version:
49
- recorded_at: Sun, 17 Apr 2016 17:00:43 GMT
50
- recorded_with: VCR 3.0.1
@@ -1,50 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.tfl.gov.uk/CycleSuperhighway?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
- - Sun, 17 Apr 2016 16:53:56 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
- - '1504234986'
41
- Transfer-Encoding:
42
- - chunked
43
- Connection:
44
- - keep-alive
45
- body:
46
- encoding: UTF-8
47
- string: ''
48
- http_version:
49
- recorded_at: Sun, 17 Apr 2016 16:53:55 GMT
50
- recorded_with: VCR 3.0.1
@@ -1,158 +0,0 @@
1
- #
2
- # Copyright (c) 2015 - 2017 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
@@ -1,79 +0,0 @@
1
- #
2
- # Copyright (c) 2015 - 2017 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
- describe '/CycleSuperhighway Integration', type: :feature do
29
- let!(:authorised_cycle) { authorised_client.cycle }
30
- let!(:unauthorised_cycle) { unauthorised_client.cycle }
31
-
32
- describe '#superhighways' do
33
- context 'with an authorised client' do
34
- it 'should return all cycle superhighways' do
35
- VCR.use_cassette('cycle/authorised_client_superhighways') do
36
- locations = authorised_cycle.superhighways
37
- expect(locations).to be_kind_of(Array)
38
- expect(locations).to_not be_empty
39
- end
40
- end
41
- end
42
-
43
- context 'with an unauthorised client' do
44
- it 'should raise an exception' do
45
- VCR.use_cassette('cycle/unauthorised_client_superhighways') do
46
- expect {
47
- unauthorised_cycle.superhighways
48
- }.to raise_error(TflApi::Exceptions::ApiException)
49
- end
50
- end
51
- end
52
- end
53
-
54
- describe '#superhighway' do
55
- let(:highway_id) { 'RMP-006' }
56
-
57
- context 'with an authorised client' do
58
- it "should return the given superhighway's details" do
59
- VCR.use_cassette('cycle/authorised_client_superhighway') do
60
- superhighway = authorised_cycle.superhighway(highway_id)
61
- expect(superhighway).to be_kind_of(Hash)
62
- expect(superhighway['id']).to eq(highway_id)
63
- expect(superhighway['labelShort']).to eq('CSNS')
64
- end
65
- end
66
- end
67
-
68
- context 'with an unauthorised client' do
69
- it 'should raise an exception' do
70
- VCR.use_cassette('cycle/unauthorised_client_superhighway') do
71
- expect {
72
- unauthorised_cycle.superhighway(highway_id)
73
- }.to raise_error(TflApi::Exceptions::ApiException)
74
- end
75
- end
76
- end
77
- end
78
-
79
- end
@@ -1,114 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
-
15
- # Additional Test Imports
16
- require 'webmock/rspec'
17
- require_relative 'support/coverage'
18
- require_relative 'support/vcr'
19
- require_relative 'support/helpers'
20
-
21
- # Load the Gem
22
- require_relative '../lib/tfl_api_client'
23
-
24
- # The `.rspec` file also contains a few flags that are not defaults but that
25
- # users commonly want.
26
- #
27
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
28
- RSpec.configure do |config|
29
- # rspec-expectations config goes here. You can use an alternate
30
- # assertion/expectation library such as wrong or the stdlib/minitest
31
- # assertions if you prefer.
32
- config.expect_with :rspec do |expectations|
33
- # This option will default to `true` in RSpec 4. It makes the `description`
34
- # and `failure_message` of custom matchers include text for helper methods
35
- # defined using `chain`, e.g.:
36
- # be_bigger_than(2).and_smaller_than(4).description
37
- # # => "be bigger than 2 and smaller than 4"
38
- # ...rather than:
39
- # # => "be bigger than 2"
40
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
41
-
42
- # Disable should syntax
43
- expectations.syntax = :expect
44
- end
45
-
46
- # rspec-mocks config goes here. You can use an alternate test double
47
- # library (such as bogus or mocha) by changing the `mock_with` option here.
48
- config.mock_with :rspec do |mocks|
49
- # Prevents you from mocking or stubbing a method that does not exist on
50
- # a real object. This is generally recommended, and will default to
51
- # `true` in RSpec 4.
52
- mocks.verify_partial_doubles = true
53
-
54
- # Disable should syntax
55
- mocks.syntax = :expect
56
- end
57
-
58
- # Include test helpers
59
- config.include Helpers
60
-
61
- # These two settings work together to allow you to limit a spec run
62
- # to individual examples or groups you care about by tagging them with
63
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
64
- # get run.
65
- # config.filter_run :focus
66
- # config.run_all_when_everything_filtered = true
67
-
68
- # Allows RSpec to persist some state between runs in order to support
69
- # the `--only-failures` and `--next-failure` CLI options. We recommend
70
- # you configure your source control system to ignore this file.
71
- # config.example_status_persistence_file_path = 'spec/examples.txt'
72
-
73
- # Limits the available syntax to the non-monkey patched syntax that is
74
- # recommended. For more details, see:
75
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
76
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
77
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
78
- # config.disable_monkey_patching!
79
-
80
- # This setting enables warnings. It's recommended, but in some cases may
81
- # be too noisy due to issues in dependencies.
82
- # config.warnings = true
83
-
84
- # Many RSpec users commonly either run the entire suite or an individual
85
- # file, and it's useful to allow more verbose output when running an
86
- # individual spec file.
87
- if config.files_to_run.one?
88
- # Use the documentation formatter for detailed output,
89
- # unless a formatter has already been configured
90
- # (e.g. via a command-line flag).
91
- # config.default_formatter = 'doc'
92
- end
93
-
94
- # Use Fuubar to handle pretty printing of the test suite
95
- config.default_formatter = 'Fuubar'
96
- config.color = true
97
-
98
- # Print the 10 slowest examples and example groups at the
99
- # end of the spec run, to help surface which specs are running
100
- # particularly slow.
101
- # config.profile_examples = 10
102
-
103
- # Run specs in random order to surface order dependencies. If you find an
104
- # order dependency and want to debug it, you can fix the order by providing
105
- # the seed, which is printed after each run.
106
- # --seed 1234
107
- config.order = :random
108
-
109
- # Seed global randomization in this process using the `--seed` CLI option.
110
- # Setting this allows you to use `--seed` to deterministically reproduce
111
- # test failures related to randomization by passing the same `--seed` value
112
- # as the one that triggered the failure.
113
- Kernel.srand config.seed
114
- end