gowalla-ruby 0.0.1 → 0.0.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.
- data/Manifest +10 -0
- data/README.markdown +20 -17
- data/Rakefile +1 -1
- data/gowalla-ruby.gemspec +5 -5
- data/init.rb +6 -1
- data/lib/gowalla/activity.rb +13 -0
- data/lib/gowalla/address.rb +1 -1
- data/lib/gowalla/category.rb +10 -0
- data/lib/gowalla/event.rb +18 -0
- data/lib/gowalla/map_bound.rb +12 -0
- data/lib/gowalla/spot.rb +40 -2
- data/lib/gowalla/stamp.rb +1 -1
- data/lib/gowalla/top_10.rb +17 -0
- data/lib/gowalla/user.rb +1 -1
- data/test/fixtures/event.json +195 -0
- data/test/fixtures/spot.json +183 -0
- data/test/fixtures/spots.json +818 -0
- data/test/test_event.rb +40 -0
- data/test/test_spot.rb +122 -0
- data/test/test_stamp.rb +3 -3
- data/test/test_user.rb +10 -3
- metadata +19 -2
data/test/test_event.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestEvent < Test::Unit::TestCase
|
4
|
+
context 'An event' do
|
5
|
+
setup do
|
6
|
+
@id = '18568'
|
7
|
+
@spot_data = YAML::load_file File.join(File.dirname(__FILE__), "fixtures", "spot.json")
|
8
|
+
@event_data = YAML::load_file File.join(File.dirname(__FILE__), "fixtures", "event.json")
|
9
|
+
Spot.stubs(:fetch).with(@id).returns(@spot_data)
|
10
|
+
Event.stubs(:fetch).with(@id).returns(@event_data)
|
11
|
+
@event = Spot.find(@id).events
|
12
|
+
end
|
13
|
+
should "have a URL" do
|
14
|
+
assert_equal '/spots/18568', @event.url
|
15
|
+
assert_equal String, @event.url.class
|
16
|
+
end
|
17
|
+
should "have an array of activities" do
|
18
|
+
assert_equal 16, @event.activity.size.to_i
|
19
|
+
assert_equal Array, @event.activity.class
|
20
|
+
end
|
21
|
+
context "with an activity" do
|
22
|
+
setup{ @activity = @event.activity.first }
|
23
|
+
should "have a type" do
|
24
|
+
assert_equal 'checkin', @activity.type
|
25
|
+
assert_equal String, @activity.type.class
|
26
|
+
end
|
27
|
+
should "have a message" do
|
28
|
+
assert_equal 'Obligatacos', @activity.message
|
29
|
+
assert_equal String, @activity.message.class
|
30
|
+
end
|
31
|
+
should "have a user" do
|
32
|
+
assert_equal 'Phillip', @activity.user.first_name
|
33
|
+
assert_equal 'http://s3.amazonaws.com/static.gowalla.com/users/12-standard.jpg?1249405659', @activity.user.image_url
|
34
|
+
assert_equal '/users/12', @activity.user.url
|
35
|
+
assert_equal 'Bowden', @activity.user.last_name
|
36
|
+
assert_equal User, @activity.user.class
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/test/test_spot.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestSpot < Test::Unit::TestCase
|
4
|
+
context 'a spot' do
|
5
|
+
setup do
|
6
|
+
@id = '18568'
|
7
|
+
@spot_data = YAML::load_file File.join(File.dirname(__FILE__), "fixtures", "spot.json")
|
8
|
+
Spot.stubs(:fetch).with(@id).returns(@spot_data)
|
9
|
+
@spot = Spot.find(@id)
|
10
|
+
end
|
11
|
+
should "have a specific amount of data" do
|
12
|
+
# ensure stub API response has all the Spot fields covered, divide in half for just the getters
|
13
|
+
assert_equal @spot_data.size, (Gowalla::Spot.public_instance_methods(false).size / 2)
|
14
|
+
end
|
15
|
+
should "have an activity url" do
|
16
|
+
assert_equal '/spots/18568/events', @spot.activity_url
|
17
|
+
assert_equal String, @spot.activity_url.class
|
18
|
+
end
|
19
|
+
should "have a radius meters" do
|
20
|
+
assert_equal 50, @spot.radius_meters.to_i
|
21
|
+
assert_equal Fixnum, @spot.radius_meters.class
|
22
|
+
end
|
23
|
+
should "have a remove bookmark url" do
|
24
|
+
assert_equal nil, @spot.remove_bookmark_url
|
25
|
+
end
|
26
|
+
should "have a checkins url" do
|
27
|
+
assert_equal '/checkins?spot_id=18568', @spot.checkins_url
|
28
|
+
assert_equal String, @spot.checkins_url.class
|
29
|
+
end
|
30
|
+
should "have a checkins count" do
|
31
|
+
assert_equal 303, @spot.checkins_count.to_i
|
32
|
+
assert_equal Fixnum, @spot.checkins_count.class
|
33
|
+
end
|
34
|
+
should "have an items count" do
|
35
|
+
assert_equal 12, @spot.items_count.to_i
|
36
|
+
assert_equal Fixnum, @spot.items_count.class
|
37
|
+
end
|
38
|
+
should "have a facebook url" do
|
39
|
+
assert_equal 'http://facebook.com/TorchysTacos', @spot.facebook_url
|
40
|
+
assert_equal String, @spot.facebook_url.class
|
41
|
+
end
|
42
|
+
should "have websites" do
|
43
|
+
assert_equal ['http://www.wahoos.com/'], @spot.websites
|
44
|
+
assert_equal Array, @spot.websites.class
|
45
|
+
end
|
46
|
+
should "have founders" do
|
47
|
+
assert_equal Array, @spot.founders.class
|
48
|
+
assert_equal 11, @spot.founders.size
|
49
|
+
end
|
50
|
+
should "have a description" do
|
51
|
+
assert_equal String, @spot.description.class
|
52
|
+
end
|
53
|
+
should "have a bookmarks url" do
|
54
|
+
assert_equal String, @spot.bookmarks_url.class
|
55
|
+
end
|
56
|
+
should "have a max items count" do
|
57
|
+
assert_equal Fixnum, @spot.max_items_count.class
|
58
|
+
end
|
59
|
+
should "have a trending level" do
|
60
|
+
assert_equal Fixnum, @spot.trending_level.class
|
61
|
+
end
|
62
|
+
should "have a lat and lng" do
|
63
|
+
assert_equal Float, @spot.lat.class
|
64
|
+
assert_equal Float, @spot.lng.class
|
65
|
+
end
|
66
|
+
should "have a users count" do
|
67
|
+
assert_equal Fixnum, @spot.users_count.class
|
68
|
+
end
|
69
|
+
should "have a twitter username" do
|
70
|
+
assert_equal String, @spot.twitter_username.class
|
71
|
+
end
|
72
|
+
should "have a creator" do
|
73
|
+
assert_equal Gowalla::User, @spot.creator.class
|
74
|
+
end
|
75
|
+
should "have a list image url 320" do
|
76
|
+
assert_equal String, @spot.list_image_url_320.class
|
77
|
+
end
|
78
|
+
should "have a items url" do
|
79
|
+
assert_equal String, @spot.items_url.class
|
80
|
+
end
|
81
|
+
should "have spot categories" do
|
82
|
+
assert_equal Array, @spot.spot_categories.class
|
83
|
+
assert_equal Gowalla::Category, @spot.spot_categories.first.class
|
84
|
+
assert_equal 'Mexican', @spot.spot_categories.first.name
|
85
|
+
end
|
86
|
+
should "have a strict radius" do
|
87
|
+
assert_equal false, @spot.strict_radius
|
88
|
+
end
|
89
|
+
should "have map bounds" do
|
90
|
+
assert_equal Gowalla::MapBound, @spot.map_bounds.class
|
91
|
+
end
|
92
|
+
should "have a phone number" do
|
93
|
+
assert_equal String, @spot.phone_number.class
|
94
|
+
end
|
95
|
+
should "have a top 10" do
|
96
|
+
assert_equal Array, @spot.top_10.class
|
97
|
+
assert_equal 'Sandi', @spot.top_10.first.first_name
|
98
|
+
assert_equal 'Weldon', @spot.top_10.first.last_name
|
99
|
+
end
|
100
|
+
|
101
|
+
context "a founder" do
|
102
|
+
setup{ @founder = @spot.founders.first }
|
103
|
+
should "have a first name" do
|
104
|
+
assert_equal 'Court', @founder.first_name
|
105
|
+
assert_equal String, @founder.first_name.class
|
106
|
+
end
|
107
|
+
should "have a last name" do
|
108
|
+
assert_equal 'Simas', @founder.last_name
|
109
|
+
assert_equal String, @founder.last_name.class
|
110
|
+
end
|
111
|
+
should "have a url" do
|
112
|
+
assert_equal '/users/151', @founder.url
|
113
|
+
assert_equal String, @founder.url.class
|
114
|
+
end
|
115
|
+
should "have an image url" do
|
116
|
+
assert_equal 'http://s3.amazonaws.com/static.gowalla.com/users/151-standard.jpg?1266952532', @founder.image_url
|
117
|
+
assert_equal String, @founder.image_url.class
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
data/test/test_stamp.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestStamp < Test::Unit::TestCase
|
4
|
-
context '
|
4
|
+
context 'A stamp' do
|
5
5
|
setup do
|
6
6
|
@username = 'andyatkinson'
|
7
7
|
@stamp_data = YAML::load_file(File.join(File.dirname(__FILE__), "fixtures", "stamps.json"))
|
8
8
|
Stamp.stubs(:fetch).with(@username).returns(@stamp_data)
|
9
9
|
@stamp = Stamp.find(@username).first
|
10
10
|
end
|
11
|
-
should "
|
11
|
+
should "match number of fields being stored to API response" do
|
12
12
|
assert_equal @stamp_data["stamps"].first.size, (Stamp.public_instance_methods(false).size / 2)
|
13
13
|
end
|
14
|
-
should "
|
14
|
+
should "have a spot with all fields" do
|
15
15
|
assert_equal 'Roosevelt High School', @stamp.spot.name
|
16
16
|
assert_equal Address, @stamp.spot.address.class
|
17
17
|
assert_equal "MN", @stamp.spot.address.region
|
data/test/test_user.rb
CHANGED
@@ -99,9 +99,16 @@ class TestUser < Test::Unit::TestCase
|
|
99
99
|
assert_equal Array, @user.last_checkins.class
|
100
100
|
assert_equal Checkin, @user.last_checkins.first.class
|
101
101
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
context "with stamps" do
|
103
|
+
setup do
|
104
|
+
@stamp_data = YAML::load_file(File.join(File.dirname(__FILE__), "fixtures", "stamps.json"))
|
105
|
+
@user_id = '19628' # user_id for @username
|
106
|
+
Stamp.stubs(:fetch).with(@user_id).returns(@stamp_data)
|
107
|
+
end
|
108
|
+
should "have stamps" do
|
109
|
+
assert_equal 20, @user.stamps.size
|
110
|
+
assert_equal Gowalla::Stamp, @user.stamps.first.class
|
111
|
+
end
|
105
112
|
end
|
106
113
|
end
|
107
114
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gowalla-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Atkinson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-07 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,11 +52,16 @@ extra_rdoc_files:
|
|
52
52
|
- LICENSE
|
53
53
|
- README.markdown
|
54
54
|
- lib/gowalla.rb
|
55
|
+
- lib/gowalla/activity.rb
|
55
56
|
- lib/gowalla/address.rb
|
56
57
|
- lib/gowalla/base.rb
|
58
|
+
- lib/gowalla/category.rb
|
57
59
|
- lib/gowalla/checkin.rb
|
60
|
+
- lib/gowalla/event.rb
|
61
|
+
- lib/gowalla/map_bound.rb
|
58
62
|
- lib/gowalla/spot.rb
|
59
63
|
- lib/gowalla/stamp.rb
|
64
|
+
- lib/gowalla/top_10.rb
|
60
65
|
- lib/gowalla/user.rb
|
61
66
|
files:
|
62
67
|
- LICENSE
|
@@ -64,15 +69,25 @@ files:
|
|
64
69
|
- Rakefile
|
65
70
|
- init.rb
|
66
71
|
- lib/gowalla.rb
|
72
|
+
- lib/gowalla/activity.rb
|
67
73
|
- lib/gowalla/address.rb
|
68
74
|
- lib/gowalla/base.rb
|
75
|
+
- lib/gowalla/category.rb
|
69
76
|
- lib/gowalla/checkin.rb
|
77
|
+
- lib/gowalla/event.rb
|
78
|
+
- lib/gowalla/map_bound.rb
|
70
79
|
- lib/gowalla/spot.rb
|
71
80
|
- lib/gowalla/stamp.rb
|
81
|
+
- lib/gowalla/top_10.rb
|
72
82
|
- lib/gowalla/user.rb
|
83
|
+
- test/fixtures/event.json
|
84
|
+
- test/fixtures/spot.json
|
85
|
+
- test/fixtures/spots.json
|
73
86
|
- test/fixtures/stamps.json
|
74
87
|
- test/fixtures/user.json
|
75
88
|
- test/helper.rb
|
89
|
+
- test/test_event.rb
|
90
|
+
- test/test_spot.rb
|
76
91
|
- test/test_stamp.rb
|
77
92
|
- test/test_user.rb
|
78
93
|
- Manifest
|
@@ -111,5 +126,7 @@ signing_key:
|
|
111
126
|
specification_version: 3
|
112
127
|
summary: Gowalla API wrapper for Ruby
|
113
128
|
test_files:
|
129
|
+
- test/test_event.rb
|
130
|
+
- test/test_spot.rb
|
114
131
|
- test/test_stamp.rb
|
115
132
|
- test/test_user.rb
|