foursquare2 0.9.1 → 0.9.5

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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "meta": {
3
+ "code": 200
4
+ },
5
+ "response": {
6
+ "tips": {
7
+ "count": 0,
8
+ "items":[]
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "meta": {
3
+ "code": 200
4
+ },
5
+ "response": {
6
+ "tips": {
7
+ "count": 4,
8
+ "items": [
9
+ {
10
+ "id": "4c94a45c82b56dcb47cad0aa",
11
+ "createdAt": 1284809820,
12
+ "text": "A arena é muito legal, mas os equipamentos são péssimos.",
13
+ "url": "",
14
+ "todo": {
15
+ "count": 0
16
+ },
17
+ "done": {
18
+ "count": 1
19
+ },
20
+ "user": {
21
+ "id": "3362873",
22
+ "firstName": "Felipe",
23
+ "lastName": "A.",
24
+ "photo": "https://playfoursquare.s3.amazonaws.com/userpix_thumbs/DRECUTB3C3NXBYFT.jpg",
25
+ "gender": "male",
26
+ "homeCity": "São Paulo, Brasil"
27
+ }
28
+ },
29
+ {
30
+ "id": "4c43ef8f429a0f47851b481e",
31
+ "createdAt": 1279520655,
32
+ "text": "O endereco do mapa tah errado.Rua Joaquim Bagunha Maldos n 535 Vila Tesouro Cep 12221420",
33
+ "todo": {
34
+ "count": 0
35
+ },
36
+ "done": {
37
+ "count": 1
38
+ },
39
+ "user": {
40
+ "id": "765336",
41
+ "firstName": "Sandro",
42
+ "lastName": "E.",
43
+ "photo": "https://playfoursquare.s3.amazonaws.com/userpix_thumbs/ANJZL2NLHLOBNDQI.jpg",
44
+ "gender": "male",
45
+ "homeCity": "São José dos Campos, Brazil"
46
+ }
47
+ },
48
+ {
49
+ "id": "4bb693bf70c603bb029096b4",
50
+ "createdAt": 1270256575,
51
+ "text": "Adrenalina pura! Tem um bar bem loko! Recomendo!",
52
+ "todo": {
53
+ "count": 0
54
+ },
55
+ "done": {
56
+ "count": 1
57
+ },
58
+ "user": {
59
+ "id": "765336",
60
+ "firstName": "Sandro",
61
+ "lastName": "E.",
62
+ "photo": "https://playfoursquare.s3.amazonaws.com/userpix_thumbs/ANJZL2NLHLOBNDQI.jpg",
63
+ "gender": "male",
64
+ "homeCity": "São José dos Campos, Brazil"
65
+ }
66
+ },
67
+ {
68
+ "id": "4bb6157870c603bb6f8396b4",
69
+ "createdAt": 1270224248,
70
+ "text": "Paintball",
71
+ "todo": {
72
+ "count": 0
73
+ },
74
+ "done": {
75
+ "count": 1
76
+ },
77
+ "user": {
78
+ "id": "765336",
79
+ "firstName": "Sandro",
80
+ "lastName": "E.",
81
+ "photo": "https://playfoursquare.s3.amazonaws.com/userpix_thumbs/ANJZL2NLHLOBNDQI.jpg",
82
+ "gender": "male",
83
+ "homeCity": "São José dos Campos, Brazil"
84
+ }
85
+ }
86
+ ]
87
+ }
88
+ }
89
+ }
@@ -15,6 +15,7 @@ require 'fakeweb'
15
15
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
17
17
  require 'foursquare2'
18
+ require 'config'
18
19
 
19
20
  FakeWeb.allow_net_connect = false
20
21
 
@@ -20,5 +20,41 @@ class TestUsers < Test::Unit::TestCase
20
20
  users.results.count.should == 1
21
21
  users.results.first.lastName.should == 'Mueller'
22
22
  end
23
+
24
+ should "fetch tips" do
25
+ stub_get("https://api.foursquare.com/v2/users/self/tips?oauth_token=#{@client.oauth_token}", "user_tips.json")
26
+ tips = @client.user_tips('self')
27
+ tips.items.first.text.should == "Encontrei mesas e chao sujos."
28
+ tips.items.size.should == 12
29
+ end
30
+
31
+ should "fetch tips and filter with term #{QUERY}" do
32
+ stub_get("https://api.foursquare.com/v2/users/self/tips?oauth_token=#{@client.oauth_token}&query=#{QUERY}", "user_tips.json")
33
+ tips = @client.user_tips('self', {:query => QUERY})
34
+ tips.items.size.should == 1
35
+ end
36
+
37
+ #TODO refactoring all call to method stub_get
38
+
39
+ should "list only user with tip #{QUERY}" do
40
+ stub_get("https://api.foursquare.com/v2/tips/search?oauth_token=#{@client.oauth_token}&ll=77.7%2C-77.7&query=#{QUERY}&limit=500", "search_tips.json")
41
+ users = @client.search_users_by_tip({:name => 'developer', :ll =>'77.7,-77.7', :query => QUERY})
42
+ users.first.id.should == "2227298"
43
+ users.size.should == 1
44
+ end
45
+
46
+ should "find by name not case sensitive" do
47
+ stub_get("https://api.foursquare.com/v2/tips/search?oauth_token=#{@client.oauth_token}&ll=77.7%2C-77.7&query=#{QUERY}&limit=500", "search_tips.json")
48
+ users = @client.search_users_by_tip({:name => 'Developer', :ll =>'77.7,-77.7', :query => QUERY})
49
+ users.first.id.should == "2227298"
50
+ users.size.should == 1
51
+ end
52
+
53
+ should "haven't user with name anonymous with tip #{QUERY}" do
54
+ stub_get("https://api.foursquare.com/v2/tips/search?oauth_token=#{@client.oauth_token}&ll=77.7%2C-77.7&query=#{QUERY}&limit=500", "search_tips.json")
55
+ users = @client.search_users_by_tip({:name => 'anonymous', :ll =>'77.7,-77.7', :query => QUERY})
56
+ users.size.should == 0
57
+ end
58
+
23
59
  end
24
60
  end
@@ -16,10 +16,44 @@ class TestVenues < Test::Unit::TestCase
16
16
 
17
17
  should "search for venues based on passed criteria" do
18
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
19
+ venues = @client.search_venues(:ll => "36.142064,-86.816086", :query => "coffee")
21
20
  venues.groups.first.items.first.name.should == 'Ugly Mugs'
22
21
  end
22
+
23
+ should "search for venues from a tip search" do
24
+ stub_get("https://api.foursquare.com/v2/tips/search?ll=-23.013968%2C-45.550802&oauth_token=#{@client.oauth_token}&query=rodoviaria", "search_venues_by_tip.json")
25
+ venues = @client.search_venues_by_tip(:ll => "-23.013968,-45.550802", :query => "rodoviaria")
26
+ venues.first.name.should == "Santa Barbara"
27
+ end
28
+
29
+ should "not find venues from a tip search" do
30
+ stub_get("https://api.foursquare.com/v2/tips/search?ll=-23.013968%2C-45.550802&oauth_token=#{@client.oauth_token}&query=loremlpsun", "no_venues_by_tip.json")
31
+ venues = @client.search_venues_by_tip(:ll => "-23.013968,-45.550802", :query => "loremlpsun")
32
+ venues.size.should == 0
33
+ end
34
+
35
+ should "get tips from a venue" do
36
+ stub_get("https://api.foursquare.com/v2/venues/4b8c3d87f964a520f7c532e3/tips?oauth_token=#{@client.oauth_token}", "venue_tips.json")
37
+ tips = @client.venue_tips('4b8c3d87f964a520f7c532e3')
38
+ tips.items.first.id.should == "4c94a45c82b56dcb47cad0aa"
39
+ tips.items.size.should == 4
40
+ end
41
+
42
+ should "get tips from a venue only with some term" do
43
+ stub_get("https://api.foursquare.com/v2/venues/4c94a45c82b56dcb47cad0aa/tips?oauth_token=#{@client.oauth_token}", "venue_tips.json")
44
+ tips = @client.venue_tips('4c94a45c82b56dcb47cad0aa', {:query => "legal"})
45
+
46
+ tips.items.count.should == 1
47
+ tips.items.first.id.should == "4c94a45c82b56dcb47cad0aa"
48
+ end
49
+
50
+ should "no tips from a venue with term lorem" do
51
+ stub_get("https://api.foursquare.com/v2/venues/4c94a45c82b56dcb47cad0aa/tips?oauth_token=#{@client.oauth_token}", "venue_tips.json")
52
+ tips = @client.venue_tips('4c94a45c82b56dcb47cad0aa', {:query => "lorem"})
53
+
54
+ tips.items.count.should == 0
55
+ end
56
+
23
57
  end
24
58
 
25
59
  end
metadata CHANGED
@@ -1,24 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foursquare2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
5
- prerelease: false
4
+ hash: 49
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 1
10
- version: 0.9.1
9
+ - 5
10
+ version: 0.9.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Mueller
14
+ - Marco Moura
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-04-05 00:00:00 -05:00
19
+ date: 2011-04-26 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
23
+ type: :runtime
22
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
@@ -32,9 +34,9 @@ dependencies:
32
34
  version: 0.6.0
33
35
  requirement: *id001
34
36
  prerelease: false
35
- type: :runtime
36
37
  name: faraday
37
38
  - !ruby/object:Gem::Dependency
39
+ type: :runtime
38
40
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
41
  none: false
40
42
  requirements:
@@ -48,9 +50,9 @@ dependencies:
48
50
  version: 0.6.0
49
51
  requirement: *id002
50
52
  prerelease: false
51
- type: :runtime
52
53
  name: faraday_middleware
53
54
  - !ruby/object:Gem::Dependency
55
+ type: :runtime
54
56
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
57
  none: false
56
58
  requirements:
@@ -64,9 +66,9 @@ dependencies:
64
66
  version: 1.0.0
65
67
  requirement: *id003
66
68
  prerelease: false
67
- type: :runtime
68
69
  name: hashie
69
70
  - !ruby/object:Gem::Dependency
71
+ type: :development
70
72
  version_requirements: &id004 !ruby/object:Gem::Requirement
71
73
  none: false
72
74
  requirements:
@@ -78,9 +80,9 @@ dependencies:
78
80
  version: "0"
79
81
  requirement: *id004
80
82
  prerelease: false
81
- type: :development
82
83
  name: shoulda
83
84
  - !ruby/object:Gem::Dependency
85
+ type: :development
84
86
  version_requirements: &id005 !ruby/object:Gem::Requirement
85
87
  none: false
86
88
  requirements:
@@ -94,9 +96,9 @@ dependencies:
94
96
  version: 1.0.0
95
97
  requirement: *id005
96
98
  prerelease: false
97
- type: :development
98
99
  name: bundler
99
100
  - !ruby/object:Gem::Dependency
101
+ type: :development
100
102
  version_requirements: &id006 !ruby/object:Gem::Requirement
101
103
  none: false
102
104
  requirements:
@@ -110,9 +112,9 @@ dependencies:
110
112
  version: 1.5.2
111
113
  requirement: *id006
112
114
  prerelease: false
113
- type: :development
114
115
  name: jeweler
115
116
  - !ruby/object:Gem::Dependency
117
+ type: :development
116
118
  version_requirements: &id007 !ruby/object:Gem::Requirement
117
119
  none: false
118
120
  requirements:
@@ -124,9 +126,9 @@ dependencies:
124
126
  version: "0"
125
127
  requirement: *id007
126
128
  prerelease: false
127
- type: :development
128
129
  name: rcov
129
130
  - !ruby/object:Gem::Dependency
131
+ type: :development
130
132
  version_requirements: &id008 !ruby/object:Gem::Requirement
131
133
  none: false
132
134
  requirements:
@@ -139,9 +141,9 @@ dependencies:
139
141
  version: "1.3"
140
142
  requirement: *id008
141
143
  prerelease: false
142
- type: :development
143
144
  name: fakeweb
144
145
  - !ruby/object:Gem::Dependency
146
+ type: :development
145
147
  version_requirements: &id009 !ruby/object:Gem::Requirement
146
148
  none: false
147
149
  requirements:
@@ -154,9 +156,9 @@ dependencies:
154
156
  version: "0.4"
155
157
  requirement: *id009
156
158
  prerelease: false
157
- type: :development
158
159
  name: jnunemaker-matchy
159
160
  - !ruby/object:Gem::Dependency
161
+ type: :development
160
162
  version_requirements: &id010 !ruby/object:Gem::Requirement
161
163
  none: false
162
164
  requirements:
@@ -169,9 +171,9 @@ dependencies:
169
171
  version: "1.4"
170
172
  requirement: *id010
171
173
  prerelease: false
172
- type: :development
173
174
  name: json_pure
174
175
  - !ruby/object:Gem::Dependency
176
+ type: :development
175
177
  version_requirements: &id011 !ruby/object:Gem::Requirement
176
178
  none: false
177
179
  requirements:
@@ -185,10 +187,11 @@ dependencies:
185
187
  version: 0.0.5
186
188
  requirement: *id011
187
189
  prerelease: false
188
- type: :development
189
190
  name: multi_json
190
191
  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.
191
- email: muellermr@gmail.com
192
+ email:
193
+ - muellermr@gmail.com
194
+ - email@marcomoura.com
192
195
  executables: []
193
196
 
194
197
  extensions: []
@@ -207,23 +210,30 @@ files:
207
210
  - lib/foursquare2.rb
208
211
  - lib/foursquare2/checkins.rb
209
212
  - lib/foursquare2/client.rb
213
+ - lib/foursquare2/hash.rb
210
214
  - lib/foursquare2/photos.rb
211
215
  - lib/foursquare2/settings.rb
212
216
  - lib/foursquare2/specials.rb
213
217
  - lib/foursquare2/tips.rb
214
218
  - lib/foursquare2/users.rb
215
219
  - lib/foursquare2/venues.rb
220
+ - test/config.rb
216
221
  - test/fixtures/checkin.json
217
222
  - test/fixtures/friend_checkins.json
223
+ - test/fixtures/no_venues_by_tip.json
218
224
  - test/fixtures/photo.json
219
225
  - test/fixtures/search_specials.json
220
226
  - test/fixtures/search_tips.json
221
227
  - test/fixtures/search_users.json
222
228
  - test/fixtures/search_venues.json
229
+ - test/fixtures/search_venues_by_tip.json
223
230
  - test/fixtures/special.json
224
231
  - test/fixtures/tip.json
225
232
  - test/fixtures/user.json
233
+ - test/fixtures/user_tips.json
234
+ - test/fixtures/user_tips_empty.json
226
235
  - test/fixtures/venue.json
236
+ - test/fixtures/venue_tips.json
227
237
  - test/helper.rb
228
238
  - test/test_checkins.rb
229
239
  - test/test_client.rb
@@ -262,11 +272,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
272
  requirements: []
263
273
 
264
274
  rubyforge_project:
265
- rubygems_version: 1.3.7
275
+ rubygems_version: 1.4.2
266
276
  signing_key:
267
277
  specification_version: 3
268
278
  summary: Foursquare API v2 gem in the spirit of the original foursquare gem
269
279
  test_files:
280
+ - test/config.rb
270
281
  - test/helper.rb
271
282
  - test/test_checkins.rb
272
283
  - test/test_client.rb