octokit 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +3 -0
- data/Rakefile +3 -10
- data/changelog.markdown +3 -0
- data/lib/octokit/client.rb +1 -2
- data/lib/octokit/client/authentication.rb +4 -0
- data/lib/octokit/client/commits.rb +1 -1
- data/lib/octokit/client/connection.rb +4 -2
- data/lib/octokit/client/issues.rb +8 -8
- data/lib/octokit/client/network.rb +3 -3
- data/lib/octokit/client/objects.rb +1 -1
- data/lib/octokit/client/organizations.rb +3 -2
- data/lib/octokit/client/pulls.rb +9 -3
- data/lib/octokit/client/repositories.rb +23 -10
- data/lib/octokit/client/request.rb +10 -10
- data/lib/octokit/client/timelines.rb +11 -9
- data/lib/octokit/configuration.rb +21 -19
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +4 -6
- data/spec/faraday/response_spec.rb +33 -0
- data/spec/fixtures/blob.json +1 -0
- data/spec/fixtures/blob_metadata.json +1 -0
- data/spec/fixtures/blobs.json +1 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/collaborators.json +1 -0
- data/spec/fixtures/comment.json +1 -0
- data/spec/fixtures/comments.json +1 -0
- data/spec/fixtures/commit.json +1 -0
- data/spec/fixtures/commits.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/delete_token.json +1 -0
- data/spec/fixtures/emails.json +1 -0
- data/spec/fixtures/followers.json +1 -0
- data/spec/fixtures/following.json +1 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/network.json +1 -0
- data/spec/fixtures/network_data.json +1 -0
- data/spec/fixtures/network_meta.json +1 -0
- data/spec/fixtures/organization.json +1 -0
- data/spec/fixtures/organizations.json +1 -0
- data/spec/fixtures/public_keys.json +1 -0
- data/spec/fixtures/pull.json +1 -0
- data/spec/fixtures/pulls.json +1 -0
- data/spec/fixtures/raw.txt +7 -0
- data/spec/fixtures/repositories.json +1 -0
- data/spec/fixtures/repository.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team.json +1 -0
- data/spec/fixtures/teams.json +1 -0
- data/spec/fixtures/timeline.json +1237 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/tree_metadata.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/watchers.json +1 -0
- data/spec/helper.rb +66 -0
- data/spec/octokit/client/commits_spec.rb +31 -0
- data/spec/octokit/client/issues_spec.rb +155 -0
- data/spec/octokit/client/network_spec.rb +31 -0
- data/spec/octokit/client/objects_spec.rb +75 -0
- data/spec/octokit/client/organizations_spec.rb +233 -0
- data/spec/octokit/client/pulls_spec.rb +43 -0
- data/spec/octokit/client/repositories_spec.rb +330 -0
- data/spec/octokit/client/timelines_spec.rb +41 -0
- data/spec/octokit/client/users_spec.rb +273 -0
- data/spec/octokit/client_spec.rb +12 -0
- data/spec/octokit_spec.rb +14 -0
- data/spec/repository_spec.rb +53 -0
- data/test/helper.rb +2 -0
- data/test/octokit_test.rb +14 -2
- metadata +147 -89
- data/lib/octokit/event.rb +0 -76
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe Octokit::Client::Pulls do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".create_pull_request" do
|
10
|
+
|
11
|
+
it "should create a pull request" do
|
12
|
+
stub_post("pulls/sferik/rails_admin").
|
13
|
+
with(:pull => {:base => "master", :head => "pengwynn:master", :title => "Title", :body => "Body"}).
|
14
|
+
to_return(:body => fixture("pulls.json"))
|
15
|
+
issues = @client.create_pull_request("sferik/rails_admin", "master", "pengwynn:master", "Title", "Body")
|
16
|
+
issues.first.number.should == 251
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".pull_requests" do
|
22
|
+
|
23
|
+
it "should return all pull requests" do
|
24
|
+
stub_get("pulls/sferik/rails_admin/open").
|
25
|
+
to_return(:body => fixture("pulls.json"))
|
26
|
+
pulls = @client.pulls("sferik/rails_admin")
|
27
|
+
pulls.first.number.should == 251
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".pull_request" do
|
33
|
+
|
34
|
+
it "should return a pull request" do
|
35
|
+
stub_get("pulls/sferik/rails_admin/251").
|
36
|
+
to_return(:body => fixture("pull.json"))
|
37
|
+
pull = @client.pull("sferik/rails_admin", 251)
|
38
|
+
pull.number.should == 251
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,330 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe Octokit::Client::Repositories do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".search_user" do
|
10
|
+
|
11
|
+
it "should return matching repositories" do
|
12
|
+
stub_get("repos/search/One40Proof").
|
13
|
+
to_return(:body => fixture("repositories.json"))
|
14
|
+
repositories = @client.search_repositories("One40Proof")
|
15
|
+
repositories.first.name.should == "One40Proof"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".repository" do
|
21
|
+
|
22
|
+
it "should return the matching repository" do
|
23
|
+
stub_get("repos/show/sferik/rails_admin").
|
24
|
+
to_return(:body => fixture("repository.json"))
|
25
|
+
repository = @client.repository("sferik/rails_admin")
|
26
|
+
repository.name.should == "rails_admin"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".update_repository" do
|
32
|
+
|
33
|
+
it "should update the matching repository" do
|
34
|
+
description = "RailsAdmin is a Rails 3 engine that provides an easy-to-use interface for managing your data"
|
35
|
+
stub_post("repos/show/sferik/rails_admin").
|
36
|
+
with(:values => {:description => description}).
|
37
|
+
to_return(:body => fixture("repository.json"))
|
38
|
+
repository = @client.update_repository("sferik/rails_admin", :description => description)
|
39
|
+
repository.description.should == description
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".repositories" do
|
45
|
+
|
46
|
+
context "with a username passed" do
|
47
|
+
|
48
|
+
it "should return user's repositories" do
|
49
|
+
stub_get("repos/show/sferik").
|
50
|
+
to_return(:body => fixture("repositories.json"))
|
51
|
+
repositories = @client.repositories("sferik")
|
52
|
+
repositories.first.name.should == "One40Proof"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
context "without a username passed" do
|
58
|
+
|
59
|
+
it "should return authenticated user's repositories" do
|
60
|
+
stub_get("repos/show/sferik").
|
61
|
+
to_return(:body => fixture("repositories.json"))
|
62
|
+
repositories = @client.repositories
|
63
|
+
repositories.first.name.should == "One40Proof"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".watch!" do
|
71
|
+
|
72
|
+
it "should watch a repository" do
|
73
|
+
stub_post("repos/watch/sferik/rails_admin").
|
74
|
+
to_return(:body => fixture("repository.json"))
|
75
|
+
repository = @client.watch!("sferik/rails_admin")
|
76
|
+
repository.name.should == "rails_admin"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe ".unwatch!" do
|
82
|
+
|
83
|
+
it "should unwatch a repository" do
|
84
|
+
stub_post("repos/unwatch/sferik/rails_admin").
|
85
|
+
to_return(:body => fixture("repository.json"))
|
86
|
+
repository = @client.unwatch!("sferik/rails_admin")
|
87
|
+
repository.name.should == "rails_admin"
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe ".fork!" do
|
93
|
+
|
94
|
+
it "should fork a repository" do
|
95
|
+
stub_post("repos/fork/sferik/rails_admin").
|
96
|
+
to_return(:body => fixture("repository.json"))
|
97
|
+
repository = @client.fork!("sferik/rails_admin")
|
98
|
+
repository.name.should == "rails_admin"
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe ".create_repository" do
|
104
|
+
|
105
|
+
it "should create a repository" do
|
106
|
+
stub_post("repos/create").
|
107
|
+
with(:name => "rails_admin").
|
108
|
+
to_return(:body => fixture("repository.json"))
|
109
|
+
repository = @client.create_repository("rails_admin")
|
110
|
+
repository.name.should == "rails_admin"
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe ".delete_repository" do
|
116
|
+
|
117
|
+
it "should return a delete token" do
|
118
|
+
stub_post("repos/delete/sferik/rails_admin").
|
119
|
+
to_return(:body => fixture("delete_token.json"))
|
120
|
+
delete_token = @client.delete_repository("sferik/rails_admin")
|
121
|
+
delete_token.should == "uhihwkkkzu"
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
describe ".delete_repository!" do
|
127
|
+
|
128
|
+
it "should delete a repository" do
|
129
|
+
stub_post("repos/delete/sferik/rails_admin").
|
130
|
+
to_return(:body => fixture("repository.json"))
|
131
|
+
repository = @client.delete_repository!("sferik/rails_admin")
|
132
|
+
repository.name.should == "rails_admin"
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe ".set_private!" do
|
138
|
+
|
139
|
+
it "should set a repository private" do
|
140
|
+
stub_post("repos/set/private/sferik/rails_admin").
|
141
|
+
to_return(:body => fixture("repository.json"))
|
142
|
+
repository = @client.set_private!("sferik/rails_admin")
|
143
|
+
repository.name.should == "rails_admin"
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
describe ".set_public!" do
|
149
|
+
|
150
|
+
it "should set a repository public" do
|
151
|
+
stub_post("repos/set/public/sferik/rails_admin").
|
152
|
+
to_return(:body => fixture("repository.json"))
|
153
|
+
repository = @client.set_public!("sferik/rails_admin")
|
154
|
+
repository.name.should == "rails_admin"
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
describe ".deploy_keys" do
|
160
|
+
|
161
|
+
it "should return a repository's deploy keys" do
|
162
|
+
stub_get("repos/keys/sferik/rails_admin").
|
163
|
+
to_return(:body => fixture("public_keys.json"))
|
164
|
+
public_keys = @client.deploy_keys("sferik/rails_admin")
|
165
|
+
public_keys.first.id.should == 103205
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
describe ".add_deploy_key" do
|
171
|
+
|
172
|
+
it "should add a repository deploy keys" do
|
173
|
+
stub_post("repos/key/sferik/rails_admin/add").
|
174
|
+
with(:title => "Moss", :key => "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host").
|
175
|
+
to_return(:body => fixture("public_keys.json"))
|
176
|
+
public_keys = @client.add_deploy_key("sferik/rails_admin", "Moss", "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host")
|
177
|
+
public_keys.first.id.should == 103205
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
describe ".remove_deploy_key" do
|
183
|
+
|
184
|
+
it "should remove a repository deploy keys" do
|
185
|
+
stub_post("repos/key/sferik/rails_admin/remove").
|
186
|
+
with(:id => 103205).
|
187
|
+
to_return(:body => fixture("public_keys.json"))
|
188
|
+
public_keys = @client.remove_deploy_key("sferik/rails_admin", 103205)
|
189
|
+
public_keys.first.id.should == 103205
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
describe ".collaborators" do
|
195
|
+
|
196
|
+
it "should return a repository's collaborators" do
|
197
|
+
stub_get("repos/show/sferik/rails_admin/collaborators").
|
198
|
+
to_return(:body => fixture("collaborators.json"))
|
199
|
+
collaborators = @client.collaborators("sferik/rails_admin")
|
200
|
+
collaborators.first.should == "sferik"
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
describe ".add_collaborator" do
|
206
|
+
|
207
|
+
it "should add a repository collaborators" do
|
208
|
+
stub_post("repos/collaborators/sferik/rails_admin/add/sferik").
|
209
|
+
to_return(:body => fixture("collaborators.json"))
|
210
|
+
collaborators = @client.add_collaborator("sferik/rails_admin", "sferik")
|
211
|
+
collaborators.first.should == "sferik"
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
describe ".remove_collaborator" do
|
217
|
+
|
218
|
+
it "should remove a repository collaborators" do
|
219
|
+
stub_post("repos/collaborators/sferik/rails_admin/remove/sferik").
|
220
|
+
to_return(:body => fixture("collaborators.json"))
|
221
|
+
collaborators = @client.remove_collaborator("sferik/rails_admin", "sferik")
|
222
|
+
collaborators.first.should == "sferik"
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
describe ".pushable" do
|
228
|
+
|
229
|
+
it "should return all pushable repositories" do
|
230
|
+
stub_get("repos/pushable").
|
231
|
+
to_return(:body => fixture("repositories.json"))
|
232
|
+
repositories = @client.pushable
|
233
|
+
repositories.first.name.should == "One40Proof"
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
describe ".repository_teams" do
|
239
|
+
|
240
|
+
it "should return all repository teams" do
|
241
|
+
stub_get("repos/show/codeforamerica/open311/teams").
|
242
|
+
to_return(:body => fixture("teams.json"))
|
243
|
+
teams = @client.repository_teams("codeforamerica/open311")
|
244
|
+
teams.first.name.should == "Fellows"
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
describe ".contributors" do
|
250
|
+
|
251
|
+
context "with anonymous users" do
|
252
|
+
|
253
|
+
it "should return all repository contributors" do
|
254
|
+
stub_get("repos/show/sferik/rails_admin/contributors/anon").
|
255
|
+
to_return(:body => fixture("contributors.json"))
|
256
|
+
contributors = @client.contributors("sferik/rails_admin", true)
|
257
|
+
contributors.first.name.should == "Erik Michaels-Ober"
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
|
262
|
+
context "without anonymous users" do
|
263
|
+
|
264
|
+
it "should return all repository contributors" do
|
265
|
+
stub_get("repos/show/sferik/rails_admin/contributors").
|
266
|
+
to_return(:body => fixture("contributors.json"))
|
267
|
+
contributors = @client.contributors("sferik/rails_admin")
|
268
|
+
contributors.first.name.should == "Erik Michaels-Ober"
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
describe ".watchers" do
|
276
|
+
|
277
|
+
it "should return all repository watchers" do
|
278
|
+
stub_get("repos/show/sferik/rails_admin/watchers").
|
279
|
+
to_return(:body => fixture("watchers.json"))
|
280
|
+
watchers = @client.watchers("sferik/rails_admin")
|
281
|
+
watchers.first.should == "sferik"
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
describe ".network" do
|
287
|
+
|
288
|
+
it "should return a repository's network" do
|
289
|
+
stub_get("repos/show/sferik/rails_admin/network").
|
290
|
+
to_return(:body => fixture("network.json"))
|
291
|
+
network = @client.network("sferik/rails_admin")
|
292
|
+
network.first.owner.should == "sferik"
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
describe ".languages" do
|
298
|
+
|
299
|
+
it "should return a repository's languages" do
|
300
|
+
stub_get("repos/show/sferik/rails_admin/languages").
|
301
|
+
to_return(:body => fixture("languages.json"))
|
302
|
+
languages = @client.languages("sferik/rails_admin")
|
303
|
+
languages.first.first.should == "Ruby"
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
describe ".tags" do
|
309
|
+
|
310
|
+
it "should return a repository's tags" do
|
311
|
+
stub_get("repos/show/pengwynn/octokit/tags").
|
312
|
+
to_return(:body => fixture("tags.json"))
|
313
|
+
tags = @client.tags("pengwynn/octokit")
|
314
|
+
tags.first.first.should == "v0.1.0"
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
describe ".branches" do
|
320
|
+
|
321
|
+
it "should return a repository's branches" do
|
322
|
+
stub_get("repos/show/pengwynn/octokit/branches").
|
323
|
+
to_return(:body => fixture("branches.json"))
|
324
|
+
branches = @client.branches("pengwynn/octokit")
|
325
|
+
branches.first.first.should == "rspec"
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe Octokit::Client::Users do
|
4
|
+
|
5
|
+
describe ".timeline" do
|
6
|
+
|
7
|
+
it "should return the public timeline" do
|
8
|
+
client = Octokit::Client.new
|
9
|
+
stub_get("https://github.com/timeline.json").
|
10
|
+
to_return(:body => fixture("timeline.json"))
|
11
|
+
events = client.timeline
|
12
|
+
events.first.repository.name.should == "homebrew"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".user_timeline" do
|
18
|
+
|
19
|
+
it "should return a user timeline" do
|
20
|
+
client = Octokit::Client.new
|
21
|
+
stub_get("https://github.com/sferik.json").
|
22
|
+
to_return(:body => fixture("timeline.json"))
|
23
|
+
events = client.user_timeline("sferik")
|
24
|
+
events.first.repository.name.should == "homebrew"
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when authenticated" do
|
28
|
+
|
29
|
+
it "should return a user timeline" do
|
30
|
+
client = Octokit::Client.new(:login => "sferik", :token => "OU812")
|
31
|
+
stub_get("https://github.com/sferik.private.json?token=OU812").
|
32
|
+
to_return(:body => fixture("timeline.json"))
|
33
|
+
events = client.user_timeline("sferik")
|
34
|
+
events.first.repository.name.should == "homebrew"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe Octokit::Client::Users do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Octokit::Client.new(:login => 'sferik')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".search_users" do
|
10
|
+
|
11
|
+
context "with a username passed" do
|
12
|
+
|
13
|
+
it "should return matching username" do
|
14
|
+
stub_get("user/search/sferik").
|
15
|
+
to_return(:body => fixture("users.json"))
|
16
|
+
users = @client.search_users("sferik")
|
17
|
+
users.first.username.should == "sferik"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with an email address passed" do
|
23
|
+
|
24
|
+
it "should return matching email address" do
|
25
|
+
stub_get("user/email/sferik@gmail.com").
|
26
|
+
to_return(:body => fixture("user.json"))
|
27
|
+
user = @client.search_users("sferik@gmail.com")
|
28
|
+
user.login.should == "sferik"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".user" do
|
36
|
+
|
37
|
+
context "with a username passed" do
|
38
|
+
|
39
|
+
it "should return the user" do
|
40
|
+
stub_get("user/show/sferik").
|
41
|
+
to_return(:body => fixture("user.json"))
|
42
|
+
user = @client.user("sferik")
|
43
|
+
user.login.should == "sferik"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "without a username passed" do
|
49
|
+
|
50
|
+
it "should return the authenticated user" do
|
51
|
+
stub_get("user/show").
|
52
|
+
to_return(:body => fixture("user.json"))
|
53
|
+
user = @client.user
|
54
|
+
user.login.should == "sferik"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe ".update_user" do
|
62
|
+
|
63
|
+
context "with a location passed" do
|
64
|
+
|
65
|
+
it "should update the user's location" do
|
66
|
+
stub_post("user/show/sferik").
|
67
|
+
with(:values => {:location => "San Francisco"}).
|
68
|
+
to_return(:body => fixture("user.json"))
|
69
|
+
user = @client.update_user(:location => "San Francisco")
|
70
|
+
user.login.should == "sferik"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ".followers" do
|
78
|
+
|
79
|
+
context "with a username passed" do
|
80
|
+
|
81
|
+
it "should return the user's followers" do
|
82
|
+
stub_get("user/show/sferik/followers").
|
83
|
+
to_return(:body => fixture("followers.json"))
|
84
|
+
users = @client.followers("sferik")
|
85
|
+
users.first.should == "puls"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context "without a username passed" do
|
91
|
+
|
92
|
+
it "should return the user's followers" do
|
93
|
+
stub_get("user/show/sferik/followers").
|
94
|
+
to_return(:body => fixture("followers.json"))
|
95
|
+
users = @client.followers
|
96
|
+
users.first.should == "puls"
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe ".following" do
|
104
|
+
|
105
|
+
context "with a username passed" do
|
106
|
+
|
107
|
+
it "should return the user's following" do
|
108
|
+
stub_get("user/show/sferik/following").
|
109
|
+
to_return(:body => fixture("following.json"))
|
110
|
+
users = @client.following("sferik")
|
111
|
+
users.first.should == "rails"
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
context "without a username passed" do
|
117
|
+
|
118
|
+
it "should return the user's following" do
|
119
|
+
stub_get("user/show/sferik/following").
|
120
|
+
to_return(:body => fixture("following.json"))
|
121
|
+
users = @client.following
|
122
|
+
users.first.should == "rails"
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe ".follows?" do
|
130
|
+
|
131
|
+
context "with one user following another" do
|
132
|
+
|
133
|
+
it "should return true" do
|
134
|
+
stub_get("user/show/sferik/following").
|
135
|
+
to_return(:body => fixture("following.json"))
|
136
|
+
follows = @client.follows?("sferik", "pengwynn")
|
137
|
+
follows.should be_true
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
context "with one user not following another" do
|
143
|
+
|
144
|
+
it "should return false" do
|
145
|
+
stub_get("user/show/sferik/following").
|
146
|
+
to_return(:body => fixture("following.json"))
|
147
|
+
follows = @client.follows?("sferik", "dogbrainz")
|
148
|
+
follows.should be_false
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
describe ".follow!" do
|
156
|
+
|
157
|
+
it "should follow a user" do
|
158
|
+
stub_post("user/follow/dianakimball").
|
159
|
+
to_return(:body => fixture("following.json"))
|
160
|
+
following = @client.follow!("dianakimball")
|
161
|
+
following.should include("dianakimball")
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
describe ".unfollow!" do
|
167
|
+
|
168
|
+
it "should unfollow a user" do
|
169
|
+
stub_post("user/unfollow/dogbrainz").
|
170
|
+
to_return(:body => fixture("following.json"))
|
171
|
+
following = @client.unfollow!("dogbrainz")
|
172
|
+
following.should_not include("dogbrainz")
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
describe ".watched" do
|
178
|
+
|
179
|
+
context "with a username passed" do
|
180
|
+
|
181
|
+
it "should return watched repositories" do
|
182
|
+
stub_get("repos/watched/sferik").
|
183
|
+
to_return(:body => fixture("repositories.json"))
|
184
|
+
repositories = @client.watched("sferik")
|
185
|
+
repositories.first.name.should == "One40Proof"
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
context "without a username passed" do
|
191
|
+
|
192
|
+
it "should return watched repositories" do
|
193
|
+
stub_get("repos/watched/sferik").
|
194
|
+
to_return(:body => fixture("repositories.json"))
|
195
|
+
repositories = @client.watched
|
196
|
+
repositories.first.name.should == "One40Proof"
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
describe ".keys" do
|
204
|
+
|
205
|
+
it "should return public keys" do
|
206
|
+
stub_get("user/keys").
|
207
|
+
to_return(:body => fixture("public_keys.json"))
|
208
|
+
public_keys = @client.keys
|
209
|
+
public_keys.first.id.should == 103205
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
describe ".add_key" do
|
215
|
+
|
216
|
+
it "should add a public key" do
|
217
|
+
stub_post("user/key/add").
|
218
|
+
with(:title => "Moss", :key => "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host").
|
219
|
+
to_return(:body => fixture("public_keys.json"))
|
220
|
+
public_keys = @client.add_key("Moss", "ssh-dss AAAAB3NzaC1kc3MAAACBAJz7HanBa18ad1YsdFzHO5Wy1/WgXd4BV+czbKq7q23jungbfjN3eo2a0SVdxux8GG+RZ9ia90VD/X+PE4s3LV60oXZ7PDAuyPO1CTF0TaDoKf9mPaHcPa6agMJVocMsgBgwviWT1Q9VgN1SccDsYVDtxkIAwuw25YeHZlG6myx1AAAAFQCgW+OvXWUdUJPBGkRJ8ML7uf0VHQAAAIAlP5G96tTss0SKYVSCJCyocn9cyGQdNjxah4/aYuYFTbLI1rxk7sr/AkZfJNIoF2UFyO5STbbratykIQGUPdUBg1a2t72bu31x+4ZYJMngNsG/AkZ2oqLiH6dJKHD7PFx2oSPalogwsUV7iSMIZIYaPa03A9763iFsN0qJjaed+gAAAIBxz3Prxdzt/os4XGXSMNoWcS03AFC/05NOkoDMrXxQnTTpp1wrOgyRqEnKz15qC5dWk1ynzK+LJXHDZGA8lXPfCjHpJO3zrlZ/ivvLhgPdDpt13MAhIJFH06hTal0woxbk/fIdY71P3kbgXC0Ppx/0S7BC+VxqRCA4/wcM+BoDbA== host")
|
221
|
+
public_keys.first.id.should == 103205
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
describe ".remove_key" do
|
227
|
+
|
228
|
+
it "should remove a public key" do
|
229
|
+
stub_post("user/key/remove").
|
230
|
+
with(:id => 103205).
|
231
|
+
to_return(:body => fixture("public_keys.json"))
|
232
|
+
public_keys = @client.remove_key(103205)
|
233
|
+
public_keys.first.id.should == 103205
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
describe ".emails" do
|
239
|
+
|
240
|
+
it "should return email addresses" do
|
241
|
+
stub_get("user/emails").
|
242
|
+
to_return(:body => fixture("emails.json"))
|
243
|
+
emails = @client.emails
|
244
|
+
emails.first.should == "sferik@gmail.com"
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
describe ".add_email" do
|
250
|
+
|
251
|
+
it "should add an email address" do
|
252
|
+
stub_post("user/email/add").
|
253
|
+
with(:email => "sferik@gmail.com").
|
254
|
+
to_return(:body => fixture("emails.json"))
|
255
|
+
emails = @client.add_email("sferik@gmail.com")
|
256
|
+
emails.first.should == "sferik@gmail.com"
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
describe ".remove_key" do
|
262
|
+
|
263
|
+
it "should remove an email address" do
|
264
|
+
stub_post("user/email/remove").
|
265
|
+
with(:email => "sferik@gmail.com").
|
266
|
+
to_return(:body => fixture("emails.json"))
|
267
|
+
emails = @client.remove_email("sferik@gmail.com")
|
268
|
+
emails.first.should == "sferik@gmail.com"
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|