yelp4r 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +41 -0
- data/Rakefile +60 -0
- data/VERSION.yml +5 -0
- data/examples/yelp.rb +166 -0
- data/lib/rubyify_keys.rb +29 -0
- data/lib/yelp4r/categories.rb +76 -0
- data/lib/yelp4r/client.rb +13 -0
- data/lib/yelp4r/neighborhood_search.rb +28 -0
- data/lib/yelp4r/neighborhoods.rb +85 -0
- data/lib/yelp4r/phone_search.rb +21 -0
- data/lib/yelp4r/response.rb +50 -0
- data/lib/yelp4r/review_search.rb +33 -0
- data/lib/yelp4r.rb +12 -0
- data/spec/fixtures/categories.html +40 -0
- data/spec/fixtures/neighborhoods.html +42 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +256 -0
- data/spec/yelp4r/categories_spec.rb +49 -0
- data/spec/yelp4r/client_spec.rb +22 -0
- data/spec/yelp4r/neighborhood_search_spec.rb +75 -0
- data/spec/yelp4r/neighborhoods_spec.rb +53 -0
- data/spec/yelp4r/phone_search_spec.rb +41 -0
- data/spec/yelp4r/review_search_spec.rb +163 -0
- metadata +126 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
<div>
|
4
|
+
<ul class="attr-list">
|
5
|
+
<li>Canada</li>
|
6
|
+
<ul>
|
7
|
+
<li>Vancouver, BC</li>
|
8
|
+
<ul>
|
9
|
+
<li>Ambleside</li>
|
10
|
+
<li>Yaletown</li>
|
11
|
+
</ul>
|
12
|
+
<li>Toronto, ON</li>
|
13
|
+
</ul>
|
14
|
+
<li>USA</li>
|
15
|
+
<ul>
|
16
|
+
<li>Berkeley, CA</li>
|
17
|
+
<ul>
|
18
|
+
<li>Claremont</li>
|
19
|
+
<li>Downtown Berkeley</li>
|
20
|
+
<li>East Solano Ave</li>
|
21
|
+
<li>Elmwood</li>
|
22
|
+
</ul>
|
23
|
+
<li>New York, NY</li>
|
24
|
+
<ul>
|
25
|
+
<li>Bronx</li>
|
26
|
+
<ul>
|
27
|
+
<li>Baychester</li>
|
28
|
+
<li>Bedford Park</li>
|
29
|
+
</ul>
|
30
|
+
<li>Brooklyn</li>
|
31
|
+
<ul>
|
32
|
+
<li>Bath Beach</li>
|
33
|
+
<li>Bay Ridge</li>
|
34
|
+
</ul>
|
35
|
+
<li>Staten Island</li>
|
36
|
+
</ul>
|
37
|
+
<li>Seattle, WA</li>
|
38
|
+
</ul>
|
39
|
+
</ul>
|
40
|
+
</div>
|
41
|
+
</body>
|
42
|
+
</html>
|
data/spec/rcov.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--exclude "spec/*"
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
require 'yelp4r'
|
11
|
+
|
12
|
+
module Yelp4rSpecHelper
|
13
|
+
|
14
|
+
def yelp4r_client
|
15
|
+
Yelp4r::Client.new('jprr4VyNVMGZrd-FARdSQA')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
module Yelp4rNeighsSpecHelper
|
21
|
+
|
22
|
+
def yelp4r_test_neighs_list
|
23
|
+
[
|
24
|
+
{"Canada" => [
|
25
|
+
{"Vancouver, BC" => [
|
26
|
+
"Ambleside", "Yaletown"
|
27
|
+
]
|
28
|
+
},
|
29
|
+
"Toronto, ON"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{"USA" => [
|
33
|
+
{"Berkeley, CA" => [
|
34
|
+
"Claremont", "Downtown Berkeley", "East Solano Ave", "Elmwood"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{"New York, NY" => [
|
38
|
+
{"Bronx" => [
|
39
|
+
"Baychester", "Bedford Park"
|
40
|
+
]
|
41
|
+
},
|
42
|
+
{"Brooklyn" => [
|
43
|
+
"Bath Beach", "Bay Ridge"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"Staten Island"
|
47
|
+
]
|
48
|
+
},
|
49
|
+
"Seattle, WA"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
def yelp4r_test_neighs_opts
|
56
|
+
[
|
57
|
+
'<option value="Canada">Canada</option>',
|
58
|
+
'<option value="Vancouver, BC, Canada"> - Vancouver, BC</option>',
|
59
|
+
'<option value="Ambleside, Vancouver, BC, Canada"> - - Ambleside</option>',
|
60
|
+
'<option value="Yaletown, Vancouver, BC, Canada"> - - Yaletown</option>',
|
61
|
+
'<option value="Toronto, ON, Canada"> - Toronto, ON</option>',
|
62
|
+
'<option value="USA">USA</option>',
|
63
|
+
'<option value="Berkeley, CA, USA"> - Berkeley, CA</option>',
|
64
|
+
'<option value="Claremont, Berkeley, CA, USA"> - - Claremont</option>',
|
65
|
+
'<option value="Downtown Berkeley, Berkeley, CA, USA"> - - Downtown Berkeley</option>',
|
66
|
+
'<option value="East Solano Ave, Berkeley, CA, USA"> - - East Solano Ave</option>',
|
67
|
+
'<option value="Elmwood, Berkeley, CA, USA"> - - Elmwood</option>',
|
68
|
+
'<option value="New York, NY, USA"> - New York, NY</option>',
|
69
|
+
'<option value="Bronx, New York, NY, USA"> - - Bronx</option>',
|
70
|
+
'<option value="Baychester, Bronx, New York, NY, USA"> - - - Baychester</option>',
|
71
|
+
'<option value="Bedford Park, Bronx, New York, NY, USA"> - - - Bedford Park</option>',
|
72
|
+
'<option value="Brooklyn, New York, NY, USA"> - - Brooklyn</option>',
|
73
|
+
'<option value="Bath Beach, Brooklyn, New York, NY, USA"> - - - Bath Beach</option>',
|
74
|
+
'<option value="Bay Ridge, Brooklyn, New York, NY, USA"> - - - Bay Ridge</option>',
|
75
|
+
'<option value="Staten Island, New York, NY, USA"> - - Staten Island</option>',
|
76
|
+
'<option value="Seattle, WA, USA"> - Seattle, WA</option>'
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def yelp4r_test_neighs_opts_single_selected
|
81
|
+
[
|
82
|
+
'<option value="Canada">Canada</option>',
|
83
|
+
'<option value="Vancouver, BC, Canada"> - Vancouver, BC</option>',
|
84
|
+
'<option value="Ambleside, Vancouver, BC, Canada"> - - Ambleside</option>',
|
85
|
+
'<option value="Yaletown, Vancouver, BC, Canada" selected="selected"> - - Yaletown</option>',
|
86
|
+
'<option value="Toronto, ON, Canada"> - Toronto, ON</option>',
|
87
|
+
'<option value="USA">USA</option>',
|
88
|
+
'<option value="Berkeley, CA, USA"> - Berkeley, CA</option>',
|
89
|
+
'<option value="Claremont, Berkeley, CA, USA"> - - Claremont</option>',
|
90
|
+
'<option value="Downtown Berkeley, Berkeley, CA, USA"> - - Downtown Berkeley</option>',
|
91
|
+
'<option value="East Solano Ave, Berkeley, CA, USA"> - - East Solano Ave</option>',
|
92
|
+
'<option value="Elmwood, Berkeley, CA, USA"> - - Elmwood</option>',
|
93
|
+
'<option value="New York, NY, USA"> - New York, NY</option>',
|
94
|
+
'<option value="Bronx, New York, NY, USA"> - - Bronx</option>',
|
95
|
+
'<option value="Baychester, Bronx, New York, NY, USA"> - - - Baychester</option>',
|
96
|
+
'<option value="Bedford Park, Bronx, New York, NY, USA"> - - - Bedford Park</option>',
|
97
|
+
'<option value="Brooklyn, New York, NY, USA"> - - Brooklyn</option>',
|
98
|
+
'<option value="Bath Beach, Brooklyn, New York, NY, USA"> - - - Bath Beach</option>',
|
99
|
+
'<option value="Bay Ridge, Brooklyn, New York, NY, USA"> - - - Bay Ridge</option>',
|
100
|
+
'<option value="Staten Island, New York, NY, USA"> - - Staten Island</option>',
|
101
|
+
'<option value="Seattle, WA, USA"> - Seattle, WA</option>'
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
def yelp4r_test_neighs_opts_multiple_selected
|
106
|
+
[
|
107
|
+
'<option value="Canada">Canada</option>',
|
108
|
+
'<option value="Vancouver, BC, Canada"> - Vancouver, BC</option>',
|
109
|
+
'<option value="Ambleside, Vancouver, BC, Canada"> - - Ambleside</option>',
|
110
|
+
'<option value="Yaletown, Vancouver, BC, Canada" selected="selected"> - - Yaletown</option>',
|
111
|
+
'<option value="Toronto, ON, Canada"> - Toronto, ON</option>',
|
112
|
+
'<option value="USA">USA</option>',
|
113
|
+
'<option value="Berkeley, CA, USA"> - Berkeley, CA</option>',
|
114
|
+
'<option value="Claremont, Berkeley, CA, USA"> - - Claremont</option>',
|
115
|
+
'<option value="Downtown Berkeley, Berkeley, CA, USA"> - - Downtown Berkeley</option>',
|
116
|
+
'<option value="East Solano Ave, Berkeley, CA, USA"> - - East Solano Ave</option>',
|
117
|
+
'<option value="Elmwood, Berkeley, CA, USA"> - - Elmwood</option>',
|
118
|
+
'<option value="New York, NY, USA" selected="selected"> - New York, NY</option>',
|
119
|
+
'<option value="Bronx, New York, NY, USA"> - - Bronx</option>',
|
120
|
+
'<option value="Baychester, Bronx, New York, NY, USA"> - - - Baychester</option>',
|
121
|
+
'<option value="Bedford Park, Bronx, New York, NY, USA"> - - - Bedford Park</option>',
|
122
|
+
'<option value="Brooklyn, New York, NY, USA"> - - Brooklyn</option>',
|
123
|
+
'<option value="Bath Beach, Brooklyn, New York, NY, USA" selected="selected"> - - - Bath Beach</option>',
|
124
|
+
'<option value="Bay Ridge, Brooklyn, New York, NY, USA"> - - - Bay Ridge</option>',
|
125
|
+
'<option value="Staten Island, New York, NY, USA"> - - Staten Island</option>',
|
126
|
+
'<option value="Seattle, WA, USA"> - Seattle, WA</option>'
|
127
|
+
]
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
module Yelp4rCatsSpecHelper
|
133
|
+
|
134
|
+
def yelp4r_test_cats_list
|
135
|
+
[
|
136
|
+
{"active" => {
|
137
|
+
:display => "Active Life",
|
138
|
+
:children => [
|
139
|
+
{"amusementparks" => {:display => "Amusement Parks"}},
|
140
|
+
{"fitness" => {
|
141
|
+
:display => "Fitness & Instruction",
|
142
|
+
:children => [
|
143
|
+
{"dancestudio" => {:display => "Dance Studios"}},
|
144
|
+
{"gyms" => {:display => "Gyms"}},
|
145
|
+
{"martialarts" => {:display => "Martial Arts"}}
|
146
|
+
]
|
147
|
+
}
|
148
|
+
}
|
149
|
+
]
|
150
|
+
}
|
151
|
+
},
|
152
|
+
{"auto" => {
|
153
|
+
:display => "Automotive",
|
154
|
+
:children => [
|
155
|
+
{"auto_detailing" => {:display => "Auto Detailing"}},
|
156
|
+
{"autoglass" => {:display => "Auto Glass Services"}}
|
157
|
+
]
|
158
|
+
}
|
159
|
+
},
|
160
|
+
{"shopping" => {
|
161
|
+
:display => "Shopping",
|
162
|
+
:children => [
|
163
|
+
{"homeandgarden" => {
|
164
|
+
:display => "Home & Garden",
|
165
|
+
:children => [
|
166
|
+
{"appliances" => {:display => "Appliances"}},
|
167
|
+
{"furniture" => {:display => "Furniture Stores"}}
|
168
|
+
]
|
169
|
+
}
|
170
|
+
},
|
171
|
+
{"sportgoods" => {
|
172
|
+
:display => "Sporting Goods",
|
173
|
+
:children => [
|
174
|
+
{"bikes" => {:display => "Bikes"}},
|
175
|
+
{"outdoorgear" => {:display => "Outdoor Gear"}},
|
176
|
+
{"sportswear" => {:display => "Sports Wear"}}
|
177
|
+
]
|
178
|
+
}
|
179
|
+
},
|
180
|
+
{"thrift_stores" => {:display => "Thrift Stores"}}
|
181
|
+
]
|
182
|
+
}
|
183
|
+
}
|
184
|
+
]
|
185
|
+
end
|
186
|
+
|
187
|
+
def yelp4r_test_cats_opts
|
188
|
+
[
|
189
|
+
'<option value="active">Active Life</option>',
|
190
|
+
'<option value="amusementparks"> - Amusement Parks</option>',
|
191
|
+
'<option value="fitness"> - Fitness & Instruction</option>',
|
192
|
+
'<option value="dancestudio"> - - Dance Studios</option>',
|
193
|
+
'<option value="gyms"> - - Gyms</option>',
|
194
|
+
'<option value="martialarts"> - - Martial Arts</option>',
|
195
|
+
'<option value="auto">Automotive</option>',
|
196
|
+
'<option value="auto_detailing"> - Auto Detailing</option>',
|
197
|
+
'<option value="autoglass"> - Auto Glass Services</option>',
|
198
|
+
'<option value="shopping">Shopping</option>',
|
199
|
+
'<option value="homeandgarden"> - Home & Garden</option>',
|
200
|
+
'<option value="appliances"> - - Appliances</option>',
|
201
|
+
'<option value="furniture"> - - Furniture Stores</option>',
|
202
|
+
'<option value="sportgoods"> - Sporting Goods</option>',
|
203
|
+
'<option value="bikes"> - - Bikes</option>',
|
204
|
+
'<option value="outdoorgear"> - - Outdoor Gear</option>',
|
205
|
+
'<option value="sportswear"> - - Sports Wear</option>',
|
206
|
+
'<option value="thrift_stores"> - Thrift Stores</option>'
|
207
|
+
]
|
208
|
+
end
|
209
|
+
|
210
|
+
def yelp4r_test_cats_opts_single_selected
|
211
|
+
[
|
212
|
+
'<option value="active">Active Life</option>',
|
213
|
+
'<option value="amusementparks"> - Amusement Parks</option>',
|
214
|
+
'<option value="fitness"> - Fitness & Instruction</option>',
|
215
|
+
'<option value="dancestudio"> - - Dance Studios</option>',
|
216
|
+
'<option value="gyms" selected="selected"> - - Gyms</option>',
|
217
|
+
'<option value="martialarts"> - - Martial Arts</option>',
|
218
|
+
'<option value="auto">Automotive</option>',
|
219
|
+
'<option value="auto_detailing"> - Auto Detailing</option>',
|
220
|
+
'<option value="autoglass"> - Auto Glass Services</option>',
|
221
|
+
'<option value="shopping">Shopping</option>',
|
222
|
+
'<option value="homeandgarden"> - Home & Garden</option>',
|
223
|
+
'<option value="appliances"> - - Appliances</option>',
|
224
|
+
'<option value="furniture"> - - Furniture Stores</option>',
|
225
|
+
'<option value="sportgoods"> - Sporting Goods</option>',
|
226
|
+
'<option value="bikes"> - - Bikes</option>',
|
227
|
+
'<option value="outdoorgear"> - - Outdoor Gear</option>',
|
228
|
+
'<option value="sportswear"> - - Sports Wear</option>',
|
229
|
+
'<option value="thrift_stores"> - Thrift Stores</option>'
|
230
|
+
]
|
231
|
+
end
|
232
|
+
|
233
|
+
def yelp4r_test_cats_opts_multiple_selected
|
234
|
+
[
|
235
|
+
'<option value="active">Active Life</option>',
|
236
|
+
'<option value="amusementparks"> - Amusement Parks</option>',
|
237
|
+
'<option value="fitness"> - Fitness & Instruction</option>',
|
238
|
+
'<option value="dancestudio"> - - Dance Studios</option>',
|
239
|
+
'<option value="gyms" selected="selected"> - - Gyms</option>',
|
240
|
+
'<option value="martialarts"> - - Martial Arts</option>',
|
241
|
+
'<option value="auto">Automotive</option>',
|
242
|
+
'<option value="auto_detailing"> - Auto Detailing</option>',
|
243
|
+
'<option value="autoglass" selected="selected"> - Auto Glass Services</option>',
|
244
|
+
'<option value="shopping">Shopping</option>',
|
245
|
+
'<option value="homeandgarden"> - Home & Garden</option>',
|
246
|
+
'<option value="appliances" selected="selected"> - - Appliances</option>',
|
247
|
+
'<option value="furniture"> - - Furniture Stores</option>',
|
248
|
+
'<option value="sportgoods"> - Sporting Goods</option>',
|
249
|
+
'<option value="bikes"> - - Bikes</option>',
|
250
|
+
'<option value="outdoorgear"> - - Outdoor Gear</option>',
|
251
|
+
'<option value="sportswear"> - - Sports Wear</option>',
|
252
|
+
'<option value="thrift_stores"> - Thrift Stores</option>'
|
253
|
+
]
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r'
|
3
|
+
|
4
|
+
describe Yelp4r::Categories do
|
5
|
+
include Yelp4rSpecHelper
|
6
|
+
include Yelp4rCatsSpecHelper
|
7
|
+
|
8
|
+
before do
|
9
|
+
@yelp_cats = Yelp4r::Categories.new
|
10
|
+
@yelp_cats.parse_url = File.dirname(__FILE__) + "/../fixtures/categories.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'initialize' do
|
14
|
+
it 'should set the url for the page to parse' do
|
15
|
+
@yelp_cats.parse_url.should_not be_blank
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'list' do
|
20
|
+
before do
|
21
|
+
@cats = @yelp_cats.list
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the list of categies" do
|
25
|
+
@cats.should_not be_blank
|
26
|
+
@cats.should == yelp4r_test_cats_list
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'options_from_list' do
|
31
|
+
it "should return an array of options" do
|
32
|
+
@yelp_cats.options_from_list.should_not be_blank
|
33
|
+
@yelp_cats.options_from_list.should == yelp4r_test_cats_opts
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return an array of options with a single selected value when given a string" do
|
37
|
+
@opts = @yelp_cats.options_from_list("gyms")
|
38
|
+
@opts.should_not be_blank
|
39
|
+
@opts.should == yelp4r_test_cats_opts_single_selected
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return an array of options with multiple selected values when given a array" do
|
43
|
+
@opts = @yelp_cats.options_from_list(["gyms", "autoglass", "appliances"])
|
44
|
+
@opts.should_not be_blank
|
45
|
+
@opts.should == yelp4r_test_cats_opts_multiple_selected
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r'
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
|
4
|
+
|
5
|
+
describe Yelp4r::Client do
|
6
|
+
include Yelp4rSpecHelper
|
7
|
+
|
8
|
+
describe 'initialize' do
|
9
|
+
before do
|
10
|
+
@client = yelp4r_client
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'sets the base_uri' do
|
14
|
+
@client.class.base_uri.should == 'http://api.yelp.com'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'sets default params to include the api key' do
|
18
|
+
@client.class.default_params.should == {:ywsid => 'jprr4VyNVMGZrd-FARdSQA'}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r'
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
|
4
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/neighborhood_search'
|
5
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/response'
|
6
|
+
|
7
|
+
describe Yelp4r::NeighborhoodSearch do
|
8
|
+
include Yelp4rSpecHelper
|
9
|
+
|
10
|
+
before do
|
11
|
+
@client = yelp4r_client
|
12
|
+
@neighborhood_search = Yelp4r::NeighborhoodSearch.new(@client)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'initialize' do
|
16
|
+
it 'set the client' do
|
17
|
+
@neighborhood_search.client.class.should == Yelp4r::Client
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'search_by_geocode' do
|
22
|
+
it 'should return results when passed a lat lon' do
|
23
|
+
@results = get_neighborhoods(42.3500, -71.0780)
|
24
|
+
@results.should be_success
|
25
|
+
@results.data.should_not be_blank
|
26
|
+
@results.error_message.should be_blank
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not return results when given invalid params' do
|
30
|
+
@results = get_neighborhoods(42.3500, '')
|
31
|
+
@results.should_not be_success
|
32
|
+
@results.data.should be_blank
|
33
|
+
@results.error_message.should_not be_blank
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_neighborhoods(*params)
|
37
|
+
@neighborhood_search.search_by_geocode(*params)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'search_by_location' do
|
42
|
+
it 'should return results when given a location' do
|
43
|
+
@results = get_neighborhoods('1512 Shattuck Ave., Berkely, CA')
|
44
|
+
@results.should be_success
|
45
|
+
@results.data.should_not be_blank
|
46
|
+
@results.error_message.should be_blank
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return results when given a location and a country code' do
|
50
|
+
@results = get_neighborhoods('1512 Shattuck Ave., Berkely, CA', 'US')
|
51
|
+
@results.should be_success
|
52
|
+
@results.data.should_not be_blank
|
53
|
+
@results.error_message.should be_blank
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should error when missing a location' do
|
57
|
+
@results = get_neighborhoods('')
|
58
|
+
@results.should_not be_success
|
59
|
+
@results.data.should be_blank
|
60
|
+
@results.error_message.should_not be_blank
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should error when given an invalid params' do
|
64
|
+
@results = get_neighborhoods('', 'US')
|
65
|
+
@results.should_not be_success
|
66
|
+
@results.data.should be_blank
|
67
|
+
@results.error_message.should_not be_blank
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_neighborhoods(*params)
|
71
|
+
@neighborhood_search.search_by_location(*params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r'
|
3
|
+
|
4
|
+
describe Yelp4r::Neighborhoods do
|
5
|
+
include Yelp4rSpecHelper
|
6
|
+
include Yelp4rNeighsSpecHelper
|
7
|
+
|
8
|
+
before do
|
9
|
+
@yelp_neighs = Yelp4r::Neighborhoods.new
|
10
|
+
@yelp_neighs.parse_url = File.dirname(__FILE__) + "/../fixtures/neighborhoods.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'initialize' do
|
14
|
+
it 'should set the url for the page to parse' do
|
15
|
+
@yelp_neighs.parse_url.should_not be_blank
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'list' do
|
20
|
+
before do
|
21
|
+
@neighs = @yelp_neighs.list
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the list of neighborhoods" do
|
25
|
+
@neighs.should_not be_blank
|
26
|
+
@neighs.should == yelp4r_test_neighs_list
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'options_from_collection' do
|
31
|
+
it "should return an array of options" do
|
32
|
+
@yelp_neighs.options_from_list.should_not be_blank
|
33
|
+
@yelp_neighs.options_from_list.should == yelp4r_test_neighs_opts
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return an array of options with a single selected value when given a string" do
|
37
|
+
@opts = @yelp_neighs.options_from_list("Yaletown, Vancouver, BC, Canada")
|
38
|
+
@opts.should_not be_blank
|
39
|
+
@opts.should == yelp4r_test_neighs_opts_single_selected
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return an array of options with multiple selected values when given a array" do
|
43
|
+
@opts = @yelp_neighs.options_from_list([
|
44
|
+
"Yaletown, Vancouver, BC, Canada",
|
45
|
+
"New York, NY, USA",
|
46
|
+
"Bath Beach, Brooklyn, New York, NY, USA"
|
47
|
+
])
|
48
|
+
@opts.should_not be_blank
|
49
|
+
@opts.should == yelp4r_test_neighs_opts_multiple_selected
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r'
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
|
4
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/phone_search'
|
5
|
+
require File.dirname(__FILE__) + '/../../lib/yelp4r/response'
|
6
|
+
|
7
|
+
describe Yelp4r::PhoneSearch do
|
8
|
+
include Yelp4rSpecHelper
|
9
|
+
|
10
|
+
before do
|
11
|
+
@client = yelp4r_client
|
12
|
+
@phone_search = Yelp4r::PhoneSearch.new(@client)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'initialize' do
|
16
|
+
it 'set the client' do
|
17
|
+
@phone_search.client.class.should == Yelp4r::Client
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'phone_search' do
|
22
|
+
it 'should return data on a valid phone number' do
|
23
|
+
@results = phone_get('4155463149')
|
24
|
+
@results.should be_success
|
25
|
+
@results.data.should_not be_blank
|
26
|
+
@results.error_message.should be_blank
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should not return data on an invalid phone number' do
|
30
|
+
@results = phone_get('415546314')
|
31
|
+
@results.should_not be_success
|
32
|
+
@results.data.should be_blank
|
33
|
+
@results.error_message.should_not be_blank
|
34
|
+
end
|
35
|
+
|
36
|
+
def phone_get(*params)
|
37
|
+
@phone_search.search_by_phone_number(*params)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|