google_distance_matrix 0.4.0 → 0.5.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +16 -0
  3. data/.rubocop.yml +6 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +1 -0
  6. data/CHANGELOG.md +20 -0
  7. data/Gemfile +2 -0
  8. data/Rakefile +9 -4
  9. data/google_distance_matrix.gemspec +20 -18
  10. data/lib/google_distance_matrix/client.rb +32 -18
  11. data/lib/google_distance_matrix/client_cache.rb +9 -3
  12. data/lib/google_distance_matrix/configuration.rb +37 -19
  13. data/lib/google_distance_matrix/errors.rb +6 -3
  14. data/lib/google_distance_matrix/log_subscriber.rb +14 -14
  15. data/lib/google_distance_matrix/logger.rb +6 -4
  16. data/lib/google_distance_matrix/matrix.rb +45 -22
  17. data/lib/google_distance_matrix/place.rb +32 -25
  18. data/lib/google_distance_matrix/places.rb +5 -4
  19. data/lib/google_distance_matrix/polyline_encoder/delta.rb +4 -2
  20. data/lib/google_distance_matrix/polyline_encoder/value_encoder.rb +11 -4
  21. data/lib/google_distance_matrix/polyline_encoder.rb +2 -2
  22. data/lib/google_distance_matrix/railtie.rb +4 -1
  23. data/lib/google_distance_matrix/route.rb +22 -15
  24. data/lib/google_distance_matrix/routes_finder.rb +25 -29
  25. data/lib/google_distance_matrix/url_builder/polyline_encoder_buffer.rb +3 -0
  26. data/lib/google_distance_matrix/url_builder.rb +44 -16
  27. data/lib/google_distance_matrix/version.rb +3 -1
  28. data/lib/google_distance_matrix.rb +25 -23
  29. data/spec/lib/google_distance_matrix/client_cache_spec.rb +26 -11
  30. data/spec/lib/google_distance_matrix/client_spec.rb +40 -30
  31. data/spec/lib/google_distance_matrix/configuration_spec.rb +36 -24
  32. data/spec/lib/google_distance_matrix/log_subscriber_spec.rb +13 -44
  33. data/spec/lib/google_distance_matrix/logger_spec.rb +16 -13
  34. data/spec/lib/google_distance_matrix/matrix_spec.rb +90 -57
  35. data/spec/lib/google_distance_matrix/place_spec.rb +30 -25
  36. data/spec/lib/google_distance_matrix/places_spec.rb +29 -28
  37. data/spec/lib/google_distance_matrix/polyline_encoder/delta_spec.rb +5 -3
  38. data/spec/lib/google_distance_matrix/polyline_encoder_spec.rb +7 -2
  39. data/spec/lib/google_distance_matrix/route_spec.rb +11 -9
  40. data/spec/lib/google_distance_matrix/routes_finder_spec.rb +95 -81
  41. data/spec/lib/google_distance_matrix/url_builder_spec.rb +97 -48
  42. data/spec/spec_helper.rb +3 -1
  43. metadata +35 -7
@@ -1,77 +1,78 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
2
4
 
3
5
  describe GoogleDistanceMatrix::Places do
4
- let(:values) { [{address: "one"}, {address: "two"}, {address: "three"}] }
6
+ let(:values) { [{ address: 'one' }, { address: 'two' }, { address: 'three' }] }
5
7
  let(:places) { values.map { |v| GoogleDistanceMatrix::Place.new v } }
6
8
 
7
- let(:place_4) { GoogleDistanceMatrix::Place.new address: "four" }
8
- let(:place_5) { GoogleDistanceMatrix::Place.new address: "five" }
9
- let(:place_6) { GoogleDistanceMatrix::Place.new address: "six" }
9
+ let(:place_4) { GoogleDistanceMatrix::Place.new address: 'four' }
10
+ let(:place_5) { GoogleDistanceMatrix::Place.new address: 'five' }
11
+ let(:place_6) { GoogleDistanceMatrix::Place.new address: 'six' }
10
12
 
11
13
  subject { described_class.new places }
12
14
 
13
- it { should include *places }
15
+ it { should include(*places) }
14
16
  it { should_not include 5 }
15
17
 
16
-
17
18
  %w[<< push unshift].each do |attr|
18
- describe "#{attr}" do
19
- it "adds value" do
20
- expect {
19
+ describe attr.to_s do
20
+ it 'adds value' do
21
+ expect do
21
22
  subject.public_send attr, place_4
22
- }.to change { subject.include? place_4 }.to true
23
+ end.to change { subject.include? place_4 }.to true
23
24
  end
24
25
 
25
- it "keeps uniq values" do
26
+ it 'keeps uniq values' do
26
27
  subject.public_send attr, place_4
27
28
 
28
- expect {
29
+ expect do
29
30
  subject.public_send attr, place_4
30
- }.to_not change subject, :length
31
+ end.to_not change subject, :length
31
32
  end
32
33
 
33
- it "is chanable" do
34
+ it 'is chanable' do
34
35
  subject.public_send(attr, place_5).public_send(attr, place_6)
35
36
 
36
37
  expect(subject).to include place_5, place_6
37
38
  end
38
39
 
39
- it "wraps values in a Place" do
40
- subject.public_send attr, {address: "four"}
40
+ it 'wraps values in a Place' do
41
+ subject.public_send attr, address: 'four'
41
42
 
42
43
  expect(subject.all? { |place| place.is_a? GoogleDistanceMatrix::Place }).to be true
43
- expect(subject.any? { |place| place.address == "four" }).to be true
44
+ expect(subject.any? { |place| place.address == 'four' }).to be true
44
45
  end
45
46
  end
46
47
  end
47
48
 
48
49
  %w[push unshift].each do |attr|
49
- describe "#{attr}" do
50
- it "adds multiple values at once" do
50
+ describe attr.to_s do
51
+ it 'adds multiple values at once' do
51
52
  subject.public_send attr, place_4, place_5
52
53
  expect(subject).to include place_4, place_5
53
54
  end
54
55
  end
55
56
  end
56
57
 
57
- describe "#concat" do
58
+ describe '#concat' do
58
59
  let(:places_2) { [place_4, place_5, place_6] }
59
60
 
60
- it "adds the given array" do
61
+ it 'adds the given array' do
61
62
  subject.concat places_2
62
- expect(subject).to include *places_2
63
+ expect(subject).to include(*places_2)
63
64
  end
64
65
 
65
- it "keeps values uniq" do
66
+ it 'keeps values uniq' do
66
67
  subject.concat places_2
67
68
 
68
- expect {
69
+ expect do
69
70
  subject.concat places_2
70
- }.to_not change subject, :length
71
+ end.to_not change subject, :length
71
72
  end
72
73
 
73
- it "returns self" do
74
- expect(subject.concat places_2).to eq subject
74
+ it 'returns self' do
75
+ expect(subject.concat(places_2)).to eq subject
75
76
  end
76
77
  end
77
78
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module GoogleDistanceMatrix
@@ -6,9 +8,9 @@ module GoogleDistanceMatrix
6
8
  deltas = subject.deltas_rounded [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]
7
9
 
8
10
  expect(deltas).to eq [
9
- 3850000, -12020000,
10
- 220000, -75000,
11
- 255200, -550300
11
+ 3_850_000, -12_020_000,
12
+ 220_000, -75_000,
13
+ 255_200, -550_300
12
14
  ]
13
15
  end
14
16
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module GoogleDistanceMatrix
@@ -5,12 +7,15 @@ module GoogleDistanceMatrix
5
7
  tests = {
6
8
  [[-179.9832104, -179.9832104]] => '`~oia@`~oia@',
7
9
  [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] => '_p~iF~ps|U_ulLnnqC_mqNvxq`@',
8
- [[41.3522171071184, -86.0456299662023],[41.3522171071183, -86.0454368471533]] => 'krk{FdxdlO?e@'
10
+ [
11
+ [41.3522171071184, -86.0456299662023],
12
+ [41.3522171071183, -86.0454368471533]
13
+ ] => 'krk{FdxdlO?e@'
9
14
  }
10
15
 
11
16
  tests.each_pair do |lat_lng_values, expected|
12
17
  it "encodes #{lat_lng_values} to #{expected}" do
13
- expect(described_class.encode lat_lng_values).to eq expected
18
+ expect(described_class.encode(lat_lng_values)).to eq expected
14
19
  end
15
20
  end
16
21
  end
@@ -1,24 +1,26 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
2
4
 
3
5
  describe GoogleDistanceMatrix::Route do
4
6
  let(:attributes) do
5
7
  {
6
- "distance" => {"text" => "2.0 km", "value" => 2032},
7
- "duration" => {"text" =>"6 mins", "value" => 367},
8
- "duration_in_traffic" => {"text" =>"5 mins", "value" => 301},
9
- "status" =>"OK"
8
+ 'distance' => { 'text' => '2.0 km', 'value' => 2032 },
9
+ 'duration' => { 'text' => '6 mins', 'value' => 367 },
10
+ 'duration_in_traffic' => { 'text' => '5 mins', 'value' => 301 },
11
+ 'status' => 'OK'
10
12
  }
11
13
  end
12
14
 
13
15
  subject { described_class.new attributes }
14
16
 
15
- it { expect(subject.status).to eq "ok" }
17
+ it { expect(subject.status).to eq 'ok' }
16
18
  it { expect(subject.distance_in_meters).to eq 2032 }
17
- it { expect(subject.distance_text).to eq "2.0 km" }
19
+ it { expect(subject.distance_text).to eq '2.0 km' }
18
20
  it { expect(subject.duration_in_seconds).to eq 367 }
19
- it { expect(subject.duration_text).to eq "6 mins" }
21
+ it { expect(subject.duration_text).to eq '6 mins' }
20
22
  it { expect(subject.duration_in_traffic_in_seconds).to eq 301 }
21
- it { expect(subject.duration_in_traffic_text).to eq "5 mins" }
23
+ it { expect(subject.duration_in_traffic_text).to eq '5 mins' }
22
24
 
23
25
  it { is_expected.to be_ok }
24
26
  end
@@ -1,16 +1,18 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
2
4
 
3
5
  describe GoogleDistanceMatrix::RoutesFinder, :request_recordings do
4
- let(:origin_1) { GoogleDistanceMatrix::Place.new address: "Karl Johans gate, Oslo" }
5
- let(:origin_2) { GoogleDistanceMatrix::Place.new address: "Askerveien 1, Asker" }
6
+ let(:origin_1) { GoogleDistanceMatrix::Place.new address: 'Karl Johans gate, Oslo' }
7
+ let(:origin_2) { GoogleDistanceMatrix::Place.new address: 'Askerveien 1, Asker' }
6
8
 
7
- let(:destination_1) { GoogleDistanceMatrix::Place.new address: "Drammensveien 1, Oslo" }
9
+ let(:destination_1) { GoogleDistanceMatrix::Place.new address: 'Drammensveien 1, Oslo' }
8
10
 
9
- let(:destination_2_built_from) { double address: "Skjellestadhagen, Heggedal" }
11
+ let(:destination_2_built_from) { double address: 'Skjellestadhagen, Heggedal' }
10
12
  let(:destination_2) { GoogleDistanceMatrix::Place.new destination_2_built_from }
11
13
 
12
14
  let(:url_builder) { GoogleDistanceMatrix::UrlBuilder.new matrix }
13
- let(:url) { url_builder.url }
15
+ let(:url) { url_builder.sensitive_url }
14
16
 
15
17
  let(:matrix) do
16
18
  GoogleDistanceMatrix::Matrix.new(
@@ -21,55 +23,61 @@ describe GoogleDistanceMatrix::RoutesFinder, :request_recordings do
21
23
 
22
24
  subject { described_class.new matrix }
23
25
 
24
- context "success, with traffic data" do
26
+ context 'success, with traffic data' do
25
27
  before do
26
28
  matrix.configure do |c|
27
29
  c.departure_time = 'now'
28
30
  end
29
31
  end
30
32
 
31
- let!(:api_request_stub) { stub_request(:get, url).to_return body: recorded_request_for(:success_with_in_traffic) }
33
+ let!(:api_request_stub) do
34
+ stub_request(:get, url).to_return body: recorded_request_for(:success_with_in_traffic)
35
+ end
32
36
 
33
- describe "#shortest_route_by_duration_in_traffic_to" do
34
- it "returns route representing shortest duration to given origin" do
37
+ describe '#shortest_route_by_duration_in_traffic_to' do
38
+ it 'returns route representing shortest duration to given origin' do
35
39
  expect(subject.shortest_route_by_duration_in_traffic_to(origin_1)).to eq matrix.data[0][0]
36
40
  end
37
41
 
38
- it "returns route representing shortest duration to given destination" do
39
- expect(subject.shortest_route_by_duration_in_traffic_to(destination_2)).to eq matrix.data[1][1]
42
+ it 'returns route representing shortest duration to given destination' do
43
+ expect(subject.shortest_route_by_duration_in_traffic_to(destination_2))
44
+ .to eq matrix.data[1][1]
40
45
  end
41
46
  end
42
47
 
43
- describe "#shortest_route_by_duration_in_traffic_to!" do
44
- it "returns the same as shortest_route_by_duration_in_traffic_to" do
45
- expect(subject.shortest_route_by_duration_in_traffic_to!(origin_1)).to eq subject.shortest_route_by_duration_in_traffic_to(origin_1)
48
+ describe '#shortest_route_by_duration_in_traffic_to!' do
49
+ it 'returns the same as shortest_route_by_duration_in_traffic_to' do
50
+ expect(subject.shortest_route_by_duration_in_traffic_to!(origin_1))
51
+ .to eq subject.shortest_route_by_duration_in_traffic_to(origin_1)
46
52
  end
47
53
  end
48
54
  end
49
55
 
50
- context "success, without in traffic data" do
51
- let!(:api_request_stub) { stub_request(:get, url).to_return body: recorded_request_for(:success) }
56
+ context 'success, without in traffic data' do
57
+ let!(:api_request_stub) do
58
+ stub_request(:get, url).to_return body: recorded_request_for(:success)
59
+ end
52
60
 
53
- describe "#routes_for" do
54
- it "fails if given place does not exist" do
55
- expect { subject.routes_for "foo" }.to raise_error ArgumentError
61
+ describe '#routes_for' do
62
+ it 'fails if given place does not exist' do
63
+ expect { subject.routes_for 'foo' }.to raise_error ArgumentError
56
64
  end
57
65
 
58
- it "returns routes for given origin" do
66
+ it 'returns routes for given origin' do
59
67
  routes = subject.routes_for origin_1
60
68
 
61
69
  expect(routes.length).to eq 2
62
70
  expect(routes.map(&:origin).all? { |o| o == origin_1 }).to be true
63
71
  end
64
72
 
65
- it "returns routes for given destination" do
73
+ it 'returns routes for given destination' do
66
74
  routes = subject.routes_for destination_2
67
75
 
68
76
  expect(routes.length).to eq 2
69
77
  expect(routes.map(&:destination).all? { |d| d == destination_2 }).to be true
70
78
  end
71
79
 
72
- it "returns routes for given object a place was built from" do
80
+ it 'returns routes for given object a place was built from' do
73
81
  routes = subject.routes_for destination_2_built_from
74
82
 
75
83
  expect(routes.length).to eq 2
@@ -77,40 +85,42 @@ describe GoogleDistanceMatrix::RoutesFinder, :request_recordings do
77
85
  end
78
86
  end
79
87
 
80
- describe "#routes_for!" do
81
- it "returns the same as routes_for" do
82
- expect(subject.routes_for! origin_1).to eq subject.routes_for(origin_1)
88
+ describe '#routes_for!' do
89
+ it 'returns the same as routes_for' do
90
+ expect(subject.routes_for!(origin_1)).to eq subject.routes_for(origin_1)
83
91
  end
84
92
  end
85
93
 
86
- describe "#route_for" do
87
- it "returns route" do
94
+ describe '#route_for' do
95
+ it 'returns route' do
88
96
  route = subject.route_for(origin: origin_1, destination: destination_1)
89
97
  expect(route.origin).to eq origin_1
90
98
  expect(route.destination).to eq destination_1
91
99
  end
92
100
 
93
- it "returns route when you give it the object a place was built from" do
101
+ it 'returns route when you give it the object a place was built from' do
94
102
  route = subject.route_for(origin: origin_1, destination: destination_2_built_from)
95
103
  expect(route.origin).to eq origin_1
96
104
  expect(route.destination).to eq destination_2
97
105
  end
98
106
 
99
- it "fails with argument error if origin is missing" do
107
+ it 'fails with argument error if origin is missing' do
100
108
  expect { subject.route_for destination: destination_2 }.to raise_error ArgumentError
101
109
  end
102
110
 
103
- it "fails with argument error if destination is missing" do
111
+ it 'fails with argument error if destination is missing' do
104
112
  expect { subject.route_for origin: origin_1 }.to raise_error ArgumentError
105
113
  end
106
114
 
107
- it "fails with argument error if sent in object is neither place nor something it was built from" do
108
- expect { subject.route_for origin: origin_1, destination: double }.to raise_error ArgumentError
115
+ it 'fails with argument error if object is neither place nor something it was built from' do
116
+ expect do
117
+ subject.route_for origin: origin_1, destination: double
118
+ end.to raise_error ArgumentError
109
119
  end
110
120
  end
111
121
 
112
- describe "#route_for!" do
113
- it "returns the same as route_for" do
122
+ describe '#route_for!' do
123
+ it 'returns the same as route_for' do
114
124
  route = subject.route_for(origin: origin_1, destination: destination_1)
115
125
  route_bang = subject.route_for!(origin: origin_1, destination: destination_1)
116
126
 
@@ -118,60 +128,64 @@ describe GoogleDistanceMatrix::RoutesFinder, :request_recordings do
118
128
  end
119
129
  end
120
130
 
121
- describe "#shortest_route_by_distance_to" do
122
- it "returns route representing shortest distance to given origin" do
131
+ describe '#shortest_route_by_distance_to' do
132
+ it 'returns route representing shortest distance to given origin' do
123
133
  expect(subject.shortest_route_by_distance_to(origin_1)).to eq matrix.data[0][0]
124
134
  end
125
135
 
126
- it "returns route representing shortest distance to given destination" do
136
+ it 'returns route representing shortest distance to given destination' do
127
137
  expect(subject.shortest_route_by_distance_to(destination_2)).to eq matrix.data[1][1]
128
138
  end
129
139
  end
130
140
 
131
- describe "#shortest_route_by_distance_to!" do
132
- it "returns the same as shortest_route_by_distance_to" do
133
- expect(subject.shortest_route_by_distance_to!(origin_1)).to eq subject.shortest_route_by_distance_to(origin_1)
141
+ describe '#shortest_route_by_distance_to!' do
142
+ it 'returns the same as shortest_route_by_distance_to' do
143
+ expect(subject.shortest_route_by_distance_to!(origin_1))
144
+ .to eq subject.shortest_route_by_distance_to(origin_1)
134
145
  end
135
146
  end
136
147
 
137
- describe "#shortest_route_by_duration_to" do
138
- it "returns route representing shortest duration to given origin" do
148
+ describe '#shortest_route_by_duration_to' do
149
+ it 'returns route representing shortest duration to given origin' do
139
150
  expect(subject.shortest_route_by_duration_to(origin_1)).to eq matrix.data[0][0]
140
151
  end
141
152
 
142
- it "returns route representing shortest duration to given destination" do
153
+ it 'returns route representing shortest duration to given destination' do
143
154
  expect(subject.shortest_route_by_duration_to(destination_2)).to eq matrix.data[1][1]
144
155
  end
145
156
  end
146
157
 
147
- describe "#shortest_route_by_duration_to!" do
148
- it "returns the same as shortest_route_by_duration_to" do
149
- expect(subject.shortest_route_by_duration_to!(origin_1)).to eq subject.shortest_route_by_duration_to(origin_1)
158
+ describe '#shortest_route_by_duration_to!' do
159
+ it 'returns the same as shortest_route_by_duration_to' do
160
+ expect(subject.shortest_route_by_duration_to!(origin_1))
161
+ .to eq subject.shortest_route_by_duration_to(origin_1)
150
162
  end
151
163
  end
152
164
 
153
- describe "#shortest_route_by_duration_in_traffic_to" do
154
- it "returns route representing shortest duration to given origin" do
155
- expect {
165
+ describe '#shortest_route_by_duration_in_traffic_to' do
166
+ it 'returns route representing shortest duration to given origin' do
167
+ expect do
156
168
  subject.shortest_route_by_duration_in_traffic_to(origin_1)
157
- }.to raise_error GoogleDistanceMatrix::InvalidQuery
169
+ end.to raise_error GoogleDistanceMatrix::InvalidQuery
158
170
  end
159
171
  end
160
172
 
161
- describe "#shortest_route_by_duration_in_traffic_to!" do
162
- it "returns the same as shortest_route_by_duration_in_traffic_to" do
163
- expect {
173
+ describe '#shortest_route_by_duration_in_traffic_to!' do
174
+ it 'returns the same as shortest_route_by_duration_in_traffic_to' do
175
+ expect do
164
176
  subject.shortest_route_by_duration_in_traffic_to!(origin_1)
165
- }.to raise_error GoogleDistanceMatrix::InvalidQuery
177
+ end.to raise_error GoogleDistanceMatrix::InvalidQuery
166
178
  end
167
179
  end
168
180
  end
169
181
 
170
- context "routes mssing data" do
171
- let!(:api_request_stub) { stub_request(:get, url).to_return body: recorded_request_for(:zero_results) }
182
+ context 'routes mssing data' do
183
+ let!(:api_request_stub) do
184
+ stub_request(:get, url).to_return body: recorded_request_for(:zero_results)
185
+ end
172
186
 
173
- describe "#routes_for" do
174
- it "returns routes for given origin" do
187
+ describe '#routes_for' do
188
+ it 'returns routes for given origin' do
175
189
  routes = subject.routes_for origin_1
176
190
 
177
191
  expect(routes.length).to eq 2
@@ -179,53 +193,53 @@ describe GoogleDistanceMatrix::RoutesFinder, :request_recordings do
179
193
  end
180
194
  end
181
195
 
182
- describe "#routes_for!" do
183
- it "fails upon any non-ok route" do
184
- expect {
196
+ describe '#routes_for!' do
197
+ it 'fails upon any non-ok route' do
198
+ expect do
185
199
  subject.routes_for! origin_1
186
- }.to raise_error GoogleDistanceMatrix::InvalidRoute
200
+ end.to raise_error GoogleDistanceMatrix::InvalidRoute
187
201
  end
188
202
  end
189
203
 
190
-
191
- describe "#route_for" do
192
- it "returns route" do
204
+ describe '#route_for' do
205
+ it 'returns route' do
193
206
  route = subject.route_for origin: origin_1, destination: destination_2
194
207
  expect(route.origin).to eq origin_1
195
208
  expect(route.destination).to eq destination_2
196
209
  end
197
210
  end
198
211
 
199
- describe "#route_for!" do
200
- it "fails upon non-ok route" do
201
- expect {
212
+ describe '#route_for!' do
213
+ it 'fails upon non-ok route' do
214
+ expect do
202
215
  subject.route_for! origin: origin_1, destination: destination_2
203
- }.to raise_error GoogleDistanceMatrix::InvalidRoute
216
+ end.to raise_error GoogleDistanceMatrix::InvalidRoute
204
217
  end
205
218
  end
206
219
 
207
-
208
- describe "#shortest_route_by_distance_to" do
209
- it "returns route representing shortest distance to given origin" do
220
+ describe '#shortest_route_by_distance_to' do
221
+ it 'returns route representing shortest distance to given origin' do
210
222
  expect(subject.shortest_route_by_distance_to(origin_1)).to eq matrix.data[0][0]
211
223
  end
212
224
  end
213
225
 
214
- describe "#shortest_route_by_distance_to!" do
215
- it "fails upon non-ok route" do
216
- expect { subject.shortest_route_by_distance_to!(origin_1) }.to raise_error GoogleDistanceMatrix::InvalidRoute
226
+ describe '#shortest_route_by_distance_to!' do
227
+ it 'fails upon non-ok route' do
228
+ expect { subject.shortest_route_by_distance_to!(origin_1) }
229
+ .to raise_error GoogleDistanceMatrix::InvalidRoute
217
230
  end
218
231
  end
219
232
 
220
- describe "#shortest_route_by_duration_to" do
221
- it "returns route representing shortest distance to given origin" do
233
+ describe '#shortest_route_by_duration_to' do
234
+ it 'returns route representing shortest distance to given origin' do
222
235
  expect(subject.shortest_route_by_duration_to(origin_1)).to eq matrix.data[0][0]
223
236
  end
224
237
  end
225
238
 
226
- describe "#shortest_route_by_duration_to!" do
227
- it "fails upon non-ok route" do
228
- expect { subject.shortest_route_by_duration_to!(origin_1) }.to raise_error GoogleDistanceMatrix::InvalidRoute
239
+ describe '#shortest_route_by_duration_to!' do
240
+ it 'fails upon non-ok route' do
241
+ expect { subject.shortest_route_by_duration_to!(origin_1) }
242
+ .to raise_error GoogleDistanceMatrix::InvalidRoute
229
243
  end
230
244
  end
231
245
  end