foursquare2 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +8 -0
- data/Rakefile +0 -3
- data/Readme.md +2 -2
- data/VERSION +1 -1
- data/foursquare2.gemspec +39 -13
- data/lib/foursquare2/client.rb +1 -0
- data/test/fixtures/checkin.json +108 -0
- data/test/fixtures/friend_checkins.json +154 -0
- data/test/fixtures/photo.json +45 -0
- data/test/fixtures/search_specials.json +50 -0
- data/test/fixtures/search_tips.json +156 -0
- data/test/fixtures/search_users.json +23 -0
- data/test/fixtures/search_venues.json +2701 -0
- data/test/fixtures/special.json +13 -0
- data/test/fixtures/tip.json +145 -0
- data/test/fixtures/user.json +270 -0
- data/test/fixtures/venue.json +899 -0
- data/test/helper.rb +34 -0
- data/test/test_checkins.rb +26 -0
- data/test/test_client.rb +22 -0
- data/test/test_photos.rb +17 -0
- data/test/test_specials.rb +23 -0
- data/test/test_tips.rb +26 -0
- data/test/test_users.rb +24 -0
- data/test/test_venues.rb +25 -0
- metadata +59 -23
- data/test/test_foursquare2.rb +0 -7
data/test/helper.rb
CHANGED
@@ -9,10 +9,44 @@ rescue Bundler::BundlerError => e
|
|
9
9
|
end
|
10
10
|
require 'test/unit'
|
11
11
|
require 'shoulda'
|
12
|
+
require 'matchy'
|
13
|
+
require 'fakeweb'
|
12
14
|
|
13
15
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
16
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
17
|
require 'foursquare2'
|
16
18
|
|
19
|
+
FakeWeb.allow_net_connect = false
|
20
|
+
|
21
|
+
def foursquare_test_client
|
22
|
+
Foursquare2::Client.new(:oauth_token => 'yeehaw')
|
23
|
+
end
|
24
|
+
|
25
|
+
def foursquare_url(url)
|
26
|
+
url =~ /^http/ ? url : "http://api.foursquare.com/v2#{url}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def fixture_file(filename)
|
30
|
+
return '' if filename == ''
|
31
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
32
|
+
File.read(file_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def stub_get(url, filename, options={})
|
36
|
+
opts = {
|
37
|
+
:body => fixture_file(filename),
|
38
|
+
:content_type => 'application/json; charset=utf-8'
|
39
|
+
}.merge(options)
|
40
|
+
FakeWeb.register_uri(:get, foursquare_url(url), opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def stub_post(url, filename, options={})
|
44
|
+
opts = {
|
45
|
+
:body => fixture_file(filename),
|
46
|
+
:content_type => 'application/json; charset=utf-8'
|
47
|
+
}.merge(options)
|
48
|
+
FakeWeb.register_uri(:post, foursquare_url(url), opts)
|
49
|
+
end
|
50
|
+
|
17
51
|
class Test::Unit::TestCase
|
18
52
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestCheckins < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with checkins" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single checkin" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/checkins/4d572bcc9e508cfab975189b?oauth_token=#{@client.oauth_token}", "checkin.json")
|
12
|
+
checkin = @client.checkin('4d572bcc9e508cfab975189b')
|
13
|
+
checkin.venue.name.should == 'Bridgestone Arena'
|
14
|
+
checkin.user.firstName.should == 'Matt'
|
15
|
+
end
|
16
|
+
|
17
|
+
should "fetch recent checkins from friends"do
|
18
|
+
stub_get("https://api.foursquare.com/v2/checkins/recent?oauth_token=#{@client.oauth_token}&limit=2", "friend_checkins.json")
|
19
|
+
checkins = @client.recent_checkins(:limit => 2)
|
20
|
+
checkins.count.should == 2
|
21
|
+
checkins.first.venue.name.should == 'Buffalo Billiards'
|
22
|
+
checkins.last.user.firstName.should == 'David'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/test/test_client.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestClient < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "when instantiating a client instance" do
|
6
|
+
should "use the correct url for api requests" do
|
7
|
+
@client = Foursquare2::Client.new
|
8
|
+
@client.api_url.should == 'https://api.foursquare.com/v2'
|
9
|
+
end
|
10
|
+
|
11
|
+
should "retain oauth token for requests" do
|
12
|
+
@client = Foursquare2::Client.new(:oauth_token => 'yeehaw')
|
13
|
+
@client.oauth_token.should == "yeehaw"
|
14
|
+
end
|
15
|
+
|
16
|
+
should "retain client id/secret for requests" do
|
17
|
+
@client = Foursquare2::Client.new(:client_id => 'awesome', :client_secret => 'sauce')
|
18
|
+
@client.client_id.should == 'awesome'
|
19
|
+
@client.client_secret.should == 'sauce'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/test_photos.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestPhotos < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with photos" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single photo" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/photos/4d0fb8162d39a340637dc42b?oauth_token=#{@client.oauth_token}", "photo.json")
|
12
|
+
photo = @client.photo('4d0fb8162d39a340637dc42b')
|
13
|
+
photo.sizes.items.count.should == 4
|
14
|
+
photo.sizes.items.first.url.should == "http://playfoursquare.s3.amazonaws.com/pix/UYU54GYOCURPAUYXH5V2U3EOM4DCX4VZPT3YOMN43H555KU2.jpg"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestSpecials < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with specials" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single special" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/specials/4bd876f886ba62b58a6e88b3?oauth_token=#{@client.oauth_token}", "special.json")
|
12
|
+
special = @client.special('4bd876f886ba62b58a6e88b3')
|
13
|
+
special.message.should == "$10 off for the mayor!"
|
14
|
+
end
|
15
|
+
|
16
|
+
should "fetch results when searching for nearby specials" do
|
17
|
+
stub_get("https://api.foursquare.com/v2/specials/search?ll=40.7%2C-73.9&oauth_token=#{@client.oauth_token}", "search_specials.json")
|
18
|
+
specials = @client.search_specials(:ll => '40.7,-73.9')
|
19
|
+
specials.count.should == 1
|
20
|
+
specials.first.message.should == "Buy 1 Get 1 40% Off All Video Games (priced up to $19.99)\r\n\r\nItems must be of equal or lesser value to the lowest priced item purchased\r\n\r\nEnds 2/12/2011"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/test_tips.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTips < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with tips" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single tip" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/tips/4b5e662a70c603bba7d790b4?oauth_token=#{@client.oauth_token}", "tip.json")
|
12
|
+
tip = @client.tip('4b5e662a70c603bba7d790b4')
|
13
|
+
tip.done.groups.first['count'].should == 0
|
14
|
+
tip.done.groups.last['count'].should == 6
|
15
|
+
tip.done.groups.last.items.first.firstName.should == 'Allison'
|
16
|
+
tip.venue.name.should == '2 Bros Pizza'
|
17
|
+
end
|
18
|
+
|
19
|
+
should "fetch results when searching for nearby tips" do
|
20
|
+
stub_get("https://api.foursquare.com/v2/tips/search?ll=40.7%2C-73.9&oauth_token=#{@client.oauth_token}&limit=3", "search_tips.json")
|
21
|
+
tips = @client.search_tips(:ll => '40.7,-73.9', :limit => 3)
|
22
|
+
tips.count.should == 3
|
23
|
+
tips.first.text.should == "If you want a soda go to the vending machine next to the ice Cream place near the music barge it's only $2 for a 20oz bottle instead of $2 for a can at one of the carts."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/test_users.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestUsers < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with users" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single user" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/users/self?oauth_token=#{@client.oauth_token}", "user.json")
|
12
|
+
user = @client.user('self')
|
13
|
+
user.firstName.should == 'Matt'
|
14
|
+
user.checkins['count'].should == 669
|
15
|
+
end
|
16
|
+
|
17
|
+
should "fetch results when searching for users" do
|
18
|
+
stub_get("https://api.foursquare.com/v2/users/search?oauth_token=#{@client.oauth_token}&twitter=matt_mueller", "search_users.json")
|
19
|
+
users = @client.search_users(:twitter => 'matt_mueller')
|
20
|
+
users.results.count.should == 1
|
21
|
+
users.results.first.lastName.should == 'Mueller'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/test/test_venues.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestVenues < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the foursquare API and working with venues" do
|
6
|
+
setup do
|
7
|
+
@client = foursquare_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "fetch info for a single venue" do
|
11
|
+
stub_get("https://api.foursquare.com/v2/venues/4b8c3d87f964a520f7c532e3?oauth_token=#{@client.oauth_token}", "venue.json")
|
12
|
+
venue = @client.venue('4b8c3d87f964a520f7c532e3')
|
13
|
+
venue.name.should == 'Bridgestone Arena'
|
14
|
+
venue.location.address.should == '501 Broadway'
|
15
|
+
end
|
16
|
+
|
17
|
+
should "search for venues based on passed criteria" do
|
18
|
+
stub_get("https://api.foursquare.com/v2/venues/search?ll=36.142064%2C-86.816086&oauth_token=#{@client.oauth_token}&query=coffee", "search_venues.json")
|
19
|
+
venues = @client.search_venues(:ll => '36.142064,-86.816086', :query => 'coffee')
|
20
|
+
venues.groups.first.items.count.should == 30
|
21
|
+
venues.groups.first.items.first.name.should == 'Ugly Mugs'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foursquare2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Mueller
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-13 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -132,48 +132,61 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
hash:
|
135
|
+
hash: 9
|
136
136
|
segments:
|
137
|
-
-
|
138
|
-
- 5
|
137
|
+
- 1
|
139
138
|
- 3
|
140
|
-
version:
|
139
|
+
version: "1.3"
|
141
140
|
requirement: *id008
|
142
141
|
prerelease: false
|
143
|
-
type: :
|
144
|
-
name:
|
142
|
+
type: :development
|
143
|
+
name: fakeweb
|
145
144
|
- !ruby/object:Gem::Dependency
|
146
145
|
version_requirements: &id009 !ruby/object:Gem::Requirement
|
147
146
|
none: false
|
148
147
|
requirements:
|
149
148
|
- - ~>
|
150
149
|
- !ruby/object:Gem::Version
|
151
|
-
hash:
|
150
|
+
hash: 3
|
152
151
|
segments:
|
153
152
|
- 0
|
154
|
-
-
|
155
|
-
|
156
|
-
version: 0.3.0
|
153
|
+
- 4
|
154
|
+
version: "0.4"
|
157
155
|
requirement: *id009
|
158
156
|
prerelease: false
|
159
|
-
type: :
|
160
|
-
name:
|
157
|
+
type: :development
|
158
|
+
name: jnunemaker-matchy
|
161
159
|
- !ruby/object:Gem::Dependency
|
162
160
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
163
161
|
none: false
|
164
162
|
requirements:
|
165
163
|
- - ~>
|
166
164
|
- !ruby/object:Gem::Version
|
167
|
-
hash:
|
165
|
+
hash: 7
|
168
166
|
segments:
|
169
167
|
- 1
|
168
|
+
- 4
|
169
|
+
version: "1.4"
|
170
|
+
requirement: *id010
|
171
|
+
prerelease: false
|
172
|
+
type: :development
|
173
|
+
name: json_pure
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ~>
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
hash: 21
|
181
|
+
segments:
|
170
182
|
- 0
|
171
183
|
- 0
|
172
|
-
|
173
|
-
|
184
|
+
- 5
|
185
|
+
version: 0.0.5
|
186
|
+
requirement: *id011
|
174
187
|
prerelease: false
|
175
|
-
type: :
|
176
|
-
name:
|
188
|
+
type: :development
|
189
|
+
name: multi_json
|
177
190
|
description: Gives access to all endpoints in version 2 of foursquare's API with syntax that will be familiar to those who used the original foursquare gem by Jeremy Welch.
|
178
191
|
email: muellermr@gmail.com
|
179
192
|
executables: []
|
@@ -200,8 +213,25 @@ files:
|
|
200
213
|
- lib/foursquare2/tips.rb
|
201
214
|
- lib/foursquare2/users.rb
|
202
215
|
- lib/foursquare2/venues.rb
|
216
|
+
- test/fixtures/checkin.json
|
217
|
+
- test/fixtures/friend_checkins.json
|
218
|
+
- test/fixtures/photo.json
|
219
|
+
- test/fixtures/search_specials.json
|
220
|
+
- test/fixtures/search_tips.json
|
221
|
+
- test/fixtures/search_users.json
|
222
|
+
- test/fixtures/search_venues.json
|
223
|
+
- test/fixtures/special.json
|
224
|
+
- test/fixtures/tip.json
|
225
|
+
- test/fixtures/user.json
|
226
|
+
- test/fixtures/venue.json
|
203
227
|
- test/helper.rb
|
204
|
-
- test/
|
228
|
+
- test/test_checkins.rb
|
229
|
+
- test/test_client.rb
|
230
|
+
- test/test_photos.rb
|
231
|
+
- test/test_specials.rb
|
232
|
+
- test/test_tips.rb
|
233
|
+
- test/test_users.rb
|
234
|
+
- test/test_venues.rb
|
205
235
|
has_rdoc: true
|
206
236
|
homepage: http://github.com/mattmueller/foursquare2
|
207
237
|
licenses:
|
@@ -238,4 +268,10 @@ specification_version: 3
|
|
238
268
|
summary: Foursquare API v2 gem in the spirit of the original foursquare gem
|
239
269
|
test_files:
|
240
270
|
- test/helper.rb
|
241
|
-
- test/
|
271
|
+
- test/test_checkins.rb
|
272
|
+
- test/test_client.rb
|
273
|
+
- test/test_photos.rb
|
274
|
+
- test/test_specials.rb
|
275
|
+
- test/test_tips.rb
|
276
|
+
- test/test_users.rb
|
277
|
+
- test/test_venues.rb
|