gowalla 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +20 -0
- data/README.md +96 -0
- data/Rakefile +14 -0
- data/changelog.md +33 -0
- data/gowalla.gemspec +30 -0
- data/lib/gowalla.rb +26 -22
- data/lib/gowalla/checkins.rb +31 -0
- data/lib/gowalla/client.rb +22 -176
- data/lib/gowalla/flags.rb +42 -0
- data/lib/gowalla/items.rb +22 -0
- data/lib/gowalla/spots.rb +67 -0
- data/lib/gowalla/trips.rb +27 -0
- data/lib/gowalla/users.rb +91 -0
- data/lib/gowalla/version.rb +3 -0
- data/test/checkins_test.rb +18 -0
- data/test/client_test.rb +72 -0
- data/test/fixtures/categories.json +1826 -0
- data/test/fixtures/category.json +8 -0
- data/test/fixtures/challenges.json +191 -0
- data/test/fixtures/checkin.json +21 -0
- data/test/fixtures/events.json +185 -0
- data/test/fixtures/find_spots.json +620 -0
- data/test/fixtures/find_trips.json +695 -0
- data/test/fixtures/flag.json +23 -0
- data/test/fixtures/flags.json +31 -0
- data/test/fixtures/friend_requests.json +21 -0
- data/test/fixtures/friends.json +3 -0
- data/test/fixtures/friends_recent.json +243 -0
- data/test/fixtures/item.json +8 -0
- data/test/fixtures/item_events.json +35 -0
- data/test/fixtures/items.json +100 -0
- data/test/fixtures/me.json +49 -0
- data/test/fixtures/missing_items.json +1 -0
- data/test/fixtures/new_spot.json +49 -0
- data/test/fixtures/photos.json +88 -0
- data/test/fixtures/pins.json +81 -0
- data/test/fixtures/potential_twitter_friends.json +2090 -0
- data/test/fixtures/spot.json +251 -0
- data/test/fixtures/spots.json +557 -0
- data/test/fixtures/spots_by_category.json +620 -0
- data/test/fixtures/spots_urls.json +26 -0
- data/test/fixtures/stamps.json +284 -0
- data/test/fixtures/top_spots.json +64 -0
- data/test/fixtures/trip.json +22 -0
- data/test/fixtures/trips.json +881 -0
- data/test/fixtures/user.json +43 -0
- data/test/fixtures/users.json +46 -0
- data/test/fixtures/vaulted_items.json +12 -0
- data/test/fixtures/visited_spots.json +1 -0
- data/test/flags_test.rb +46 -0
- data/test/helper.rb +6 -6
- data/test/items_test.rb +26 -0
- data/test/spots_test.rb +70 -0
- data/test/trips_test.rb +25 -0
- data/test/users_test.rb +83 -0
- metadata +177 -29
- data/test/gowalla_test.rb +0 -214
data/test/gowalla_test.rb
DELETED
@@ -1,214 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class GowallaTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "When using the Gowalla API" do
|
6
|
-
setup do
|
7
|
-
@client = Gowalla::Client.new(:username => 'pengwynn', :password => '0U812', :api_key => 'gowallawallabingbang')
|
8
|
-
end
|
9
|
-
|
10
|
-
context "and working with Spots" do
|
11
|
-
should "Retrieve a list of spots within a specified distance of a location" do
|
12
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/spots?lat=%2B33.237593417&lng=-96.960559033&radius=50", "spots.json")
|
13
|
-
spots = @client.list_spots(:lat => 33.237593417, :lng => -96.960559033, :radius => 50)
|
14
|
-
spots.first.name.should == 'Gnomb Bar'
|
15
|
-
spots.first.radius_meters.should == 50
|
16
|
-
end
|
17
|
-
|
18
|
-
should "Retrieve a list of spots within a specified bounds" do
|
19
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/spots?sw=%2839.25565142103586%2C%20-8.717308044433594%29&nw=%2839.31411296530539%2C%20-8.490715026855469%29", "spots.json")
|
20
|
-
spots = @client.list_spots(:sw => "(39.25565142103586, -8.717308044433594)", :nw => "(39.31411296530539, -8.490715026855469)")
|
21
|
-
spots.first.name.should == 'Gnomb Bar'
|
22
|
-
end
|
23
|
-
|
24
|
-
should "Retrieve information about a specific spot" do
|
25
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/spots/18568', 'spot.json')
|
26
|
-
spot = @client.spot(18568)
|
27
|
-
spot.name.should == "Wahoo's"
|
28
|
-
spot.twitter_username.should == 'Wahoos512'
|
29
|
-
spot.spot_categories.first.name.should == 'Mexican'
|
30
|
-
end
|
31
|
-
|
32
|
-
should "retrieve a list of check-ins at a particular spot. Shows only the activity that is visible to a given user" do
|
33
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/spots/452593/events', 'events.json')
|
34
|
-
events = @client.spot_events(452593)
|
35
|
-
events.first[:type].should == 'checkin'
|
36
|
-
events.first.user.last_name.should == 'Mack'
|
37
|
-
end
|
38
|
-
|
39
|
-
should "retrieve a list of items available at a particular spot" do
|
40
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/spots/18568/items', 'items.json')
|
41
|
-
items = @client.spot_items(18568)
|
42
|
-
items.first.issue_number.should == 27868
|
43
|
-
items.first.name.should == 'Bowl of Noodles'
|
44
|
-
end
|
45
|
-
|
46
|
-
should "lists all spot categories" do
|
47
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/categories", "categories.json")
|
48
|
-
categories = @client.categories
|
49
|
-
categories.size.should == 9
|
50
|
-
categories.first.name.should == 'Architecture & Buildings'
|
51
|
-
categories.first.description.should == 'Bridge, Corporate, Home, Church, etc.'
|
52
|
-
categories.first.spot_categories.size.should == 15
|
53
|
-
categories.first.spot_categories.first.name.should == 'Bridge'
|
54
|
-
end
|
55
|
-
|
56
|
-
should "retrieve information about a specific category" do
|
57
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/categories/1", "category.json")
|
58
|
-
category = @client.category(1)
|
59
|
-
category.name.should == 'Coffee Shop'
|
60
|
-
end
|
61
|
-
|
62
|
-
should "retrieve flags associated with that spot" do
|
63
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/spots/1/flags", "flags.json")
|
64
|
-
flags = @client.spot_flags(1)
|
65
|
-
flags.first.spot.name.should == 'Wild Gowallaby #1'
|
66
|
-
flags.first.user.url.should == '/users/340897'
|
67
|
-
flags.first[:type].should == 'invalid'
|
68
|
-
flags.first.status.should == 'open'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "and working with Users" do
|
73
|
-
|
74
|
-
should "retrieve information about a specific user" do
|
75
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/users/sco', 'user.json')
|
76
|
-
user = @client.user('sco')
|
77
|
-
user.bio.should == "CTO & co-founder of Gowalla. Ruby/Cocoa/JavaScript developer. Game designer. Author. Indoorsman."
|
78
|
-
user.stamps_count.should == 506
|
79
|
-
end
|
80
|
-
|
81
|
-
should "retrieve a list of the stamps the user has collected" do
|
82
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/stamps?limit=20', 'stamps.json')
|
83
|
-
stamps = @client.stamps(1707)
|
84
|
-
stamps.size.should == 20
|
85
|
-
stamps.first.spot.name.should == "Muck-N-Dave's Texas BBQ"
|
86
|
-
stamps.first.spot.address.locality.should == 'Austin'
|
87
|
-
end
|
88
|
-
|
89
|
-
should "retrieve a list of spots the user has visited most often" do
|
90
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/users/1707/top_spots', 'top_spots.json')
|
91
|
-
top_spots = @client.top_spots(1707)
|
92
|
-
top_spots.size.should == 10
|
93
|
-
top_spots.first.name.should == 'Juan Pelota Cafe'
|
94
|
-
top_spots.first.user_checkins_count.should == 30
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
context "and working with Items" do
|
100
|
-
should "retrieve information about a specific item" do
|
101
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/items/607583', 'item.json')
|
102
|
-
item = @client.item(607583)
|
103
|
-
item.issue_number.should == 13998
|
104
|
-
item.name.should == 'Sweets'
|
105
|
-
item.determiner.should == 'some'
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "and working with Trips" do
|
110
|
-
should "retrieve a list of trips" do
|
111
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/trips', 'trips.json')
|
112
|
-
trips = @client.trips
|
113
|
-
trips.first.name.should == 'London Pub Crawl'
|
114
|
-
trips.first.spots.first.url.should == '/spots/164009'
|
115
|
-
end
|
116
|
-
|
117
|
-
should "retrieve information about a specific trip" do
|
118
|
-
stub_get('http://pengwynn:0U812@api.gowalla.com/trips/1', 'trip.json')
|
119
|
-
trip = @client.trip(1)
|
120
|
-
trip.creator.last_name.should == 'Gowalla'
|
121
|
-
trip.map_bounds.east.should == -63.457031
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "and working with Flags" do
|
126
|
-
should "retrieve a list of flags" do
|
127
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/flags", "flags.json")
|
128
|
-
flags = @client.list_flags
|
129
|
-
flags.first.spot.name.should == 'Wild Gowallaby #1'
|
130
|
-
flags.first.user.url.should == '/users/340897'
|
131
|
-
flags.first[:type].should == 'invalid'
|
132
|
-
flags.first.status.should == 'open'
|
133
|
-
end
|
134
|
-
|
135
|
-
should "retrieve information about a specific flag" do
|
136
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/flags/1", "flag.json")
|
137
|
-
flag = @client.flag(1)
|
138
|
-
flag.spot.name.should == 'Wild Gowallaby #1'
|
139
|
-
flag.user.url.should == '/users/340897'
|
140
|
-
flag[:type].should == 'invalid'
|
141
|
-
flag.status.should == 'open'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "and working with checkins" do
|
146
|
-
should "fetch info for a checkin" do
|
147
|
-
stub_get("http://pengwynn:0U812@api.gowalla.com/checkins/88", "checkin.json")
|
148
|
-
checkin = @client.checkin_info(88)
|
149
|
-
checkin.spot.name.should == 'Movie Tavern'
|
150
|
-
checkin.message.should == 'There sending us Back-- to the Future!'
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "when using basic auth" do
|
156
|
-
should "configure api_key, username, and password for easy access" do
|
157
|
-
|
158
|
-
Gowalla.configure do |config|
|
159
|
-
config.api_key = 'api_key'
|
160
|
-
config.api_secret = nil
|
161
|
-
config.username = 'username'
|
162
|
-
config.password = 'password'
|
163
|
-
end
|
164
|
-
|
165
|
-
@client = Gowalla::Client.new
|
166
|
-
|
167
|
-
stub_get('http://username:password@api.gowalla.com/trips', 'trips.json')
|
168
|
-
trips = @client.trips
|
169
|
-
|
170
|
-
@client.username.should == 'username'
|
171
|
-
end
|
172
|
-
|
173
|
-
should "configure test mode" do
|
174
|
-
Gowalla.configure do |config|
|
175
|
-
config.api_key = 'api_key'
|
176
|
-
config.api_secret = nil
|
177
|
-
config.username = 'username'
|
178
|
-
config.password = 'password'
|
179
|
-
config.test_mode = true
|
180
|
-
end
|
181
|
-
|
182
|
-
Gowalla.test_mode?.should == true
|
183
|
-
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context "when using OAuth2" do
|
188
|
-
|
189
|
-
setup do
|
190
|
-
Gowalla.configure do |config|
|
191
|
-
config.api_key = 'api_key'
|
192
|
-
config.api_secret = 'api_secret'
|
193
|
-
end
|
194
|
-
|
195
|
-
@client = Gowalla::Client.new
|
196
|
-
end
|
197
|
-
|
198
|
-
should "confiure api_key, api_secret" do
|
199
|
-
@client.api_secret.should == 'api_secret'
|
200
|
-
@client.oauth_client.id.should == 'api_key'
|
201
|
-
end
|
202
|
-
|
203
|
-
should "create an OAuth2 client" do
|
204
|
-
@client.oauth_client.class.to_s.should == "OAuth2::Client"
|
205
|
-
end
|
206
|
-
|
207
|
-
should "indicate if it needs an access_token" do
|
208
|
-
@client.needs_access?.should == true
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|
212
|
-
|
213
|
-
|
214
|
-
end
|