hybridgroup-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.
- data/.document +4 -0
- data/.gemtest +0 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.markdown +73 -0
- data/Rakefile +8 -0
- data/changelog.markdown +42 -0
- data/lib/faraday/response/raise_error.rb +33 -0
- data/lib/octokit/client/authentication.rb +23 -0
- data/lib/octokit/client/commits.rb +16 -0
- data/lib/octokit/client/connection.rb +34 -0
- data/lib/octokit/client/issues.rb +60 -0
- data/lib/octokit/client/network.rb +15 -0
- data/lib/octokit/client/objects.rb +33 -0
- data/lib/octokit/client/organizations.rb +90 -0
- data/lib/octokit/client/pulls.rb +25 -0
- data/lib/octokit/client/repositories.rb +138 -0
- data/lib/octokit/client/request.rb +41 -0
- data/lib/octokit/client/timelines.rb +22 -0
- data/lib/octokit/client/users.rb +75 -0
- data/lib/octokit/client.rb +40 -0
- data/lib/octokit/configuration.rb +61 -0
- data/lib/octokit/repository.rb +39 -0
- data/lib/octokit/version.rb +3 -0
- data/lib/octokit.rb +53 -0
- data/octokit.gemspec +33 -0
- data/spec/faraday/response_spec.rb +34 -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 +64 -0
- data/spec/octokit/client/commits_spec.rb +32 -0
- data/spec/octokit/client/issues_spec.rb +154 -0
- data/spec/octokit/client/network_spec.rb +32 -0
- data/spec/octokit/client/objects_spec.rb +81 -0
- data/spec/octokit/client/organizations_spec.rb +234 -0
- data/spec/octokit/client/pulls_spec.rb +44 -0
- data/spec/octokit/client/repositories_spec.rb +331 -0
- data/spec/octokit/client/timelines_spec.rb +42 -0
- data/spec/octokit/client/users_spec.rb +274 -0
- data/spec/octokit/client_spec.rb +12 -0
- data/spec/octokit_spec.rb +15 -0
- data/spec/repository_spec.rb +54 -0
- metadata +403 -0
@@ -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
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Octokit::Client do
|
4
|
+
|
5
|
+
it "should connect using the endpoint configuration" do
|
6
|
+
client = Octokit::Client.new
|
7
|
+
endpoint = URI.parse(client.endpoint)
|
8
|
+
connection = client.send(:connection).build_url(nil).to_s
|
9
|
+
connection.should == endpoint.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe Octokit::Repository do
|
5
|
+
context "when passed a string containg a slash" do
|
6
|
+
before do
|
7
|
+
@repository = Octokit::Repository.new("sferik/octokit")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should set the repository name and username" do
|
11
|
+
@repository.name.should == "octokit"
|
12
|
+
@repository.username.should == "sferik"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should respond to repo and user" do
|
16
|
+
@repository.repo.should == "octokit"
|
17
|
+
@repository.user.should == "sferik"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should render slug as string" do
|
21
|
+
@repository.slug.should == "sferik/octokit"
|
22
|
+
@repository.to_s.should == @repository.slug
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should render url as string" do
|
26
|
+
@repository.url.should == 'https://github.com/sferik/octokit'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when passed a hash" do
|
32
|
+
it "should set the repository name and username" do
|
33
|
+
repository = Octokit::Repository.new({:username => 'sferik', :name => 'octokit'})
|
34
|
+
repository.name.should == "octokit"
|
35
|
+
repository.username.should == "sferik"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when passed a Repo" do
|
40
|
+
it "should set the repository name and username" do
|
41
|
+
repository = Octokit::Repository.new(Octokit::Repository.new('sferik/octokit'))
|
42
|
+
repository.name.should == "octokit"
|
43
|
+
repository.username.should == "sferik"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when given a URL" do
|
48
|
+
it "should set the repository name and username" do
|
49
|
+
repository = Octokit::Repository.from_url("https://github.com/sferik/octokit")
|
50
|
+
repository.name.should == "octokit"
|
51
|
+
repository.username.should == "sferik"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|