google_places 0.21.0 → 0.22.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 +4 -4
- data/Gemfile.lock +27 -17
- data/google_places.gemspec +11 -11
- data/lib/google_places/spot.rb +3 -2
- data/spec/google_places/client_spec.rb +8 -8
- data/spec/google_places/location_spec.rb +1 -1
- data/spec/google_places/photo_spec.rb +4 -5
- data/spec/google_places/request_spec.rb +40 -89
- data/spec/google_places/spot_spec.rb +34 -98
- data/spec/spec_helper.rb +1 -5
- data/spec/vcr_cassettes/list_spots.yml +6005 -1980
- data/spec/vcr_cassettes/list_spots_by_radar.yml +1095 -28
- data/spec/vcr_cassettes/list_spots_with_multiple_types.yml +3563 -1368
- data/spec/vcr_cassettes/list_spots_with_name.yml +216 -57
- data/spec/vcr_cassettes/list_spots_with_name_and_types.yml +216 -57
- data/spec/vcr_cassettes/list_spots_with_single_type.yml +1103 -381
- data/spec/vcr_cassettes/list_spots_with_types_and_exclusion.yml +3564 -1368
- data/spec/vcr_cassettes/multiple_page_request.yml +2809 -391
- data/spec/vcr_cassettes/photo.yml +43 -2
- data/spec/vcr_cassettes/premium_list_spots_with_data.yml +503 -184
- data/spec/vcr_cassettes/single_spot.yml +1155 -241
- data/spec/vcr_setup.rb +2 -1
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36355b632140bf6ebad9a1f19d6fb067dd956d8
|
4
|
+
data.tar.gz: 9fe83b73519827f1770d121672a3b21a5ef82bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256fa11719e1c5523d839b9e6e9ce817721f4b84b415a30c100d0fad9daaa0356be20d75ccbc266981bf704d45065c4fc90a9e76360e89a02c9f7a042d56c5f3
|
7
|
+
data.tar.gz: efeb854f9aca0e29775d8e85c9ed1a22f9b7dc6e2ea719a2d9388ed09753012a4406b44c28ffcf72c583269d6b5ab24f3c9d76baa195ad4be23fe876bdc4b32f
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
google_places (0.
|
5
|
-
httparty
|
4
|
+
google_places (0.22.0)
|
5
|
+
httparty (~> 0.13.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
addressable (2.3.6)
|
11
|
+
crack (0.4.2)
|
12
|
+
safe_yaml (~> 1.0.0)
|
13
|
+
diff-lcs (1.2.5)
|
14
|
+
httparty (0.13.1)
|
13
15
|
json (~> 1.8)
|
14
16
|
multi_xml (>= 0.5.2)
|
15
17
|
json (1.8.1)
|
16
18
|
multi_xml (0.5.5)
|
17
|
-
rspec (
|
18
|
-
rspec-core (~>
|
19
|
-
rspec-expectations (~>
|
20
|
-
rspec-mocks (~>
|
21
|
-
rspec-core (
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
rspec (3.0.0)
|
20
|
+
rspec-core (~> 3.0.0)
|
21
|
+
rspec-expectations (~> 3.0.0)
|
22
|
+
rspec-mocks (~> 3.0.0)
|
23
|
+
rspec-core (3.0.2)
|
24
|
+
rspec-support (~> 3.0.0)
|
25
|
+
rspec-expectations (3.0.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.0.0)
|
28
|
+
rspec-mocks (3.0.2)
|
29
|
+
rspec-support (~> 3.0.0)
|
30
|
+
rspec-support (3.0.2)
|
31
|
+
safe_yaml (1.0.3)
|
32
|
+
vcr (2.9.2)
|
33
|
+
webmock (1.18.0)
|
34
|
+
addressable (>= 2.3.6)
|
35
|
+
crack (>= 0.3.2)
|
26
36
|
|
27
37
|
PLATFORMS
|
28
38
|
ruby
|
29
39
|
|
30
40
|
DEPENDENCIES
|
31
|
-
fakeweb
|
32
41
|
google_places!
|
33
|
-
rspec
|
34
|
-
vcr
|
42
|
+
rspec (~> 3.0.0)
|
43
|
+
vcr (~> 2.9.2)
|
44
|
+
webmock (~> 1.18.0)
|
data/google_places.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
6
|
-
s.version = '0.
|
5
|
+
s.name = 'google_places'
|
6
|
+
s.version = '0.22.0'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Marcel de Graaf']
|
9
|
+
s.email = ['mail@marceldegraaf.net']
|
10
|
+
s.homepage = 'https://github.com/marceldegraaf/google_places'
|
11
11
|
s.summary = %q{A Ruby wrapper around the Google Places API.}
|
12
12
|
s.description = %q{This gem provides a Ruby wrapper around the Google Places API for use in your own project. Please note that this gem does not provide OAuth authentication.}
|
13
13
|
s.license = 'MIT'
|
@@ -15,10 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
-
s.require_paths = [
|
18
|
+
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.add_dependency 'httparty'
|
21
|
-
s.add_development_dependency 'rspec'
|
22
|
-
s.add_development_dependency '
|
23
|
-
s.add_development_dependency 'vcr'
|
20
|
+
s.add_dependency 'httparty', '~> 0.13.1'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.0.0'
|
22
|
+
s.add_development_dependency 'webmock', '~> 1.18.0'
|
23
|
+
s.add_development_dependency 'vcr', '~> 2.9.2'
|
24
24
|
end
|
data/lib/google_places/spot.rb
CHANGED
@@ -2,7 +2,7 @@ require 'google_places/review'
|
|
2
2
|
|
3
3
|
module GooglePlaces
|
4
4
|
class Spot
|
5
|
-
attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :international_phone_number, :formatted_address, :address_components, :street_number, :street, :city, :region, :postal_code, :country, :rating, :url, :cid, :website, :reviews, :aspects, :zagat_selected, :zagat_reviewed, :photos, :review_summary, :nextpagetoken, :price_level, :opening_hours, :events, :utc_offset
|
5
|
+
attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :international_phone_number, :formatted_address, :address_components, :street_number, :street, :city, :region, :postal_code, :country, :rating, :url, :cid, :website, :reviews, :aspects, :zagat_selected, :zagat_reviewed, :photos, :review_summary, :nextpagetoken, :price_level, :opening_hours, :events, :utc_offset, :place_id
|
6
6
|
|
7
7
|
# Search for Spots at the provided location
|
8
8
|
#
|
@@ -27,7 +27,7 @@ module GooglePlaces
|
|
27
27
|
# the number of check-ins from your application, global popularity, and other factors.
|
28
28
|
# - distance. This option sorts results in ascending order by their distance from the specified location.
|
29
29
|
# Ranking results by distance will set a fixed search radius of 50km.
|
30
|
-
# One or more of keyword, name, or types is required.
|
30
|
+
# One or more of keyword, name, or types is required.
|
31
31
|
# @option options [String,Array] :types
|
32
32
|
# Restricts the results to Spots matching at least one of the specified types
|
33
33
|
# @option options [String] :name
|
@@ -363,6 +363,7 @@ module GooglePlaces
|
|
363
363
|
# @return [Spot] a newly created spot
|
364
364
|
def initialize(json_result_object, api_key, sensor)
|
365
365
|
@reference = json_result_object['reference']
|
366
|
+
@place_id = json_result_object['place_id']
|
366
367
|
@vicinity = json_result_object['vicinity']
|
367
368
|
@lat = json_result_object['geometry']['location']['lat']
|
368
369
|
@lng = json_result_object['geometry']['location']['lng']
|
@@ -4,39 +4,39 @@ describe GooglePlaces::Client do
|
|
4
4
|
|
5
5
|
it 'should initialize with an api_key' do
|
6
6
|
@client = GooglePlaces::Client.new(api_key)
|
7
|
-
@client.api_key.
|
7
|
+
expect(@client.api_key).to eq(api_key)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should request spots' do
|
11
11
|
lat, lng = '-33.8670522', '151.1957362'
|
12
12
|
@client = GooglePlaces::Client.new(api_key)
|
13
|
-
GooglePlaces::Spot.
|
13
|
+
expect(GooglePlaces::Spot).to receive(:list).with(lat, lng, api_key, false, {})
|
14
14
|
|
15
15
|
@client.spots(lat, lng)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should request a single spot' do
|
19
|
-
reference =
|
19
|
+
reference = 'CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA'
|
20
20
|
@client = GooglePlaces::Client.new(api_key)
|
21
|
-
GooglePlaces::Spot.
|
21
|
+
expect(GooglePlaces::Spot).to receive(:find).with(reference, api_key, false, {})
|
22
22
|
|
23
23
|
@client.spot(reference)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should request spots by query' do
|
27
|
-
query =
|
27
|
+
query = 'Statue of liberty, New York'
|
28
28
|
@client = GooglePlaces::Client.new(api_key)
|
29
|
-
GooglePlaces::Spot.
|
29
|
+
expect(GooglePlaces::Spot).to receive(:list_by_query).with(query, api_key, false, {})
|
30
30
|
|
31
31
|
@client.spots_by_query(query)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should request spots by radar' do
|
35
|
-
keywords =
|
35
|
+
keywords = 'landmarks'
|
36
36
|
lat, lng = '51.511627', '-0.183778'
|
37
37
|
radius = 5000
|
38
38
|
@client = GooglePlaces::Client.new(api_key)
|
39
|
-
GooglePlaces::Spot.
|
39
|
+
expect(GooglePlaces::Spot).to receive(:list_by_radar).with(lat, lng, api_key, false, {:radius=> radius, :keyword => keywords})
|
40
40
|
|
41
41
|
@client.spots_by_radar(lat, lng, :radius => radius, :keyword => keywords)
|
42
42
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe GooglePlaces::Location do
|
4
4
|
|
5
5
|
it 'should return a location based on a lat and lng' do
|
6
|
-
GooglePlaces::Location.new('123', '456').format.
|
6
|
+
expect(GooglePlaces::Location.new('123', '456').format).to eq('123.00000000,456.00000000')
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -8,22 +8,21 @@ describe GooglePlaces::Photo do
|
|
8
8
|
@photo_reference = "CnRtAAAACQQXR83Jc3Pffxt1Zx7QbCe6AfY2negSNzkk2IeSf0q5nxHgartLzkr1fltSlkEDSS-EZqswWAW2eQDbiOl12J-V4Rmn_JNko9e9gSnMwxHBdmScu_84NMSe-0RwB9BM6AEqE8sENXQ8cpWaiEsC_RIQLzIJxpRdoqSPrPtrjTrOhxoUWb8uwObkV4duXfKIiNB20gfnu88"
|
9
9
|
end
|
10
10
|
|
11
|
-
context 'Photo' do
|
12
|
-
use_vcr_cassette 'photo'
|
11
|
+
context 'Photo', vcr: { cassette_name: 'photo'} do
|
13
12
|
before :each do
|
14
13
|
@photo = GooglePlaces::Photo.new(400, 400, @photo_reference, [], api_key, @sensor)
|
15
14
|
end
|
16
15
|
it 'should be a Photo' do
|
17
|
-
@photo.class.
|
16
|
+
expect(@photo.class).to eq(GooglePlaces::Photo)
|
18
17
|
end
|
19
18
|
%w(width height photo_reference html_attributions).each do |attribute|
|
20
19
|
it "should have the attribute: #{attribute}" do
|
21
|
-
@photo.respond_to?(attribute).
|
20
|
+
expect(@photo.respond_to?(attribute)).to eq(true)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
it 'should return a url when fetched' do
|
25
24
|
url = @photo.fetch_url(@max_width)
|
26
|
-
url.
|
25
|
+
expect(url).to_not be_empty
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
@@ -4,16 +4,15 @@ describe GooglePlaces::Request do
|
|
4
4
|
|
5
5
|
before :each do
|
6
6
|
@location = GooglePlaces::Location.new('-33.8670522', '151.1957362').format
|
7
|
-
@query =
|
7
|
+
@query = 'Statue of liberty, New York'
|
8
8
|
@radius = 200
|
9
9
|
@sensor = false
|
10
|
-
@reference =
|
11
|
-
@reference_not_found =
|
12
|
-
@keyword =
|
10
|
+
@reference = 'CnRsAAAASc4grenwL0h3X5VPNp5fkDNfqbjt3iQtWIPlKS-3ms9GbnCxR_FLHO0B0ZKCgJSg19qymkeHagjQFB4aUL87yhp4mhFTc17DopK1oiYDaeGthztSjERic8TmFNe-6zOpKSdiZWKE6xlQvcbSiWIJchIQOEYZqunSSZqNDoBSs77bWRoUJcMMVANtSlhy0llKI0MI6VcC7DU'
|
11
|
+
@reference_not_found = 'CnRpAAAAlO2WvF_4eOqp02TAWKsXpPSCFz8KxBjraWhB4MSvdUPqXN0yCpxQgblam1LeRENcWZF-9-2CEfUwlHUli61PaYe0e7dUPAU302tk6KkalnKqx7nv07iFA1Ca_Y1WoCLH9adEWwkxKMITlbGhUUz9-hIQPxQ4Bp_dz5nHloUFkj3rkBoUDSPqy2smqMnPEo4ayfbDupeKEZY'
|
12
|
+
@keyword = 'attractions'
|
13
13
|
end
|
14
14
|
|
15
|
-
context 'Listing spots' do
|
16
|
-
use_vcr_cassette 'list_spots'
|
15
|
+
context 'Listing spots', vcr: { cassette_name: 'list_spots' } do
|
17
16
|
context 'with valid options' do
|
18
17
|
it 'should retrieve a list of spots' do
|
19
18
|
response = GooglePlaces::Request.spots(
|
@@ -22,36 +21,25 @@ describe GooglePlaces::Request do
|
|
22
21
|
:sensor => @sensor,
|
23
22
|
:key => api_key
|
24
23
|
)
|
25
|
-
response['results'].
|
26
|
-
end
|
27
|
-
end
|
28
|
-
context 'with missing sensor' do
|
29
|
-
it do
|
30
|
-
lambda {
|
31
|
-
GooglePlaces::Request.spots(
|
32
|
-
:location => @location,
|
33
|
-
:radius => @radius,
|
34
|
-
:key => api_key
|
35
|
-
)
|
36
|
-
}.should raise_error GooglePlaces::RequestDeniedError
|
24
|
+
expect(response['results']).to_not be_empty
|
37
25
|
end
|
38
26
|
end
|
39
27
|
context 'without location' do
|
40
28
|
context 'without retry options' do
|
41
29
|
it do
|
42
|
-
lambda {
|
30
|
+
expect(lambda {
|
43
31
|
GooglePlaces::Request.spots(
|
44
32
|
:radius => @radius,
|
45
33
|
:sensor => @sensor,
|
46
34
|
:key => api_key
|
47
35
|
)
|
48
|
-
}.
|
36
|
+
}).to raise_error GooglePlaces::InvalidRequestError
|
49
37
|
end
|
50
38
|
end
|
51
39
|
context 'with retry options' do
|
52
40
|
context 'without timeout' do
|
53
41
|
it do
|
54
|
-
lambda {
|
42
|
+
expect(lambda {
|
55
43
|
GooglePlaces::Request.spots(
|
56
44
|
:radius => @radius,
|
57
45
|
:sensor => @sensor,
|
@@ -62,12 +50,12 @@ describe GooglePlaces::Request do
|
|
62
50
|
:delay => 1
|
63
51
|
}
|
64
52
|
)
|
65
|
-
}.
|
53
|
+
}).to raise_error GooglePlaces::RetryError
|
66
54
|
end
|
67
55
|
end
|
68
56
|
context 'with timeout' do
|
69
57
|
it do
|
70
|
-
lambda {
|
58
|
+
expect(lambda {
|
71
59
|
GooglePlaces::Request.spots(
|
72
60
|
:radius => @radius,
|
73
61
|
:sensor => @sensor,
|
@@ -79,7 +67,7 @@ describe GooglePlaces::Request do
|
|
79
67
|
:timeout => 1
|
80
68
|
}
|
81
69
|
)
|
82
|
-
}.
|
70
|
+
}).to raise_error GooglePlaces::RetryTimeoutError
|
83
71
|
end
|
84
72
|
end
|
85
73
|
end
|
@@ -87,8 +75,7 @@ describe GooglePlaces::Request do
|
|
87
75
|
end
|
88
76
|
|
89
77
|
|
90
|
-
context 'Listing spots by query' do
|
91
|
-
use_vcr_cassette 'list_spots'
|
78
|
+
context 'Listing spots by query', vcr: { cassette_name: 'list_spots' } do
|
92
79
|
|
93
80
|
context 'with valid options' do
|
94
81
|
it 'should retrieve a list of spots' do
|
@@ -98,37 +85,26 @@ describe GooglePlaces::Request do
|
|
98
85
|
:key => api_key
|
99
86
|
)
|
100
87
|
|
101
|
-
response['results'].
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'with missing sensor' do
|
106
|
-
it do
|
107
|
-
lambda {
|
108
|
-
GooglePlaces::Request.spots_by_query(
|
109
|
-
:query => @query,
|
110
|
-
:key => api_key
|
111
|
-
)
|
112
|
-
}.should raise_error GooglePlaces::RequestDeniedError
|
88
|
+
expect(response['results']).to_not be_empty
|
113
89
|
end
|
114
90
|
end
|
115
91
|
|
116
92
|
context 'without query' do
|
117
93
|
context 'without retry options' do
|
118
94
|
it do
|
119
|
-
lambda {
|
95
|
+
expect(lambda {
|
120
96
|
GooglePlaces::Request.spots_by_query(
|
121
97
|
:sensor => @sensor,
|
122
98
|
:key => api_key
|
123
99
|
)
|
124
|
-
}.
|
100
|
+
}).to raise_error GooglePlaces::InvalidRequestError
|
125
101
|
end
|
126
102
|
end
|
127
103
|
|
128
104
|
context 'with retry options' do
|
129
105
|
context 'without timeout' do
|
130
106
|
it do
|
131
|
-
lambda {
|
107
|
+
expect(lambda {
|
132
108
|
GooglePlaces::Request.spots_by_query(
|
133
109
|
:sensor => @sensor,
|
134
110
|
:key => api_key,
|
@@ -138,13 +114,13 @@ describe GooglePlaces::Request do
|
|
138
114
|
:delay => 1
|
139
115
|
}
|
140
116
|
)
|
141
|
-
}.
|
117
|
+
}).to raise_error GooglePlaces::RetryError
|
142
118
|
end
|
143
119
|
end
|
144
120
|
|
145
121
|
context 'with timeout' do
|
146
122
|
it do
|
147
|
-
lambda {
|
123
|
+
expect(lambda {
|
148
124
|
GooglePlaces::Request.spots_by_query(
|
149
125
|
:sensor => @sensor,
|
150
126
|
:key => api_key,
|
@@ -155,15 +131,14 @@ describe GooglePlaces::Request do
|
|
155
131
|
:timeout => 1
|
156
132
|
}
|
157
133
|
)
|
158
|
-
}.
|
134
|
+
}).to raise_error GooglePlaces::RetryTimeoutError
|
159
135
|
end
|
160
136
|
end
|
161
137
|
end
|
162
138
|
end
|
163
139
|
end
|
164
140
|
|
165
|
-
context 'Spot details' do
|
166
|
-
use_vcr_cassette 'single_spot'
|
141
|
+
context 'Spot details', vcr: { cassette_name: 'single_spot' } do
|
167
142
|
context 'with valid options' do
|
168
143
|
it 'should retrieve a single spot' do
|
169
144
|
response = GooglePlaces::Request.spot(
|
@@ -171,45 +146,35 @@ describe GooglePlaces::Request do
|
|
171
146
|
:sensor => @sensor,
|
172
147
|
:key => api_key
|
173
148
|
)
|
174
|
-
response['result'].
|
149
|
+
expect(response['result']).to_not be_empty
|
175
150
|
end
|
176
151
|
context 'with reference not found' do
|
177
|
-
it '
|
178
|
-
lambda {
|
152
|
+
it 'to raise not found error' do
|
153
|
+
expect(lambda {
|
179
154
|
GooglePlaces::Request.spot(
|
180
155
|
:reference => @reference_not_found,
|
181
156
|
:sensor => @sensor,
|
182
157
|
:key => api_key
|
183
158
|
)
|
184
|
-
}.
|
159
|
+
}).to raise_error GooglePlaces::NotFoundError
|
185
160
|
end
|
186
161
|
end
|
187
162
|
end
|
188
|
-
context 'with missing sensor' do
|
189
|
-
it do
|
190
|
-
lambda {
|
191
|
-
GooglePlaces::Request.spot(
|
192
|
-
:reference => @reference,
|
193
|
-
:key => api_key
|
194
|
-
)
|
195
|
-
}.should raise_error GooglePlaces::RequestDeniedError
|
196
|
-
end
|
197
|
-
end
|
198
163
|
context 'with missing reference' do
|
199
164
|
context 'without retry options' do
|
200
165
|
it do
|
201
|
-
lambda {
|
166
|
+
expect(lambda {
|
202
167
|
GooglePlaces::Request.spot(
|
203
168
|
:sensor => @sensor,
|
204
169
|
:key => api_key
|
205
170
|
)
|
206
|
-
}.
|
171
|
+
}).to raise_error GooglePlaces::InvalidRequestError
|
207
172
|
end
|
208
173
|
end
|
209
174
|
context 'with retry options' do
|
210
175
|
context 'without timeout' do
|
211
176
|
it do
|
212
|
-
lambda {
|
177
|
+
expect(lambda {
|
213
178
|
GooglePlaces::Request.spot(
|
214
179
|
:sensor => @sensor,
|
215
180
|
:key => api_key,
|
@@ -219,12 +184,12 @@ describe GooglePlaces::Request do
|
|
219
184
|
:delay => 1
|
220
185
|
}
|
221
186
|
)
|
222
|
-
}.
|
187
|
+
}).to raise_error GooglePlaces::RetryError
|
223
188
|
end
|
224
189
|
end
|
225
190
|
context 'with timeout' do
|
226
191
|
it do
|
227
|
-
lambda {
|
192
|
+
expect(lambda {
|
228
193
|
GooglePlaces::Request.spot(
|
229
194
|
:sensor => @sensor,
|
230
195
|
:key => api_key,
|
@@ -235,7 +200,7 @@ describe GooglePlaces::Request do
|
|
235
200
|
:timeout => 1
|
236
201
|
}
|
237
202
|
)
|
238
|
-
}.
|
203
|
+
}).to raise_error GooglePlaces::RetryTimeoutError
|
239
204
|
end
|
240
205
|
end
|
241
206
|
end
|
@@ -244,8 +209,7 @@ describe GooglePlaces::Request do
|
|
244
209
|
|
245
210
|
|
246
211
|
|
247
|
-
context 'Listing spots by radar' do
|
248
|
-
use_vcr_cassette 'list_spots_by_radar'
|
212
|
+
context 'Listing spots by radar', vcr: { cassette_name: 'list_spots_by_radar' } do
|
249
213
|
|
250
214
|
context 'with valid options' do
|
251
215
|
context 'with keyword' do
|
@@ -257,7 +221,7 @@ describe GooglePlaces::Request do
|
|
257
221
|
:sensor => @sensor,
|
258
222
|
:key => api_key
|
259
223
|
)
|
260
|
-
response['results'].
|
224
|
+
expect(response['results']).to_not be_empty
|
261
225
|
end
|
262
226
|
end
|
263
227
|
|
@@ -270,42 +234,29 @@ describe GooglePlaces::Request do
|
|
270
234
|
:sensor => @sensor,
|
271
235
|
:key => api_key
|
272
236
|
)
|
273
|
-
response['results'].
|
237
|
+
expect(response['results']).to_not be_empty
|
274
238
|
end
|
275
239
|
end
|
276
240
|
end
|
277
241
|
|
278
|
-
context 'with missing sensor' do
|
279
|
-
it do
|
280
|
-
lambda {
|
281
|
-
GooglePlaces::Request.spots_by_radar(
|
282
|
-
:location => @location,
|
283
|
-
:keyword => @keyword,
|
284
|
-
:radius => @radius,
|
285
|
-
:key => api_key
|
286
|
-
)
|
287
|
-
}.should raise_error GooglePlaces::RequestDeniedError
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
242
|
context 'without keyword' do
|
292
243
|
context 'without retry options' do
|
293
244
|
it do
|
294
|
-
lambda {
|
245
|
+
expect(lambda {
|
295
246
|
GooglePlaces::Request.spots_by_radar(
|
296
247
|
:location => @location,
|
297
248
|
:radius => @radius,
|
298
249
|
:sensor => @sensor,
|
299
250
|
:key => api_key
|
300
251
|
)
|
301
|
-
}.
|
252
|
+
}).to raise_error GooglePlaces::InvalidRequestError
|
302
253
|
end
|
303
254
|
end
|
304
255
|
|
305
256
|
context 'with retry options' do
|
306
257
|
context 'without timeout' do
|
307
258
|
it do
|
308
|
-
lambda {
|
259
|
+
expect(lambda {
|
309
260
|
GooglePlaces::Request.spots_by_radar(
|
310
261
|
:location => @location,
|
311
262
|
:radius => @radius,
|
@@ -317,13 +268,13 @@ describe GooglePlaces::Request do
|
|
317
268
|
:delay => 1
|
318
269
|
}
|
319
270
|
)
|
320
|
-
}.
|
271
|
+
}).to raise_error GooglePlaces::RetryError
|
321
272
|
end
|
322
273
|
end
|
323
274
|
|
324
275
|
context 'with timeout' do
|
325
276
|
it do
|
326
|
-
lambda {
|
277
|
+
expect(lambda {
|
327
278
|
GooglePlaces::Request.spots_by_radar(
|
328
279
|
:location => @location,
|
329
280
|
:radius => @radius,
|
@@ -336,7 +287,7 @@ describe GooglePlaces::Request do
|
|
336
287
|
:timeout => 1
|
337
288
|
}
|
338
289
|
)
|
339
|
-
}.
|
290
|
+
}).to raise_error GooglePlaces::RetryTimeoutError
|
340
291
|
end
|
341
292
|
end
|
342
293
|
end
|