xn-octokit 0.6.1

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