yelp4r 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,163 @@
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/review_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
+ @review_search = Yelp4r::ReviewSearch.new(@client)
13
+ end
14
+
15
+ describe 'initialize' do
16
+ it 'set the client' do
17
+ @review_search.client.class.should == Yelp4r::Client
18
+ end
19
+ end
20
+
21
+ describe 'search_by_bounding_box' do
22
+ it 'should return results when given top left and bottom right geocodes' do
23
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5)
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 return the number of results requested' do
30
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :num_biz_requested => 5)
31
+ @results.should be_success
32
+ @results.data.should_not be_blank
33
+ @results.data.size.should == 5
34
+ @results.error_message.should be_blank
35
+ end
36
+
37
+ it 'should return max 20 results' do
38
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :num_biz_requested => 30)
39
+ @results.should be_success
40
+ @results.data.should_not be_blank
41
+ @results.data.size.should == 20
42
+ @results.error_message.should be_blank
43
+ end
44
+
45
+ it 'should return results when given a category term' do
46
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :term => 'bars')
47
+ @results.should be_success
48
+ @results.data.should_not be_blank
49
+ @results.error_message.should be_blank
50
+ end
51
+
52
+ it 'should error when missing a with bad geocodes' do
53
+ @results = get_businesses(37.788022, -122.399797, 37.9, '')
54
+ @results.should_not be_success
55
+ @results.data.should be_blank
56
+ @results.error_message.should_not be_blank
57
+ end
58
+
59
+ def get_businesses(*params)
60
+ @review_search.search_by_bounding_box(*params)
61
+ end
62
+ end
63
+
64
+ describe 'search_by_geocode_and_radius' do
65
+ it 'should return results when given a geocode' do
66
+ @results = get_businesses(37.788022, -122.399797)
67
+ @results.should be_success
68
+ @results.data.should_not be_blank
69
+ @results.error_message.should be_blank
70
+ end
71
+
72
+ it 'should return results when given a geocode and a radius' do
73
+ @results = get_businesses(37.788022, -122.399797, :radius => 10)
74
+ @results.should be_success
75
+ @results.data.should_not be_blank
76
+ @results.error_message.should be_blank
77
+ end
78
+
79
+ it 'should return the number of results requested' do
80
+ @results = get_businesses(37.788022, -122.399797, :num_biz_requested => 5)
81
+ @results.should be_success
82
+ @results.data.should_not be_blank
83
+ @results.data.size.should == 5
84
+ @results.error_message.should be_blank
85
+ end
86
+
87
+ it 'should return max 20 results' do
88
+ @results = get_businesses(37.788022, -122.399797, :num_biz_requested => 30)
89
+ @results.should be_success
90
+ @results.data.should_not be_blank
91
+ @results.data.size.should == 20
92
+ @results.error_message.should be_blank
93
+ end
94
+
95
+ it 'should return results when given a category term' do
96
+ @results = get_businesses(37.788022, -122.399797, :term => 'bars')
97
+ @results.should be_success
98
+ @results.data.should_not be_blank
99
+ @results.error_message.should be_blank
100
+ end
101
+
102
+ it 'should error when given a bad geocode' do
103
+ @results = get_businesses(37.788022, '')
104
+ @results.should_not be_success
105
+ @results.data.should be_blank
106
+ @results.error_message.should_not be_blank
107
+ end
108
+
109
+ def get_businesses(*params)
110
+ @review_search.search_by_geocode_and_radius(*params)
111
+ end
112
+ end
113
+
114
+ describe 'search_by_location' do
115
+ it 'should return results given a location' do
116
+ @results = get_businesses('Boston, MA')
117
+ @results.should be_success
118
+ @results.data.should_not be_blank
119
+ @results.error_message.should be_blank
120
+ end
121
+
122
+ it 'should return the number of results requested' do
123
+ @results = get_businesses('Boston, MA', :num_biz_requested => 5)
124
+ @results.should be_success
125
+ @results.data.should_not be_blank
126
+ @results.data.size.should == 5
127
+ @results.error_message.should be_blank
128
+ end
129
+
130
+ it 'should return max 20 results' do
131
+ @results = get_businesses('Boston, MA', :num_biz_requested => 30)
132
+ @results.should be_success
133
+ @results.data.should_not be_blank
134
+ @results.data.size.should == 20
135
+ @results.error_message.should be_blank
136
+ end
137
+
138
+ it 'should return results when given a category term' do
139
+ @results = get_businesses('Boston, MA', :term => 'bars')
140
+ @results.should be_success
141
+ @results.data.should_not be_blank
142
+ @results.error_message.should be_blank
143
+ end
144
+
145
+ it 'should return results when given a valid country code' do
146
+ @results = get_businesses('Boston, MA', :cc => 'US')
147
+ @results.should be_success
148
+ @results.data.should_not be_blank
149
+ @results.error_message.should be_blank
150
+ end
151
+
152
+ it 'should error when missing a location' do
153
+ @results = get_businesses('')
154
+ @results.should_not be_success
155
+ @results.data.should be_blank
156
+ @results.error_message.should_not be_blank
157
+ end
158
+
159
+ def get_businesses(*params)
160
+ @review_search.search_by_location(*params)
161
+ end
162
+ end
163
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yelp4r
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Cocca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-09 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: mash
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: Simple Ruby wrapper for the Yelp API built on HTTParty with parsers for available Neighborhoods and Categories
56
+ email: tom.cocca@gmail.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README
64
+ files:
65
+ - LICENSE
66
+ - README
67
+ - Rakefile
68
+ - VERSION.yml
69
+ - examples/yelp.rb
70
+ - lib/rubyify_keys.rb
71
+ - lib/yelp4r.rb
72
+ - lib/yelp4r/categories.rb
73
+ - lib/yelp4r/client.rb
74
+ - lib/yelp4r/neighborhood_search.rb
75
+ - lib/yelp4r/neighborhoods.rb
76
+ - lib/yelp4r/phone_search.rb
77
+ - lib/yelp4r/response.rb
78
+ - lib/yelp4r/review_search.rb
79
+ - spec/fixtures/categories.html
80
+ - spec/fixtures/neighborhoods.html
81
+ - spec/rcov.opts
82
+ - spec/spec.opts
83
+ - spec/spec_helper.rb
84
+ - spec/yelp4r/categories_spec.rb
85
+ - spec/yelp4r/client_spec.rb
86
+ - spec/yelp4r/neighborhood_search_spec.rb
87
+ - spec/yelp4r/neighborhoods_spec.rb
88
+ - spec/yelp4r/phone_search_spec.rb
89
+ - spec/yelp4r/review_search_spec.rb
90
+ has_rdoc: true
91
+ homepage: http://github.com/tcocca/yelp4r
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: "0"
110
+ version:
111
+ requirements: []
112
+
113
+ rubyforge_project:
114
+ rubygems_version: 1.3.5
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Yelp API wrapper in Ruby
118
+ test_files:
119
+ - spec/spec_helper.rb
120
+ - spec/yelp4r/categories_spec.rb
121
+ - spec/yelp4r/client_spec.rb
122
+ - spec/yelp4r/neighborhood_search_spec.rb
123
+ - spec/yelp4r/neighborhoods_spec.rb
124
+ - spec/yelp4r/phone_search_spec.rb
125
+ - spec/yelp4r/review_search_spec.rb
126
+ - examples/yelp.rb