baby_tooth 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/baby_tooth.gemspec +19 -8
- data/lib/baby_tooth.rb +9 -45
- data/lib/baby_tooth/client.rb +45 -0
- data/lib/baby_tooth/fitness_activity.rb +4 -0
- data/lib/baby_tooth/fitness_activity_feed.rb +11 -0
- data/lib/baby_tooth/profile.rb +13 -0
- data/lib/baby_tooth/team_feed.rb +7 -0
- data/lib/baby_tooth/user.rb +21 -0
- data/test/fixtures/vcr_cassettes/fitness_activities.yml +171 -0
- data/test/fixtures/vcr_cassettes/street_team.yml +55 -0
- data/test/helper.rb +4 -1
- data/test/test_baby_tooth.rb +67 -39
- metadata +58 -34
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.runkeeper.com:80/user
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- application/vnd.com.runkeeper.User+json
|
10
|
+
authorization:
|
11
|
+
- Bearer TEST_TOKEN
|
12
|
+
response: !ruby/struct:VCR::Response
|
13
|
+
status: !ruby/struct:VCR::ResponseStatus
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
content-type:
|
18
|
+
- application/vnd.com.runkeeper.user+json;charset=ISO-8859-1
|
19
|
+
content-language:
|
20
|
+
- en-US
|
21
|
+
server:
|
22
|
+
- Apache-Coyote/1.1
|
23
|
+
date:
|
24
|
+
- Sun, 11 Sep 2011 20:59:17 GMT
|
25
|
+
content-length:
|
26
|
+
- "379"
|
27
|
+
body: "{\"strength_training_activities\":\"/strengthTrainingActivities\",\"weight\":\"/weight\",\"settings\":\"/settings\",\"diabetes\":\"/diabetes\",\"team\":\"/team\",\"sleep\":\"/sleep\",\"fitness_activities\":\"/fitnessActivities\",\"userID\":1625209,\"nutrition\":\"/nutrition\",\"general_measurements\":\"/generalMeasurements\",\"background_activities\":\"/backgroundActivities\",\"records\":\"/records\",\"profile\":\"/profile\"}"
|
28
|
+
http_version: "1.1"
|
29
|
+
- !ruby/struct:VCR::HTTPInteraction
|
30
|
+
request: !ruby/struct:VCR::Request
|
31
|
+
method: :get
|
32
|
+
uri: http://api.runkeeper.com:80/team
|
33
|
+
body:
|
34
|
+
headers:
|
35
|
+
accept:
|
36
|
+
- application/vnd.com.runkeeper.TeamFeed+json
|
37
|
+
authorization:
|
38
|
+
- Bearer TEST_TOKEN
|
39
|
+
response: !ruby/struct:VCR::Response
|
40
|
+
status: !ruby/struct:VCR::ResponseStatus
|
41
|
+
code: 200
|
42
|
+
message: OK
|
43
|
+
headers:
|
44
|
+
content-type:
|
45
|
+
- application/vnd.com.runkeeper.teamfeed+json;charset=ISO-8859-1
|
46
|
+
content-language:
|
47
|
+
- en-US
|
48
|
+
server:
|
49
|
+
- Apache-Coyote/1.1
|
50
|
+
date:
|
51
|
+
- Sun, 11 Sep 2011 20:59:17 GMT
|
52
|
+
content-length:
|
53
|
+
- "1158"
|
54
|
+
body: "{\"items\":[{\"name\":\"Ryan Palmer\",\"url\":\"/team/1649313\",\"profile\":\"http://www.runkeeper.com/user/RyanP724\"},{\"name\":\"Cort Johnson\",\"url\":\"/team/1426969\",\"profile\":\"http://www.runkeeper.com/user/cort\"},{\"name\":\"Jake Boxer\",\"url\":\"/team/1900138\",\"profile\":\"http://www.runkeeper.com/user/jboxer\"},{\"name\":\"Nicolas Warren\",\"url\":\"/team/1219339\",\"profile\":\"http://www.runkeeper.com/user/Nicolaswarren\"},{\"name\":\"Nick\",\"url\":\"/team/387603\",\"profile\":\"http://www.runkeeper.com/user/NickHerbold\"},{\"name\":\"Jake Cacciapaglia\",\"url\":\"/team/992916\",\"profile\":\"http://www.runkeeper.com/user/JakeCacci\"},{\"name\":\"Tom Boates\",\"url\":\"/team/50885\",\"profile\":\"http://www.runkeeper.com/user/tomboates\"},{\"name\":\"Sarah Hodges\",\"url\":\"/team/1520437\",\"profile\":\"http://www.runkeeper.com/user/SHodges\"},{\"name\":\"Dwayne Harris\",\"url\":\"/team/1261047\",\"profile\":\"http://www.runkeeper.com/user/djsstrat\"},{\"name\":\"Carlos Rodarte\",\"url\":\"/team/6472900\",\"profile\":\"http://www.runkeeper.com/user/crodarte\"},{\"url\":\"/team/2955498\",\"profile\":\"http://www.runkeeper.com/user/semanticart\"},{\"name\":\"Ryan Neu\",\"url\":\"/team/6421590\",\"profile\":\"http://www.runkeeper.com/user/ryanRneu\"}],\"size\":12}"
|
55
|
+
http_version: "1.1"
|
data/test/helper.rb
CHANGED
@@ -21,7 +21,10 @@ WebMock.disable_net_connect!
|
|
21
21
|
VCR.config do |config|
|
22
22
|
config.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
23
23
|
config.stub_with :webmock
|
24
|
-
config.default_cassette_options = {
|
24
|
+
config.default_cassette_options = {
|
25
|
+
:record => :none,
|
26
|
+
:match_requests_on => [:method, :uri, :headers]
|
27
|
+
}
|
25
28
|
end
|
26
29
|
|
27
30
|
require 'baby_tooth'
|
data/test/test_baby_tooth.rb
CHANGED
@@ -1,73 +1,49 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestBabyTooth < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
BabyTooth.configure do |config|
|
6
|
+
config.access_token_url = "http://runkeeper.com/apps/token"
|
7
|
+
config.authorization_url = "http://runkeeper.com/apps/authorize"
|
8
|
+
config.client_secret = "SECRET"
|
9
|
+
config.client_id = "CLIENT_ID"
|
10
|
+
config.redirect_uri = "http://my.app/authorization"
|
11
|
+
config.site = "http://api.runkeeper.com"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
context "configure" do
|
5
16
|
should "accept client_id" do
|
6
|
-
BabyTooth.configure do |config|
|
7
|
-
config.client_id = "CLIENT_ID"
|
8
|
-
end
|
9
|
-
|
10
17
|
assert_equal "CLIENT_ID", BabyTooth.configuration.client_id
|
11
18
|
end
|
12
19
|
|
13
20
|
should "accept client_secret" do
|
14
|
-
BabyTooth.
|
15
|
-
config.client_secret = "CLIENT_SECRET"
|
16
|
-
end
|
17
|
-
|
18
|
-
assert_equal "CLIENT_SECRET", BabyTooth.configuration.client_secret
|
21
|
+
assert_equal "SECRET", BabyTooth.configuration.client_secret
|
19
22
|
end
|
20
23
|
|
21
24
|
should "accept authorization_url" do
|
22
|
-
BabyTooth.configure do |config|
|
23
|
-
config.authorization_url = "http://runkeeper.com/apps/authorize"
|
24
|
-
end
|
25
|
-
|
26
25
|
assert_equal "http://runkeeper.com/apps/authorize", BabyTooth.configuration.authorization_url
|
27
26
|
end
|
28
27
|
|
29
28
|
should "accept access_token_url" do
|
30
|
-
BabyTooth.configure do |config|
|
31
|
-
config.access_token_url = "http://runkeeper.com/apps/token"
|
32
|
-
end
|
33
|
-
|
34
29
|
assert_equal "http://runkeeper.com/apps/token", BabyTooth.configuration.access_token_url
|
35
30
|
end
|
36
31
|
|
37
32
|
should "accept redirect_uri" do
|
38
|
-
BabyTooth.configure do |config|
|
39
|
-
config.redirect_uri = "http://my.app/authorization"
|
40
|
-
end
|
41
|
-
|
42
33
|
assert_equal "http://my.app/authorization", BabyTooth.configuration.redirect_uri
|
43
34
|
end
|
44
35
|
end
|
45
36
|
|
46
37
|
context "authorize_url" do
|
47
|
-
should "return a URL with the proper parameters" do
|
48
|
-
|
49
|
-
|
50
|
-
config.authorization_url = "http://runkeeper.com/apps/authorize"
|
51
|
-
config.client_secret = "SECRET"
|
52
|
-
config.client_id = "CLIENT_ID"
|
53
|
-
config.redirect_uri = "http://my.app/authorization"
|
54
|
-
end
|
55
|
-
|
56
|
-
assert_equal "http://runkeeper.com/apps/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Fmy.app%2Fauthorization",
|
57
|
-
BabyTooth.authorize_url
|
38
|
+
should "return a URL with the proper parameters including the passed in state" do
|
39
|
+
assert_equal "http://runkeeper.com/apps/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Fmy.app%2Fauthorization&state=this%20is%20a%20test",
|
40
|
+
BabyTooth.authorize_url('this is a test')
|
58
41
|
end
|
59
42
|
end
|
60
43
|
|
61
44
|
context "get_token" do
|
62
45
|
setup do
|
63
46
|
VCR.insert_cassette 'oauth/token success', :record => :none
|
64
|
-
BabyTooth.configure do |config|
|
65
|
-
config.access_token_url = "http://runkeeper.com/apps/token"
|
66
|
-
config.authorization_url = "http://runkeeper.com/apps/authorize"
|
67
|
-
config.client_secret = "SECRET"
|
68
|
-
config.client_id = "ID"
|
69
|
-
config.redirect_uri = "http://steps.dev/authorization"
|
70
|
-
end
|
71
47
|
end
|
72
48
|
|
73
49
|
teardown do
|
@@ -78,4 +54,56 @@ class TestBabyTooth < Test::Unit::TestCase
|
|
78
54
|
assert_equal "ACCESS_TOKEN", BabyTooth.get_token("TOKEN")
|
79
55
|
end
|
80
56
|
end
|
57
|
+
|
58
|
+
context "fitness_activity_feed" do
|
59
|
+
setup do
|
60
|
+
VCR.insert_cassette 'fitness_activities', :record => :none
|
61
|
+
@user = BabyTooth::User.new('TEST_TOKEN')
|
62
|
+
end
|
63
|
+
|
64
|
+
teardown { VCR.eject_cassette }
|
65
|
+
|
66
|
+
subject { @user.fitness_activity_feed}
|
67
|
+
|
68
|
+
should "be a BabyTooth::FitnessActivityFeed" do
|
69
|
+
assert_kind_of BabyTooth::FitnessActivityFeed, subject
|
70
|
+
end
|
71
|
+
|
72
|
+
context "fitness_activities" do
|
73
|
+
subject { @user.fitness_activity_feed.fitness_activities }
|
74
|
+
|
75
|
+
should "return an array of FitnessActivity objects" do
|
76
|
+
assert_kind_of Array, subject
|
77
|
+
|
78
|
+
assert_equal 13, subject.length
|
79
|
+
|
80
|
+
subject.each do |fitness_activity|
|
81
|
+
assert_kind_of BabyTooth::FitnessActivity, fitness_activity
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "street_team" do
|
88
|
+
setup do
|
89
|
+
VCR.insert_cassette 'street_team', :record => :none
|
90
|
+
@user = BabyTooth::User.new('TEST_TOKEN')
|
91
|
+
end
|
92
|
+
|
93
|
+
teardown { VCR.eject_cassette }
|
94
|
+
|
95
|
+
subject { @user.street_team }
|
96
|
+
|
97
|
+
should "return an array of members" do
|
98
|
+
assert_kind_of Array, subject
|
99
|
+
|
100
|
+
assert_equal 12, subject.size
|
101
|
+
|
102
|
+
teammate = subject.first
|
103
|
+
|
104
|
+
assert_equal 'Ryan Palmer', teammate['name']
|
105
|
+
assert_equal 'http://www.runkeeper.com/user/RyanP724', teammate['profile']
|
106
|
+
assert_equal '/team/1649313', teammate['url']
|
107
|
+
end
|
108
|
+
end
|
81
109
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baby_tooth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joe Lind
|
@@ -15,10 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-21 00:00:00 -04:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
24
|
none: false
|
23
25
|
requirements:
|
24
26
|
- - ~>
|
@@ -30,11 +32,11 @@ dependencies:
|
|
30
32
|
- 0
|
31
33
|
version: 0.5.0
|
32
34
|
name: oauth2
|
35
|
+
version_requirements: *id001
|
33
36
|
prerelease: false
|
34
|
-
type: :runtime
|
35
|
-
requirement: *id001
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
38
|
+
type: :runtime
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
40
42
|
- - ">="
|
@@ -44,11 +46,25 @@ dependencies:
|
|
44
46
|
- 0
|
45
47
|
version: "0"
|
46
48
|
name: faraday-stack
|
49
|
+
version_requirements: *id002
|
47
50
|
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
48
52
|
type: :runtime
|
49
|
-
requirement:
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
name: json
|
63
|
+
version_requirements: *id003
|
64
|
+
prerelease: false
|
50
65
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
66
|
+
type: :development
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
68
|
none: false
|
53
69
|
requirements:
|
54
70
|
- - ">="
|
@@ -58,11 +74,11 @@ dependencies:
|
|
58
74
|
- 0
|
59
75
|
version: "0"
|
60
76
|
name: shoulda
|
77
|
+
version_requirements: *id004
|
61
78
|
prerelease: false
|
62
|
-
type: :development
|
63
|
-
requirement: *id003
|
64
79
|
- !ruby/object:Gem::Dependency
|
65
|
-
|
80
|
+
type: :development
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
66
82
|
none: false
|
67
83
|
requirements:
|
68
84
|
- - ~>
|
@@ -74,11 +90,11 @@ dependencies:
|
|
74
90
|
- 0
|
75
91
|
version: 1.0.0
|
76
92
|
name: bundler
|
93
|
+
version_requirements: *id005
|
77
94
|
prerelease: false
|
78
|
-
type: :development
|
79
|
-
requirement: *id004
|
80
95
|
- !ruby/object:Gem::Dependency
|
81
|
-
|
96
|
+
type: :development
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
82
98
|
none: false
|
83
99
|
requirements:
|
84
100
|
- - ~>
|
@@ -90,11 +106,11 @@ dependencies:
|
|
90
106
|
- 4
|
91
107
|
version: 1.6.4
|
92
108
|
name: jeweler
|
109
|
+
version_requirements: *id006
|
93
110
|
prerelease: false
|
94
|
-
type: :development
|
95
|
-
requirement: *id005
|
96
111
|
- !ruby/object:Gem::Dependency
|
97
|
-
|
112
|
+
type: :development
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
98
114
|
none: false
|
99
115
|
requirements:
|
100
116
|
- - ">="
|
@@ -104,11 +120,11 @@ dependencies:
|
|
104
120
|
- 0
|
105
121
|
version: "0"
|
106
122
|
name: rcov
|
123
|
+
version_requirements: *id007
|
107
124
|
prerelease: false
|
108
|
-
type: :development
|
109
|
-
requirement: *id006
|
110
125
|
- !ruby/object:Gem::Dependency
|
111
|
-
|
126
|
+
type: :development
|
127
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
112
128
|
none: false
|
113
129
|
requirements:
|
114
130
|
- - ">="
|
@@ -118,11 +134,11 @@ dependencies:
|
|
118
134
|
- 0
|
119
135
|
version: "0"
|
120
136
|
name: launchy
|
137
|
+
version_requirements: *id008
|
121
138
|
prerelease: false
|
122
|
-
type: :development
|
123
|
-
requirement: *id007
|
124
139
|
- !ruby/object:Gem::Dependency
|
125
|
-
|
140
|
+
type: :development
|
141
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
126
142
|
none: false
|
127
143
|
requirements:
|
128
144
|
- - ">="
|
@@ -132,11 +148,11 @@ dependencies:
|
|
132
148
|
- 0
|
133
149
|
version: "0"
|
134
150
|
name: ruby-debug
|
151
|
+
version_requirements: *id009
|
135
152
|
prerelease: false
|
136
|
-
type: :development
|
137
|
-
requirement: *id008
|
138
153
|
- !ruby/object:Gem::Dependency
|
139
|
-
|
154
|
+
type: :development
|
155
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
140
156
|
none: false
|
141
157
|
requirements:
|
142
158
|
- - ">="
|
@@ -146,11 +162,11 @@ dependencies:
|
|
146
162
|
- 0
|
147
163
|
version: "0"
|
148
164
|
name: webmock
|
165
|
+
version_requirements: *id010
|
149
166
|
prerelease: false
|
150
|
-
type: :development
|
151
|
-
requirement: *id009
|
152
167
|
- !ruby/object:Gem::Dependency
|
153
|
-
|
168
|
+
type: :development
|
169
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
154
170
|
none: false
|
155
171
|
requirements:
|
156
172
|
- - ">="
|
@@ -160,9 +176,8 @@ dependencies:
|
|
160
176
|
- 0
|
161
177
|
version: "0"
|
162
178
|
name: vcr
|
179
|
+
version_requirements: *id011
|
163
180
|
prerelease: false
|
164
|
-
type: :development
|
165
|
-
requirement: *id010
|
166
181
|
description: A Ruby wrapper for the Health Graph API
|
167
182
|
email: joelind@gmail.com
|
168
183
|
executables: []
|
@@ -182,9 +197,18 @@ files:
|
|
182
197
|
- VERSION
|
183
198
|
- baby_tooth.gemspec
|
184
199
|
- lib/baby_tooth.rb
|
200
|
+
- lib/baby_tooth/client.rb
|
201
|
+
- lib/baby_tooth/fitness_activity.rb
|
202
|
+
- lib/baby_tooth/fitness_activity_feed.rb
|
203
|
+
- lib/baby_tooth/profile.rb
|
204
|
+
- lib/baby_tooth/team_feed.rb
|
205
|
+
- lib/baby_tooth/user.rb
|
206
|
+
- test/fixtures/vcr_cassettes/fitness_activities.yml
|
185
207
|
- test/fixtures/vcr_cassettes/oauth/token_success.yml
|
208
|
+
- test/fixtures/vcr_cassettes/street_team.yml
|
186
209
|
- test/helper.rb
|
187
210
|
- test/test_baby_tooth.rb
|
211
|
+
has_rdoc: true
|
188
212
|
homepage: http://github.com/terriblelabs/BabyTooth
|
189
213
|
licenses:
|
190
214
|
- MIT
|
@@ -214,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
238
|
requirements: []
|
215
239
|
|
216
240
|
rubyforge_project:
|
217
|
-
rubygems_version: 1.
|
241
|
+
rubygems_version: 1.6.2
|
218
242
|
signing_key:
|
219
243
|
specification_version: 3
|
220
244
|
summary: A Ruby wrapper for the Health Graph API
|