octopussy 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/changelog.markdown +18 -5
- data/lib/octopussy.rb +32 -110
- data/lib/octopussy/client.rb +31 -66
- data/octopussy.gemspec +16 -13
- data/test/fixtures/list_branch_commits.json +48 -0
- data/test/fixtures/list_commits.json +824 -0
- data/test/fixtures/show_commit.json +37 -0
- data/test/helper.rb +9 -14
- data/test/{test_octopussy.rb → octopussy_test.rb} +129 -83
- data/test/{test_repo.rb → repo_test.rb} +3 -3
- metadata +69 -35
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"commit": {
|
3
|
+
"modified": [
|
4
|
+
{
|
5
|
+
"filename": "facebox.css",
|
6
|
+
"diff": "@@ -103,5 +103,5 @@\n \n * html #facebox_overlay { \/* ie6 hack *\/\n position: absolute;\n- height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');\n+ height: expression(\"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'\");\n }"
|
7
|
+
}
|
8
|
+
],
|
9
|
+
"added": [
|
10
|
+
|
11
|
+
],
|
12
|
+
"author": {
|
13
|
+
"name": "Stephen Martin",
|
14
|
+
"login": "",
|
15
|
+
"email": "stephenmartin@stephen-martins-mac-pro.local"
|
16
|
+
},
|
17
|
+
"parents": [
|
18
|
+
{
|
19
|
+
"id": "b9a23779076953b33744261a8b745ff753cce85b"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"removed": [
|
23
|
+
|
24
|
+
],
|
25
|
+
"url": "http:\/\/github.com\/defunkt\/facebox\/commit\/1ff368f79b0f0aa0e1f1d78bcaa8691f94f9703e",
|
26
|
+
"id": "1ff368f79b0f0aa0e1f1d78bcaa8691f94f9703e",
|
27
|
+
"committed_date": "2010-04-23T08:49:45-07:00",
|
28
|
+
"authored_date": "2009-03-19T06:28:05-07:00",
|
29
|
+
"message": "Fixed CSS expression, throwing errors in IE6.",
|
30
|
+
"committer": {
|
31
|
+
"name": "Chris Wanstrath",
|
32
|
+
"login": "defunkt",
|
33
|
+
"email": "chris@ozmm.org"
|
34
|
+
},
|
35
|
+
"tree": "2460799b2a8c55df06690b663cf47874661e6745"
|
36
|
+
}
|
37
|
+
}
|
data/test/helper.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'pathname'
|
3
|
-
require 'rubygems'
|
4
|
-
|
5
|
-
gem 'thoughtbot-shoulda', '>= 2.10.1'
|
6
|
-
gem 'jnunemaker-matchy', '0.4.0'
|
7
|
-
gem 'mocha', '0.9.4'
|
8
|
-
gem 'fakeweb', '>= 1.2.5'
|
9
3
|
|
10
4
|
require 'shoulda'
|
11
5
|
require 'matchy'
|
12
6
|
require 'mocha'
|
13
7
|
require 'fakeweb'
|
14
8
|
|
9
|
+
require 'redgreen'
|
15
10
|
|
16
11
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
12
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -32,14 +27,14 @@ def github_url(url)
|
|
32
27
|
url =~ /^http/ ? url : "http://github.com/api/v2/json#{url}"
|
33
28
|
end
|
34
29
|
|
35
|
-
def
|
36
|
-
options = {:body =>
|
37
|
-
options.merge!({:
|
38
|
-
|
39
|
-
|
40
|
-
end
|
30
|
+
def stub_request(method, url, filename, status=nil)
|
31
|
+
options = {:body => ""}
|
32
|
+
options.merge!({:body => fixture_file(filename)}) if filename
|
33
|
+
options.merge!({:body => status.last}) if status
|
34
|
+
options.merge!({:status => status}) if status
|
41
35
|
|
42
|
-
|
43
|
-
FakeWeb.register_uri(:post, github_url(url), :body => fixture_file(filename))
|
36
|
+
FakeWeb.register_uri(method, github_url(url), options)
|
44
37
|
end
|
45
38
|
|
39
|
+
def stub_get(*args); stub_request(:get, *args) end
|
40
|
+
def stub_post(*args); stub_request(:post, *args) end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class OctopussyTest < Test::Unit::TestCase
|
2
4
|
|
3
|
-
class TestOctopussy < Test::Unit::TestCase
|
4
|
-
|
5
5
|
context "when authenticated" do
|
6
6
|
setup do
|
7
7
|
@client = Octopussy::Client.new(:login => 'pengwynn', :token => 'OU812')
|
@@ -12,235 +12,235 @@ class TestOctopussy < Test::Unit::TestCase
|
|
12
12
|
users = @client.search_users("wynn")
|
13
13
|
users.first.username.should == 'pengwynn'
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
should "return full user info for the authenticated user" do
|
17
17
|
stub_get("/user/show/pengwynn?login=pengwynn&token=OU812", "full_user.json")
|
18
18
|
user = @client.user
|
19
19
|
user.plan.name.should == 'free'
|
20
20
|
user.plan.space.should == 307200
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
should "return followers for a user" do
|
24
24
|
stub_get("/user/show/pengwynn/followers", "followers.json")
|
25
25
|
followers = @client.followers("pengwynn")
|
26
26
|
followers.size.should == 21
|
27
27
|
assert followers.include?("adamstac")
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
should "return followers for the authenticated user" do
|
31
31
|
stub_get("/user/show/pengwynn/followers", "followers.json")
|
32
32
|
followers = @client.followers
|
33
33
|
followers.size.should == 21
|
34
34
|
assert followers.include?("adamstac")
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
should "return users a user follows" do
|
38
38
|
stub_get("/user/show/pengwynn/following", "followers.json")
|
39
39
|
followers = @client.following("pengwynn")
|
40
40
|
followers.size.should == 21
|
41
41
|
assert followers.include?("adamstac")
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
should "return the users the authenticated user follows" do
|
45
45
|
stub_get("/user/show/pengwynn/following", "followers.json")
|
46
46
|
followers = @client.following
|
47
47
|
followers.size.should == 21
|
48
48
|
assert followers.include?("adamstac")
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
should "indicate if one user follows another" do
|
52
52
|
stub_get("/user/show/pengwynn/following", "followers.json")
|
53
53
|
@client.follows?('adamstac')
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
should "return the repos a user watches" do
|
57
57
|
stub_get("/repos/watched/pengwynn", "repos.json")
|
58
58
|
repos = @client.watched
|
59
59
|
repos.first.owner.should == 'jnunemaker'
|
60
60
|
repos.first.forks.should == 120
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
should "return the repos the authenticated user watched" do
|
64
64
|
stub_get("/repos/watched/pengwynn", "repos.json")
|
65
65
|
repos = @client.watched('pengwynn')
|
66
66
|
repos.first.owner.should == 'jnunemaker'
|
67
67
|
repos.first.forks.should == 120
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
should "update user info" do
|
71
71
|
stub_post("/user/show/pengwynn?login=pengwynn&token=OU812", "user.json")
|
72
72
|
user = @client.update_user(:location => "Dallas, TX")
|
73
73
|
user.location.should == 'Dallas, TX'
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
should "return emails for the authenticated user" do
|
77
77
|
stub_get("/user/emails?login=pengwynn&token=OU812", "emails.json")
|
78
78
|
emails = @client.emails
|
79
79
|
emails.size.should == 3
|
80
80
|
assert emails.include? "wynn@orrka.com"
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
should "add an email for the authenticated user" do
|
84
84
|
stub_post("/user/email/add?login=pengwynn&token=OU812", "emails.json")
|
85
85
|
emails = @client.add_email('wynn@orrka.com')
|
86
86
|
emails.size.should == 3
|
87
87
|
assert emails.include? "wynn@orrka.com"
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
should "remove an email for the authenticated user" do
|
91
91
|
stub_post("/user/email/remove?login=pengwynn&token=OU812", "emails.json")
|
92
92
|
emails = @client.remove_email('wynn@squeejee.com')
|
93
93
|
emails.size.should == 3
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
should "return keys for the authenticated user" do
|
97
97
|
stub_get("/user/keys?login=pengwynn&token=OU812", "keys.json")
|
98
98
|
keys = @client.keys
|
99
99
|
keys.size.should == 6
|
100
100
|
keys.last.title.should == 'wynn@pengwynn.local'
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
should "add an key for the authenticated user" do
|
104
104
|
stub_post("/user/key/add?login=pengwynn&token=OU812", "keys.json")
|
105
105
|
keys = @client.add_key('pengwynn', 'ssh-rsa 009aasd0kalsdfa-sd9a-sdf')
|
106
106
|
keys.size.should == 6
|
107
107
|
keys.last.title.should == 'wynn@pengwynn.local'
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
should "remove an key for the authenticated user" do
|
111
111
|
stub_post("/user/key/remove?login=pengwynn&token=OU812", "keys.json")
|
112
112
|
keys = @client.remove_key(1234)
|
113
113
|
keys.size.should == 6
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
should "open an issue" do
|
117
117
|
stub_post "/issues/open/pengwynn/linkedin", "open_issue.json"
|
118
118
|
issue = @client.open_issue({:username => "pengwynn", :repo => "linkedin"}, "testing", "Testing api")
|
119
119
|
issue.title.should == "testing"
|
120
120
|
issue.number.should == 2
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
should "close an issue" do
|
124
124
|
stub_post "/issues/close/pengwynn/linkedin/2", "close_issue.json"
|
125
125
|
issue = @client.close_issue({:username => "pengwynn", :repo => "linkedin"}, 2)
|
126
126
|
issue.title.should == "testing"
|
127
127
|
issue.number.should == 2
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
should "reopen an issue" do
|
131
131
|
stub_post "/issues/reopen/pengwynn/linkedin/2", "reopen_issue.json"
|
132
132
|
issue = @client.close_issue({:username => "pengwynn", :repo => "linkedin"}, 2)
|
133
133
|
issue.title.should == "testing"
|
134
134
|
issue.number.should == 2
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
should "edit an issue" do
|
138
138
|
stub_post "/issues/edit/pengwynn/linkedin/2", "open_issue.json"
|
139
139
|
issue = @client.update_issue("pengwynn/linkedin", 2, "testing", "Testing api")
|
140
140
|
issue.title.should == "testing"
|
141
141
|
issue.number.should == 2
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
should "list issue labels for a repo" do
|
145
145
|
stub_get "/issues/labels/pengwynn/linkedin", "labels.json"
|
146
146
|
labels = @client.labels("pengwynn/linkedin")
|
147
147
|
labels.first.should == 'oauth'
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
should "add a label to an issue" do
|
151
151
|
stub_post("/issues/label/add/pengwynn/linkedin/oauth/2", "labels.json")
|
152
152
|
labels = @client.add_label('pengwynn/linkedin', 2, 'oauth')
|
153
153
|
assert labels.include?("oauth")
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
should "remove a label from an issue" do
|
157
157
|
stub_post("/issues/label/remove/pengwynn/linkedin/oauth/2", "labels.json")
|
158
158
|
labels = @client.remove_label('pengwynn/linkedin', 2, 'oauth')
|
159
159
|
assert labels.is_a?(Array)
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
should "add a comment to an issue" do
|
163
163
|
stub_post("/issues/comment/pengwynn/linkedin/2", "comment.json")
|
164
164
|
comment = @client.add_comment('pengwynn/linkedin', 2, 'Nice catch!')
|
165
165
|
comment.comment.should == 'Nice catch!'
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
should "watch a repository" do
|
169
169
|
stub_post("/repos/watch/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
|
170
170
|
repo = @client.watch('pengwynn/linkedin')
|
171
171
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
should "unwatch a repository" do
|
175
175
|
stub_post("/repos/unwatch/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
|
176
176
|
repo = @client.unwatch('pengwynn/linkedin')
|
177
177
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
should "fork a repository" do
|
181
181
|
stub_post("/repos/fork/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
|
182
182
|
repo = @client.fork('pengwynn/linkedin')
|
183
183
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
should "create a repository" do
|
187
187
|
stub_post("/repos/create?login=pengwynn&token=OU812", "repo.json")
|
188
188
|
repo = @client.create(:name => 'linkedin', :description => 'Ruby wrapper for the LinkedIn API', :homepage => 'http://bit.ly/ruby-linkedin', :public => 1)
|
189
189
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
# should "return a delete_token when calling delete without supplying a delete_token" do
|
193
193
|
#
|
194
194
|
# end
|
195
|
-
|
195
|
+
|
196
196
|
should "set a repo's visibility to private" do
|
197
197
|
stub_post("/repos/set/private/linkedin?login=pengwynn&token=OU812", "repo.json")
|
198
198
|
repo = @client.set_private('linkedin')
|
199
199
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
should "set a repo's visibility to public" do
|
203
203
|
stub_post("/repos/set/public/linkedin?login=pengwynn&token=OU812", "repo.json")
|
204
204
|
repo = @client.set_public('linkedin')
|
205
205
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
should "return deploy keys for a repo" do
|
209
209
|
stub_get("/repos/keys/linkedin?login=pengwynn&token=OU812", "keys.json")
|
210
210
|
keys = @client.deploy_keys('linkedin')
|
211
211
|
keys.size.should == 6
|
212
212
|
keys.last.title.should == 'wynn@pengwynn.local'
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
should "add a deploy key for a repo" do
|
216
216
|
stub_post("/repos/key/linkedin/add?login=pengwynn&token=OU812", "keys.json")
|
217
217
|
keys = @client.add_deploy_key('pengwynn/linkedin', 'ssh-rsa 009aasd0kalsdfa-sd9a-sdf')
|
218
218
|
keys.size.should == 6
|
219
219
|
keys.last.title.should == 'wynn@pengwynn.local'
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
should "remove a deploy key for a repo" do
|
223
223
|
stub_post("/repos/key/linkedin/remove?login=pengwynn&token=OU812", "keys.json")
|
224
224
|
keys = @client.remove_deploy_key('linkedin', 1234)
|
225
225
|
keys.size.should == 6
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
should "add a collaborator to a repo" do
|
229
229
|
stub_post("/repos/collaborators/linkedin/add/adamstac?login=pengwynn&token=OU812", "collaborators.json")
|
230
230
|
collaborators = @client.add_collaborator("linkedin", "adamstac")
|
231
231
|
collaborators.first.should == 'pengwynn'
|
232
232
|
end
|
233
|
-
|
233
|
+
|
234
234
|
should "remove a collaborator from a repo" do
|
235
235
|
stub_post("/repos/collaborators/linkedin/remove/adamstac?login=pengwynn&token=OU812", "collaborators.json")
|
236
236
|
collaborators = @client.remove_collaborator("linkedin", "adamstac")
|
237
237
|
collaborators.last.should == 'adamstac'
|
238
238
|
end
|
239
|
-
|
240
|
-
|
239
|
+
|
240
|
+
|
241
241
|
end
|
242
|
-
|
243
|
-
|
242
|
+
|
243
|
+
|
244
244
|
context "when unauthenticated" do
|
245
245
|
|
246
246
|
should "search users" do
|
@@ -248,7 +248,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
248
248
|
users = Octopussy.search_users("wynn")
|
249
249
|
users.first.username.should == 'pengwynn'
|
250
250
|
end
|
251
|
-
|
251
|
+
|
252
252
|
should "return user info" do
|
253
253
|
stub_get("/user/show/pengwynn", "user.json")
|
254
254
|
user = Octopussy.user("pengwynn")
|
@@ -256,107 +256,107 @@ class TestOctopussy < Test::Unit::TestCase
|
|
256
256
|
user.blog.should == 'http://wynnnetherland.com'
|
257
257
|
user.name.should == 'Wynn Netherland'
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
should "return followers for a user" do
|
261
261
|
stub_get("/user/show/pengwynn/followers", "followers.json")
|
262
262
|
followers = Octopussy.followers("pengwynn")
|
263
263
|
followers.size.should == 21
|
264
264
|
assert followers.include?("adamstac")
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
should "indicate if one user follows another" do
|
268
268
|
stub_get("/user/show/pengwynn/following", "followers.json")
|
269
269
|
assert Octopussy.follows?('pengwynn', 'adamstac')
|
270
270
|
end
|
271
|
-
|
271
|
+
|
272
272
|
should "return users a user follows" do
|
273
273
|
stub_get("/user/show/pengwynn/following", "followers.json")
|
274
274
|
followers = Octopussy.following("pengwynn")
|
275
275
|
followers.size.should == 21
|
276
276
|
assert followers.include?("adamstac")
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
279
|
should "return the repos a user watches" do
|
280
280
|
stub_get("/repos/watched/pengwynn", "repos.json")
|
281
281
|
repos = Octopussy.watched('pengwynn')
|
282
282
|
repos.first.owner.should == 'jnunemaker'
|
283
283
|
repos.first.forks.should == 120
|
284
284
|
end
|
285
|
-
|
285
|
+
|
286
286
|
should "search issues for a repo" do
|
287
287
|
stub_get("/issues/search/jnunemaker/twitter/open/httparty", "issues.json")
|
288
288
|
issues = Octopussy.search_issues({:username => 'jnunemaker', :repo => 'twitter'}, 'open', 'httparty')
|
289
289
|
issues.first.title.should == 'Crack error when creating friendship'
|
290
290
|
issues.first.votes.should == 2
|
291
291
|
end
|
292
|
-
|
292
|
+
|
293
293
|
should "list issues for a repo" do
|
294
294
|
stub_get("/issues/list/jnunemaker/twitter/open", "issues.json")
|
295
295
|
issues = Octopussy.issues({:username => 'jnunemaker', :repo => 'twitter'}, 'open')
|
296
296
|
issues.first.title.should == 'Crack error when creating friendship'
|
297
297
|
issues.first.votes.should == 2
|
298
298
|
end
|
299
|
-
|
299
|
+
|
300
300
|
should "return issue info" do
|
301
301
|
stub_get("/issues/show/jnunemaker/twitter/3", "issue.json")
|
302
302
|
issue = Octopussy.issue({:username => 'jnunemaker', :repo => 'twitter'}, 3)
|
303
303
|
issue.title.should == 'Crack error when creating friendship'
|
304
304
|
issue.votes.should == 2
|
305
305
|
end
|
306
|
-
|
306
|
+
|
307
307
|
# Repos
|
308
|
-
|
308
|
+
|
309
309
|
should "search repos" do
|
310
310
|
stub_get("/repos/search/compass", "repo_search.json")
|
311
311
|
repos = Octopussy.search_repos("compass")
|
312
312
|
repos.first.username.should == 'chriseppstein'
|
313
313
|
repos.first.language.should == 'Ruby'
|
314
314
|
end
|
315
|
-
|
315
|
+
|
316
316
|
should "return repo information" do
|
317
317
|
stub_get("/repos/show/pengwynn/linkedin", "repo.json")
|
318
318
|
repo = Octopussy.repo({:username => "pengwynn", :repo => "linkedin"})
|
319
319
|
repo.homepage.should == "http://bit.ly/ruby-linkedin"
|
320
320
|
end
|
321
|
-
|
321
|
+
|
322
322
|
should "list repos for a user" do
|
323
323
|
stub_get("/repos/show/pengwynn", "repos.json")
|
324
324
|
repos = Octopussy.list_repos('pengwynn')
|
325
325
|
repos.first.name.should == 'twitter'
|
326
326
|
repos.first.watchers.should == 609
|
327
327
|
end
|
328
|
-
|
328
|
+
|
329
329
|
should "list collaborators for a repo" do
|
330
330
|
stub_post("/repos/show/pengwynn/octopussy/collaborators", "collaborators.json")
|
331
331
|
users = Octopussy.collaborators({:username => "pengwynn", :repo => "octopussy"})
|
332
332
|
users.last.should == 'adamstac'
|
333
333
|
end
|
334
|
-
|
334
|
+
|
335
335
|
should "show the network for a repo" do
|
336
336
|
stub_get("/repos/show/pengwynn/linkedin/network", "network.json")
|
337
337
|
network = Octopussy.network({:username => 'pengwynn', :repo => "linkedin"})
|
338
338
|
network.last.owner.should == 'nfo'
|
339
339
|
end
|
340
|
-
|
340
|
+
|
341
341
|
should "show the language breakdown for a repo" do
|
342
342
|
stub_get("/repos/show/pengwynn/linkedin/languages", "languages.json")
|
343
343
|
languages = Octopussy.languages({:username => 'pengwynn', :repo => "linkedin"})
|
344
344
|
languages['Ruby'].should == 21515
|
345
345
|
end
|
346
|
-
|
346
|
+
|
347
347
|
should "list all the tags in a repo" do
|
348
348
|
stub_get("/repos/show/pengwynn/linkedin/tags", "tags.json")
|
349
349
|
tags = Octopussy.tags(:username => 'pengwynn', :repo => "linkedin")
|
350
350
|
assert tags.include?("v0.0.1")
|
351
351
|
end
|
352
|
-
|
352
|
+
|
353
353
|
should "list all the branches in a repo" do
|
354
354
|
stub_get("/repos/show/pengwynn/linkedin/branches", "branches.json")
|
355
355
|
branches = Octopussy.branches(:username => 'pengwynn', :repo => "linkedin")
|
356
356
|
assert branches.include?("integration")
|
357
357
|
end
|
358
|
-
|
359
|
-
|
358
|
+
|
359
|
+
|
360
360
|
# network
|
361
361
|
should "return network meta info for a repo" do
|
362
362
|
stub_get("http://github.com/schacon/simplegit/network_meta", "network_meta.json")
|
@@ -364,7 +364,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
364
364
|
info.users.first.name.should == 'schacon'
|
365
365
|
info.users.first.repo.should == 'simplegit'
|
366
366
|
end
|
367
|
-
|
367
|
+
|
368
368
|
should "return first 100 commits by branch" do
|
369
369
|
stub_get("http://github.com/schacon/simplegit/network_data_chunk?nethash=fa8fe264b926cdebaab36420b6501bd74402a6ff", "network_data.json")
|
370
370
|
info = Octopussy.network_data({:username => "schacon", :repo => "simplegit"}, "fa8fe264b926cdebaab36420b6501bd74402a6ff")
|
@@ -378,24 +378,70 @@ class TestOctopussy < Test::Unit::TestCase
|
|
378
378
|
trees.first.name.should == '.gitignore'
|
379
379
|
trees.first.sha.should == 'e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf'
|
380
380
|
end
|
381
|
-
|
381
|
+
|
382
382
|
should "return data about a blob by tree SHA and path" do
|
383
383
|
stub_get("http://github.com/api/v2/json/blob/show/defunkt/facebox/d4fc2d5e810d9b4bc1ce67702603080e3086a4ed/README.txt", "blob.json")
|
384
384
|
blob = Octopussy.blob({:username => "defunkt", :repo => "facebox"}, "d4fc2d5e810d9b4bc1ce67702603080e3086a4ed", "README.txt")
|
385
385
|
blob.name.should == 'README.txt'
|
386
386
|
blob.sha.should == 'd4fc2d5e810d9b4bc1ce67702603080e3086a4ed'
|
387
387
|
end
|
388
|
-
|
388
|
+
|
389
389
|
should "return the contents of a blob with the blob's SHA" do
|
390
390
|
stub_get("http://github.com/api/v2/yaml/blob/show/defunkt/facebox/4bf7a39e8c4ec54f8b4cd594a3616d69004aba69", "raw_git_data.json")
|
391
391
|
raw_text = Octopussy.raw({:username => "defunkt", :repo => "facebox"}, "4bf7a39e8c4ec54f8b4cd594a3616d69004aba69")
|
392
392
|
assert raw_text.include?("cd13d9a61288dceb0a7aa73b55ed2fd019f4f1f7")
|
393
393
|
end
|
394
394
|
|
395
|
+
#commits
|
396
|
+
should "list commits for a repo's master branch by default" do
|
397
|
+
stub_get("http://github.com/api/v2/json/commits/list/defunkt/facebox/master", "list_commits.json")
|
398
|
+
commits_list = Octopussy.list_commits({:username => "defunkt", :repo => "facebox"})
|
399
|
+
assert commits_list.any? { |c| c.message == "Fixed CSS expression, throwing errors in IE6." }
|
400
|
+
end
|
401
|
+
|
402
|
+
should "list commits for a repo on a given branch" do
|
403
|
+
stub_get("http://github.com/api/v2/json/commits/list/schacon/simplegit/m/dev/cp", "list_branch_commits.json")
|
404
|
+
commits_list = Octopussy.list_commits({:username => "schacon", :repo => "simplegit"}, "m/dev/cp")
|
405
|
+
assert commits_list.any? { |c| c.message == "removed unnecessary test code" }
|
406
|
+
end
|
407
|
+
|
408
|
+
should "show a specific commit for a repo given its SHA" do
|
409
|
+
sha = "1ff368f79b0f0aa0e1f1d78bcaa8691f94f9703e"
|
410
|
+
stub_get("http://github.com/api/v2/json/commits/show/defunkt/facebox/#{sha}", "show_commit.json")
|
411
|
+
show_commit = Octopussy.commit({:username => "defunkt", :repo => "facebox"}, sha)
|
412
|
+
assert show_commit.message == "Fixed CSS expression, throwing errors in IE6."
|
413
|
+
end
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
context "when Github responds with an error" do
|
418
|
+
{
|
419
|
+
["401", "Unauthorized"] => Octopussy::Unauthorized,
|
420
|
+
["403", "Rate Limit Exceeded"] => Octopussy::RateLimitExceeded,
|
421
|
+
["404", "Not Found"] => Octopussy::NotFound,
|
422
|
+
["406", "Not Acceptable"] => Octopussy::ClientError,
|
423
|
+
["500", "Server Error"] => Octopussy::ServerError,
|
424
|
+
["501", "Not Implemented"] => Octopussy::ServerError
|
425
|
+
}.each do |status, exception|
|
426
|
+
context "#{status.first}, a get" do
|
427
|
+
should "raise an #{exception.name} error" do
|
428
|
+
stub_get("/user/show/pengwynn", nil, status)
|
429
|
+
lambda { Octopussy.user("pengwynn") }.should raise_error(exception)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
context "#{status.first}, a post" do
|
434
|
+
should "raise an #{exception.name} error" do
|
435
|
+
stub_post("/user/show/pengwynn?login=pengwynn&token=OU812", nil, status)
|
436
|
+
client = Octopussy::Client.new(:login => 'pengwynn', :token => 'OU812')
|
437
|
+
lambda { client.update_user(:location => "Dallas, TX") }.should raise_error(exception)
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
395
441
|
end
|
396
|
-
|
442
|
+
|
397
443
|
context "when consuming feeds" do
|
398
|
-
|
444
|
+
|
399
445
|
should "should set user, title, and published time for the event" do
|
400
446
|
entry = Hashie::Mash.new({
|
401
447
|
:id => 'tag:github.com,2008:CreateEvent/110645788',
|
@@ -414,7 +460,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
414
460
|
event.title.should == 'pengwynn created tag v0.7.10 at jnunemaker/twitter'
|
415
461
|
event.links.first.should == 'http://github.com/jnunemaker/twitter/tree/v0.7.10'
|
416
462
|
end
|
417
|
-
|
463
|
+
|
418
464
|
should "should create a repo event from an atom entry" do
|
419
465
|
entry = Hashie::Mash.new({
|
420
466
|
:id => 'tag:github.com,2008:CreateEvent/110645788',
|
@@ -447,7 +493,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
447
493
|
event.repo.name.should == 'twitter'
|
448
494
|
event.tag.should == 'v0.7.10'
|
449
495
|
end
|
450
|
-
|
496
|
+
|
451
497
|
should "should create a branch event from an atom entry" do
|
452
498
|
entry = Hashie::Mash.new({
|
453
499
|
:id => 'tag:github.com,2008:CreateEvent/110645788',
|
@@ -465,7 +511,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
465
511
|
event.user.should == 'cwcore'
|
466
512
|
event.branch.should == 'cwcore-0.1'
|
467
513
|
end
|
468
|
-
|
514
|
+
|
469
515
|
should "should create a push event from an atom entry" do
|
470
516
|
entry = Hashie::Mash.new({
|
471
517
|
:id => 'tag:github.com,2008:PushEvent/110645788',
|
@@ -481,7 +527,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
481
527
|
event.repo.name.should == 'twitter'
|
482
528
|
event.branch.should == 'master'
|
483
529
|
end
|
484
|
-
|
530
|
+
|
485
531
|
should "should create a fork event from an atom entry" do
|
486
532
|
entry = Hashie::Mash.new({
|
487
533
|
:id => 'tag:github.com,2008:ForkEvent/110645788',
|
@@ -498,7 +544,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
498
544
|
event.repo.name.should == 'aeon'
|
499
545
|
event.forked_from.username.should == 'djh'
|
500
546
|
end
|
501
|
-
|
547
|
+
|
502
548
|
should "should create a watch event from an atom entry" do
|
503
549
|
entry = Hashie::Mash.new({
|
504
550
|
:id => 'tag:github.com,2008:WatchEvent/110645788',
|
@@ -514,7 +560,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
514
560
|
event.repo.username.should == 'bogolisk'
|
515
561
|
event.repo.name.should == 'egg'
|
516
562
|
end
|
517
|
-
|
563
|
+
|
518
564
|
should "should create a follow event from an atom entry" do
|
519
565
|
entry = Hashie::Mash.new({
|
520
566
|
:id => 'tag:github.com,2008:FollowEvent/110645788',
|
@@ -530,7 +576,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
530
576
|
event.repo.should == nil
|
531
577
|
event.target_user.should == 'swistak'
|
532
578
|
end
|
533
|
-
|
579
|
+
|
534
580
|
should "should create an issues event from an atom entry" do
|
535
581
|
entry = Hashie::Mash.new({
|
536
582
|
:id => 'tag:github.com,2008:IssuesEvent/110645788',
|
@@ -547,7 +593,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
547
593
|
event.action.should == 'closed'
|
548
594
|
event.issue_number.should == 19
|
549
595
|
end
|
550
|
-
|
596
|
+
|
551
597
|
should "should create a gist event from an atom entry" do
|
552
598
|
entry = Hashie::Mash.new({
|
553
599
|
:id => 'tag:github.com,2008:GistEvent/110645788',
|
@@ -563,7 +609,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
563
609
|
event.repo.should == nil
|
564
610
|
event.gist_number.should == 253987
|
565
611
|
end
|
566
|
-
|
612
|
+
|
567
613
|
should "should create a member event from an atom entry" do
|
568
614
|
entry = Hashie::Mash.new({
|
569
615
|
:id => 'tag:github.com,2008:MemberEvent/110645788',
|
@@ -579,7 +625,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
579
625
|
event.repo.name.should == 'octopussy'
|
580
626
|
event.target_user.should == 'adamstac'
|
581
627
|
end
|
582
|
-
|
628
|
+
|
583
629
|
should "should create a fork_apply event from an atom entry" do
|
584
630
|
entry = Hashie::Mash.new({
|
585
631
|
:id => 'tag:github.com,2008:ForkApplyEvent/110645788',
|
@@ -595,7 +641,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
595
641
|
event.repo.name.should == 'linkedin'
|
596
642
|
event.branch.should == 'integration'
|
597
643
|
end
|
598
|
-
|
644
|
+
|
599
645
|
should "should create a wiki event from an atom entry" do
|
600
646
|
entry = Hashie::Mash.new({
|
601
647
|
:id => 'tag:github.com,2008:WikiEvent/110645788',
|
@@ -611,7 +657,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
611
657
|
event.repo.name.should == 'Fammel'
|
612
658
|
event.page.should == 'documentation'
|
613
659
|
end
|
614
|
-
|
660
|
+
|
615
661
|
should "should create a comment event from an atom entry" do
|
616
662
|
entry = Hashie::Mash.new({
|
617
663
|
:id => 'tag:github.com,2008:CommitCommentEvent/110645788',
|
@@ -626,7 +672,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
626
672
|
event.event_type.should == 'comment'
|
627
673
|
event.repo.name.should == 'resque'
|
628
674
|
end
|
629
|
-
|
675
|
+
|
630
676
|
should "should create a delete event from an atom entry" do
|
631
677
|
entry = Hashie::Mash.new({
|
632
678
|
:id => 'tag:github.com,2008:DeleteEvent/110645788',
|
@@ -642,7 +688,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
642
688
|
event.repo.name.should == 'vimlike-smooziee'
|
643
689
|
event.branch.should == 'search'
|
644
690
|
end
|
645
|
-
|
691
|
+
|
646
692
|
should "should create a public event from an atom entry" do
|
647
693
|
entry = Hashie::Mash.new({
|
648
694
|
:id => 'tag:github.com,2008:PublicEvent/110645788',
|
@@ -657,7 +703,7 @@ class TestOctopussy < Test::Unit::TestCase
|
|
657
703
|
event.event_type.should == 'public'
|
658
704
|
event.repo.name.should == 'bpmn2'
|
659
705
|
end
|
660
|
-
|
706
|
+
|
661
707
|
should "should create a download event from an atom entry" do
|
662
708
|
entry = Hashie::Mash.new({
|
663
709
|
:id => 'tag:github.com,2008:DownloadEvent/110645788',
|
@@ -673,6 +719,6 @@ class TestOctopussy < Test::Unit::TestCase
|
|
673
719
|
event.repo.name.should == 'prototype'
|
674
720
|
end
|
675
721
|
end
|
676
|
-
|
677
|
-
|
722
|
+
|
723
|
+
|
678
724
|
end
|