octopussy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ {
2
+ "users": [{
3
+ "name": "pengwynn",
4
+ "location": "Dallas, TX",
5
+ "followers": 19,
6
+ "username": "pengwynn",
7
+ "language": "Ruby",
8
+ "fullname": "Wynn Netherland",
9
+ "repos": 15,
10
+ "id": "user-865",
11
+ "type": "user",
12
+ "pushed": "2009-12-05T17:15:06.757Z",
13
+ "score": 2.6885872,
14
+ "created": "2008-02-25T18:24:19Z"
15
+ },
16
+ {
17
+ "name": "mattwynne",
18
+ "location": "London",
19
+ "followers": 13,
20
+ "username": "mattwynne",
21
+ "language": "Ruby",
22
+ "fullname": "Matt Wynne",
23
+ "repos": 13,
24
+ "id": "user-19260",
25
+ "type": "user",
26
+ "pushed": "2009-09-26T18:31:33.171Z",
27
+ "score": 2.6885872,
28
+ "created": "2008-08-01T17:15:11Z"
29
+ },
30
+ {
31
+ "name": "harrywynn",
32
+ "location": "Myrtle Beach, SC",
33
+ "followers": 2,
34
+ "username": "harrywynn",
35
+ "language": "",
36
+ "fullname": "Harry Wynn",
37
+ "repos": 0,
38
+ "id": "user-103879",
39
+ "type": "user",
40
+ "pushed": "2009-09-26T19:13:37.522Z",
41
+ "score": 2.6885872,
42
+ "created": "2009-07-11T12:12:32Z"
43
+ }]
44
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tags": {
3
+ "v0.1.0": "b372d3fbbcef395e8b376d94ad62dc5c91795856",
4
+ "v0.0.1": "432a127e1320559f80d48dde268c8b6587d2825b",
5
+ "v0.1.1": "a202fb290bac4a488f6aee9f2d30ee0738e08602",
6
+ "v0.0.2": "8500d5646fcb9e9983023565d681fc7b64f8cb3e"
7
+ }
8
+ }
@@ -0,0 +1,140 @@
1
+ {
2
+ "tree": [{
3
+ "name": ".gitignore",
4
+ "sha": "e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf",
5
+ "mode": "100644",
6
+ "type": "blob"
7
+ },
8
+ {
9
+ "name": "README.txt",
10
+ "sha": "d4fc2d5e810d9b4bc1ce67702603080e3086a4ed",
11
+ "mode": "100644",
12
+ "type": "blob"
13
+ },
14
+ {
15
+ "name": "b.png",
16
+ "sha": "f184e6269b343014f58694093b55558dd5dde193",
17
+ "mode": "100644",
18
+ "type": "blob"
19
+ },
20
+ {
21
+ "name": "bl.png",
22
+ "sha": "f6271859d51654b6fb2719df5fe192c8398ecefc",
23
+ "mode": "100644",
24
+ "type": "blob"
25
+ },
26
+ {
27
+ "name": "br.png",
28
+ "sha": "31f204fc451cd9dd5cfdadfad2d86ed0e1104882",
29
+ "mode": "100644",
30
+ "type": "blob"
31
+ },
32
+ {
33
+ "name": "build_tar.sh",
34
+ "sha": "08f6f1fce2f6a02dcb15b6c66244470794587bb0",
35
+ "mode": "100755",
36
+ "type": "blob"
37
+ },
38
+ {
39
+ "name": "closelabel.gif",
40
+ "sha": "87b4f8bd699386e3a6fcc2e50d7c61bfc4aabb8d",
41
+ "mode": "100755",
42
+ "type": "blob"
43
+ },
44
+ {
45
+ "name": "facebox.css",
46
+ "sha": "08e190d5f81959d73d2bdd3e4f752271800886bf",
47
+ "mode": "100644",
48
+ "type": "blob"
49
+ },
50
+ {
51
+ "name": "facebox.js",
52
+ "sha": "43245f3b1b50a0568ece00b44d2dc67be413f2a4",
53
+ "mode": "100644",
54
+ "type": "blob"
55
+ },
56
+ {
57
+ "name": "faceplant.css",
58
+ "sha": "dc61a86c3f342b930f0a0447cae33fee812e27d3",
59
+ "mode": "100644",
60
+ "type": "blob"
61
+ },
62
+ {
63
+ "name": "index.html",
64
+ "sha": "a9d1c235d08ae383e4d9dedf5e2cc0236defdaa6",
65
+ "mode": "100644",
66
+ "type": "blob"
67
+ },
68
+ {
69
+ "name": "jquery.js",
70
+ "sha": "ebe02bdd357c337e0e817fcbce2a034a54a13287",
71
+ "mode": "100644",
72
+ "type": "blob"
73
+ },
74
+ {
75
+ "name": "loading.gif",
76
+ "sha": "f864d5fd38b7466c76b5a36dc0e3e9455c0126e2",
77
+ "mode": "100755",
78
+ "type": "blob"
79
+ },
80
+ {
81
+ "name": "logo.png",
82
+ "sha": "e41cfe5c654e8e05ad46f15af1c462a1360e9764",
83
+ "mode": "100644",
84
+ "type": "blob"
85
+ },
86
+ {
87
+ "name": "releases",
88
+ "sha": "82e3a754b6a0fcb238b03c0e47d05219fbf9cf89",
89
+ "mode": "040000",
90
+ "type": "tree"
91
+ },
92
+ {
93
+ "name": "remote.html",
94
+ "sha": "98d3e92373d1bc541e7f516e5e73b645a991ddc2",
95
+ "mode": "100644",
96
+ "type": "blob"
97
+ },
98
+ {
99
+ "name": "screenshots",
100
+ "sha": "bbf747873075ac28667d246491ffdefbd314fe4f",
101
+ "mode": "040000",
102
+ "type": "tree"
103
+ },
104
+ {
105
+ "name": "shadow.gif",
106
+ "sha": "e58b35b362ce5347bb5064e91a3bf8e4fed4f6ef",
107
+ "mode": "100644",
108
+ "type": "blob"
109
+ },
110
+ {
111
+ "name": "stairs.jpg",
112
+ "sha": "63459bb418f5f6d896a8eb925c01f45024933ed6",
113
+ "mode": "100644",
114
+ "type": "blob"
115
+ },
116
+ {
117
+ "name": "test.html",
118
+ "sha": "0a279c66167d358e40682186864935d0f856c4c4",
119
+ "mode": "100644",
120
+ "type": "blob"
121
+ },
122
+ {
123
+ "name": "test_programmatic.html",
124
+ "sha": "0249382efbdc7412a67976d19154ef07ac51437f",
125
+ "mode": "100644",
126
+ "type": "blob"
127
+ },
128
+ {
129
+ "name": "tl.png",
130
+ "sha": "d99c8f6c6eaa12d7b49a20f41f08a5006f3ea8b7",
131
+ "mode": "100644",
132
+ "type": "blob"
133
+ },
134
+ {
135
+ "name": "tr.png",
136
+ "sha": "e99b6ec8310e859fd27519694f04e1babf2ab2c4",
137
+ "mode": "100644",
138
+ "type": "blob"
139
+ }]
140
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "user": {
3
+ "name": "Wynn Netherland",
4
+ "company": "Orrka",
5
+ "location": "Dallas, TX",
6
+ "created_at": "2008/02/25 10:24:19 -0800",
7
+ "public_gist_count": 3,
8
+ "public_repo_count": 15,
9
+ "blog": "http://wynnnetherland.com",
10
+ "following_count": 55,
11
+ "id": 865,
12
+ "followers_count": 21,
13
+ "login": "pengwynn",
14
+ "email": "wynn.netherland@gmail.com"
15
+ }
16
+ }
data/test/helper.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'test/unit'
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
+
10
+ require 'shoulda'
11
+ require 'matchy'
12
+ require 'mocha'
13
+ require 'fakeweb'
14
+
15
+
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
18
+ require 'octopussy'
19
+
20
+ FakeWeb.allow_net_connect = false
21
+
22
+ class Test::Unit::TestCase
23
+ end
24
+
25
+ def fixture_file(filename)
26
+ return '' if filename == ''
27
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
28
+ File.read(file_path)
29
+ end
30
+
31
+ def github_url(url)
32
+ url =~ /^http/ ? url : "http://github.com/api/v2/json#{url}"
33
+ end
34
+
35
+ def stub_get(url, filename, status=nil)
36
+ options = {:body => fixture_file(filename)}
37
+ options.merge!({:status => status}) unless status.nil?
38
+
39
+ FakeWeb.register_uri(:get, github_url(url), options)
40
+ end
41
+
42
+ def stub_post(url, filename)
43
+ FakeWeb.register_uri(:post, github_url(url), :body => fixture_file(filename))
44
+ end
45
+
@@ -0,0 +1,397 @@
1
+ require 'helper'
2
+
3
+ class TestOctopussy < Test::Unit::TestCase
4
+
5
+ context "when authenticated" do
6
+ setup do
7
+ @client = Octopussy::Client.new(:login => 'pengwynn', :token => 'OU812')
8
+ end
9
+
10
+ should "should search users" do
11
+ stub_get("/user/search/wynn", "search.json")
12
+ users = @client.search_users("wynn")
13
+ users.first.username.should == 'pengwynn'
14
+ end
15
+
16
+ should "return full user info for the authenticated user" do
17
+ stub_get("/user/show/pengwynn?login=pengwynn&token=OU812", "full_user.json")
18
+ user = @client.user
19
+ user.plan.name.should == 'free'
20
+ user.plan.space.should == 307200
21
+ end
22
+
23
+ should "return followers for a user" do
24
+ stub_get("/user/show/pengwynn/followers", "followers.json")
25
+ followers = @client.followers("pengwynn")
26
+ followers.size.should == 21
27
+ assert followers.include?("adamstac")
28
+ end
29
+
30
+ should "return followers for the authenticated user" do
31
+ stub_get("/user/show/pengwynn/followers", "followers.json")
32
+ followers = @client.followers
33
+ followers.size.should == 21
34
+ assert followers.include?("adamstac")
35
+ end
36
+
37
+ should "return users a user follows" do
38
+ stub_get("/user/show/pengwynn/following", "followers.json")
39
+ followers = @client.following("pengwynn")
40
+ followers.size.should == 21
41
+ assert followers.include?("adamstac")
42
+ end
43
+
44
+ should "return the users the authenticated user follows" do
45
+ stub_get("/user/show/pengwynn/following", "followers.json")
46
+ followers = @client.following
47
+ followers.size.should == 21
48
+ assert followers.include?("adamstac")
49
+ end
50
+
51
+ should "indicate if one user follows another" do
52
+ stub_get("/user/show/pengwynn/following", "followers.json")
53
+ @client.follows?('adamstac')
54
+ end
55
+
56
+ should "return the repos a user watches" do
57
+ stub_get("/repos/watched/pengwynn", "repos.json")
58
+ repos = @client.watched
59
+ repos.first.owner.should == 'jnunemaker'
60
+ repos.first.forks.should == 120
61
+ end
62
+
63
+ should "return the repos the authenticated user watched" do
64
+ stub_get("/repos/watched/pengwynn", "repos.json")
65
+ repos = @client.watched('pengwynn')
66
+ repos.first.owner.should == 'jnunemaker'
67
+ repos.first.forks.should == 120
68
+ end
69
+
70
+ should "update user info" do
71
+ stub_post("/user/show/pengwynn?login=pengwynn&token=OU812", "user.json")
72
+ user = @client.update_user(:location => "Dallas, TX")
73
+ user.location.should == 'Dallas, TX'
74
+ end
75
+
76
+ should "return emails for the authenticated user" do
77
+ stub_get("/user/emails?login=pengwynn&token=OU812", "emails.json")
78
+ emails = @client.emails
79
+ emails.size.should == 3
80
+ assert emails.include? "wynn@orrka.com"
81
+ end
82
+
83
+ should "add an email for the authenticated user" do
84
+ stub_post("/user/email/add?login=pengwynn&token=OU812", "emails.json")
85
+ emails = @client.add_email('wynn@orrka.com')
86
+ emails.size.should == 3
87
+ assert emails.include? "wynn@orrka.com"
88
+ end
89
+
90
+ should "remove an email for the authenticated user" do
91
+ stub_post("/user/email/remove?login=pengwynn&token=OU812", "emails.json")
92
+ emails = @client.remove_email('wynn@squeejee.com')
93
+ emails.size.should == 3
94
+ end
95
+
96
+ should "return keys for the authenticated user" do
97
+ stub_get("/user/keys?login=pengwynn&token=OU812", "keys.json")
98
+ keys = @client.keys
99
+ keys.size.should == 6
100
+ keys.last.title.should == 'wynn@pengwynn.local'
101
+ end
102
+
103
+ should "add an key for the authenticated user" do
104
+ stub_post("/user/key/add?login=pengwynn&token=OU812", "keys.json")
105
+ keys = @client.add_key('pengwynn', 'ssh-rsa 009aasd0kalsdfa-sd9a-sdf')
106
+ keys.size.should == 6
107
+ keys.last.title.should == 'wynn@pengwynn.local'
108
+ end
109
+
110
+ should "remove an key for the authenticated user" do
111
+ stub_post("/user/key/remove?login=pengwynn&token=OU812", "keys.json")
112
+ keys = @client.remove_key(1234)
113
+ keys.size.should == 6
114
+ end
115
+
116
+ should "open an issue" do
117
+ stub_post "/issues/open/pengwynn/linkedin", "open_issue.json"
118
+ issue = @client.open_issue({:username => "pengwynn", :repo => "linkedin"}, "testing", "Testing api")
119
+ issue.title.should == "testing"
120
+ issue.number.should == 2
121
+ end
122
+
123
+ should "close an issue" do
124
+ stub_post "/issues/close/pengwynn/linkedin/2", "close_issue.json"
125
+ issue = @client.close_issue({:username => "pengwynn", :repo => "linkedin"}, 2)
126
+ issue.title.should == "testing"
127
+ issue.number.should == 2
128
+ end
129
+
130
+ should "reopen an issue" do
131
+ stub_post "/issues/reopen/pengwynn/linkedin/2", "reopen_issue.json"
132
+ issue = @client.close_issue({:username => "pengwynn", :repo => "linkedin"}, 2)
133
+ issue.title.should == "testing"
134
+ issue.number.should == 2
135
+ end
136
+
137
+ should "edit an issue" do
138
+ stub_post "/issues/edit/pengwynn/linkedin/2", "open_issue.json"
139
+ issue = @client.update_issue("pengwynn/linkedin", 2, "testing", "Testing api")
140
+ issue.title.should == "testing"
141
+ issue.number.should == 2
142
+ end
143
+
144
+ should "list issue labels for a repo" do
145
+ stub_get "/issues/labels/pengwynn/linkedin", "labels.json"
146
+ labels = @client.labels("pengwynn/linkedin")
147
+ labels.first.should == 'oauth'
148
+ end
149
+
150
+ should "add a label to an issue" do
151
+ stub_post("/issues/label/add/pengwynn/linkedin/oauth/2", "labels.json")
152
+ labels = @client.add_label('pengwynn/linkedin', 2, 'oauth')
153
+ assert labels.include?("oauth")
154
+ end
155
+
156
+ should "remove a label from an issue" do
157
+ stub_post("/issues/label/remove/pengwynn/linkedin/oauth/2", "labels.json")
158
+ labels = @client.remove_label('pengwynn/linkedin', 2, 'oauth')
159
+ assert labels.is_a?(Array)
160
+ end
161
+
162
+ should "add a comment to an issue" do
163
+ stub_post("/issues/comment/pengwynn/linkedin/2", "comment.json")
164
+ comment = @client.add_comment('pengwynn/linkedin', 2, 'Nice catch!')
165
+ comment.comment.should == 'Nice catch!'
166
+ end
167
+
168
+ should "watch a repository" do
169
+ stub_post("/repos/watch/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
170
+ repo = @client.watch('pengwynn/linkedin')
171
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
172
+ end
173
+
174
+ should "unwatch a repository" do
175
+ stub_post("/repos/unwatch/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
176
+ repo = @client.unwatch('pengwynn/linkedin')
177
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
178
+ end
179
+
180
+ should "fork a repository" do
181
+ stub_post("/repos/fork/pengwynn/linkedin?login=pengwynn&token=OU812", "repo.json")
182
+ repo = @client.fork('pengwynn/linkedin')
183
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
184
+ end
185
+
186
+ should "create a repository" do
187
+ stub_post("/repos/create?login=pengwynn&token=OU812", "repo.json")
188
+ repo = @client.create(:name => 'linkedin', :description => 'Ruby wrapper for the LinkedIn API', :homepage => 'http://bit.ly/ruby-linkedin', :public => 1)
189
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
190
+ end
191
+
192
+ # should "return a delete_token when calling delete without supplying a delete_token" do
193
+ #
194
+ # end
195
+
196
+ should "set a repo's visibility to private" do
197
+ stub_post("/repos/set/private/linkedin?login=pengwynn&token=OU812", "repo.json")
198
+ repo = @client.set_private('linkedin')
199
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
200
+ end
201
+
202
+ should "set a repo's visibility to public" do
203
+ stub_post("/repos/set/public/linkedin?login=pengwynn&token=OU812", "repo.json")
204
+ repo = @client.set_public('linkedin')
205
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
206
+ end
207
+
208
+ should "return deploy keys for a repo" do
209
+ stub_get("/repos/keys/linkedin?login=pengwynn&token=OU812", "keys.json")
210
+ keys = @client.deploy_keys('linkedin')
211
+ keys.size.should == 6
212
+ keys.last.title.should == 'wynn@pengwynn.local'
213
+ end
214
+
215
+ should "add a deploy key for a repo" do
216
+ stub_post("/repos/key/linkedin/add?login=pengwynn&token=OU812", "keys.json")
217
+ keys = @client.add_deploy_key('pengwynn/linkedin', 'ssh-rsa 009aasd0kalsdfa-sd9a-sdf')
218
+ keys.size.should == 6
219
+ keys.last.title.should == 'wynn@pengwynn.local'
220
+ end
221
+
222
+ should "remove a deploy key for a repo" do
223
+ stub_post("/repos/key/linkedin/remove?login=pengwynn&token=OU812", "keys.json")
224
+ keys = @client.remove_deploy_key('linkedin', 1234)
225
+ keys.size.should == 6
226
+ end
227
+
228
+ should "add a collaborator to a repo" do
229
+ stub_post("/repos/collaborators/linkedin/add/adamstac?login=pengwynn&token=OU812", "collaborators.json")
230
+ collaborators = @client.add_collaborator("linkedin", "adamstac")
231
+ collaborators.first.should == 'pengwynn'
232
+ end
233
+
234
+ should "remove a collaborator from a repo" do
235
+ stub_post("/repos/collaborators/linkedin/remove/adamstac?login=pengwynn&token=OU812", "collaborators.json")
236
+ collaborators = @client.remove_collaborator("linkedin", "adamstac")
237
+ collaborators.last.should == 'adamstac'
238
+ end
239
+
240
+
241
+ end
242
+
243
+
244
+ context "when unauthenticated" do
245
+
246
+ should "search users" do
247
+ stub_get("/user/search/wynn", "search.json")
248
+ users = Octopussy.search_users("wynn")
249
+ users.first.username.should == 'pengwynn'
250
+ end
251
+
252
+ should "return user info" do
253
+ stub_get("/user/show/pengwynn", "user.json")
254
+ user = Octopussy.user("pengwynn")
255
+ user.login.should == 'pengwynn'
256
+ user.blog.should == 'http://wynnnetherland.com'
257
+ user.name.should == 'Wynn Netherland'
258
+ end
259
+
260
+ should "return followers for a user" do
261
+ stub_get("/user/show/pengwynn/followers", "followers.json")
262
+ followers = Octopussy.followers("pengwynn")
263
+ followers.size.should == 21
264
+ assert followers.include?("adamstac")
265
+ end
266
+
267
+ should "indicate if one user follows another" do
268
+ stub_get("/user/show/pengwynn/following", "followers.json")
269
+ assert Octopussy.follows?('pengwynn', 'adamstac')
270
+ end
271
+
272
+ should "return users a user follows" do
273
+ stub_get("/user/show/pengwynn/following", "followers.json")
274
+ followers = Octopussy.following("pengwynn")
275
+ followers.size.should == 21
276
+ assert followers.include?("adamstac")
277
+ end
278
+
279
+ should "return the repos a user watches" do
280
+ stub_get("/repos/watched/pengwynn", "repos.json")
281
+ repos = Octopussy.watched('pengwynn')
282
+ repos.first.owner.should == 'jnunemaker'
283
+ repos.first.forks.should == 120
284
+ end
285
+
286
+ should "search issues for a repo" do
287
+ stub_get("/issues/search/jnunemaker/twitter/open/httparty", "issues.json")
288
+ issues = Octopussy.search_issues({:username => 'jnunemaker', :repo => 'twitter'}, 'open', 'httparty')
289
+ issues.first.title.should == 'Crack error when creating friendship'
290
+ issues.first.votes.should == 2
291
+ end
292
+
293
+ should "list issues for a repo" do
294
+ stub_get("/issues/list/jnunemaker/twitter/open", "issues.json")
295
+ issues = Octopussy.issues({:username => 'jnunemaker', :repo => 'twitter'}, 'open')
296
+ issues.first.title.should == 'Crack error when creating friendship'
297
+ issues.first.votes.should == 2
298
+ end
299
+
300
+ should "return issue info" do
301
+ stub_get("/issues/show/jnunemaker/twitter/3", "issue.json")
302
+ issue = Octopussy.issue({:username => 'jnunemaker', :repo => 'twitter'}, 3)
303
+ issue.title.should == 'Crack error when creating friendship'
304
+ issue.votes.should == 2
305
+ end
306
+
307
+ # Repos
308
+
309
+ should "search repos" do
310
+ stub_get("/repos/search/compass", "repo_search.json")
311
+ repos = Octopussy.search_repos("compass")
312
+ repos.first.username.should == 'chriseppstein'
313
+ repos.first.language.should == 'Ruby'
314
+ end
315
+
316
+ should "return repo information" do
317
+ stub_get("/repos/show/pengwynn/linkedin", "repo.json")
318
+ repo = Octopussy.repo({:username => "pengwynn", :repo => "linkedin"})
319
+ repo.homepage.should == "http://bit.ly/ruby-linkedin"
320
+ end
321
+
322
+ should "list repos for a user" do
323
+ stub_get("/repos/show/pengwynn", "repos.json")
324
+ repos = Octopussy.list_repos('pengwynn')
325
+ repos.first.name.should == 'twitter'
326
+ repos.first.watchers.should == 609
327
+ end
328
+
329
+ should "list collaborators for a repo" do
330
+ stub_post("/repos/show/pengwynn/octopussy/collaborators", "collaborators.json")
331
+ users = Octopussy.collaborators({:username => "pengwynn", :repo => "octopussy"})
332
+ users.last.should == 'adamstac'
333
+ end
334
+
335
+ should "show the network for a repo" do
336
+ stub_get("/repos/show/pengwynn/linkedin/network", "network.json")
337
+ network = Octopussy.network({:username => 'pengwynn', :repo => "linkedin"})
338
+ network.last.owner.should == 'nfo'
339
+ end
340
+
341
+ should "show the language breakdown for a repo" do
342
+ stub_get("/repos/show/pengwynn/linkedin/languages", "languages.json")
343
+ languages = Octopussy.languages({:username => 'pengwynn', :repo => "linkedin"})
344
+ languages['Ruby'].should == 21515
345
+ end
346
+
347
+ should "list all the tags in a repo" do
348
+ stub_get("/repos/show/pengwynn/linkedin/tags", "tags.json")
349
+ tags = Octopussy.tags(:username => 'pengwynn', :repo => "linkedin")
350
+ assert tags.include?("v0.0.1")
351
+ end
352
+
353
+ should "list all the branches in a repo" do
354
+ stub_get("/repos/show/pengwynn/linkedin/branches", "branches.json")
355
+ branches = Octopussy.branches(:username => 'pengwynn', :repo => "linkedin")
356
+ assert branches.include?("integration")
357
+ end
358
+
359
+
360
+ # network
361
+ should "return network meta info for a repo" do
362
+ stub_get("http://github.com/schacon/simplegit/network_meta", "network_meta.json")
363
+ info = Octopussy.network_meta(:username => "schacon", :repo => "simplegit")
364
+ info.users.first.name.should == 'schacon'
365
+ info.users.first.repo.should == 'simplegit'
366
+ end
367
+
368
+ should "return first 100 commits by branch" do
369
+ stub_get("http://github.com/schacon/simplegit/network_data_chunk?nethash=fa8fe264b926cdebaab36420b6501bd74402a6ff", "network_data.json")
370
+ info = Octopussy.network_data({:username => "schacon", :repo => "simplegit"}, "fa8fe264b926cdebaab36420b6501bd74402a6ff")
371
+ assert info.is_a?(Array)
372
+ end
373
+
374
+ # trees
375
+ should "return contents of a tree by tree SHA" do
376
+ stub_get("http://github.com/api/v2/json/tree/show/defunkt/facebox/a47803c9ba26213ff194f042ab686a7749b17476", "trees.json")
377
+ trees = Octopussy.tree({:username => "defunkt", :repo => "facebox"}, "a47803c9ba26213ff194f042ab686a7749b17476")
378
+ trees.first.name.should == '.gitignore'
379
+ trees.first.sha.should == 'e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf'
380
+ end
381
+
382
+ should "return data about a blob by tree SHA and path" do
383
+ stub_get("http://github.com/api/v2/json/blob/show/defunkt/facebox/d4fc2d5e810d9b4bc1ce67702603080e3086a4ed/README.txt", "blob.json")
384
+ blob = Octopussy.blob({:username => "defunkt", :repo => "facebox"}, "d4fc2d5e810d9b4bc1ce67702603080e3086a4ed", "README.txt")
385
+ blob.name.should == 'README.txt'
386
+ blob.sha.should == 'd4fc2d5e810d9b4bc1ce67702603080e3086a4ed'
387
+ end
388
+
389
+ should "return the contents of a blob with the blob's SHA" do
390
+ stub_get("http://github.com/api/v2/yaml/blob/show/defunkt/facebox/4bf7a39e8c4ec54f8b4cd594a3616d69004aba69", "raw_git_data.json")
391
+ raw_text = Octopussy.raw({:username => "defunkt", :repo => "facebox"}, "4bf7a39e8c4ec54f8b4cd594a3616d69004aba69")
392
+ assert raw_text.include?("cd13d9a61288dceb0a7aa73b55ed2fd019f4f1f7")
393
+ end
394
+
395
+ end
396
+
397
+ end