octokit 0.6.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.rspec +1 -2
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +1 -0
  4. data/Gemfile +1 -1
  5. data/README.md +41 -28
  6. data/Rakefile +11 -0
  7. data/lib/faraday/response/raise_octokit_error.rb +4 -2
  8. data/lib/octokit/client.rb +2 -0
  9. data/lib/octokit/client/commits.rb +12 -0
  10. data/lib/octokit/client/events.rb +26 -0
  11. data/lib/octokit/client/issues.rb +35 -7
  12. data/lib/octokit/client/labels.rb +5 -5
  13. data/lib/octokit/client/objects.rb +10 -6
  14. data/lib/octokit/client/organizations.rb +25 -21
  15. data/lib/octokit/client/pub_sub_hubbub/service_hooks.rb +2 -2
  16. data/lib/octokit/client/pulls.rb +4 -4
  17. data/lib/octokit/client/repositories.rb +18 -18
  18. data/lib/octokit/client/users.rb +19 -14
  19. data/lib/octokit/configuration.rb +14 -11
  20. data/lib/octokit/connection.rb +3 -3
  21. data/lib/octokit/request.rb +17 -1
  22. data/lib/octokit/version.rb +1 -1
  23. data/octokit.gemspec +13 -12
  24. data/spec/fixtures/v3/blob.json +7 -0
  25. data/spec/fixtures/v3/commit_comment.json +19 -0
  26. data/spec/fixtures/v3/commit_comments.json +78 -0
  27. data/spec/fixtures/v3/emails.json +4 -0
  28. data/spec/fixtures/v3/followers.json +212 -0
  29. data/spec/fixtures/v3/following.json +209 -0
  30. data/spec/fixtures/v3/issue.json +37 -0
  31. data/spec/fixtures/v3/issue_closed.json +37 -0
  32. data/spec/fixtures/v3/issue_event.json +44 -0
  33. data/spec/fixtures/v3/issue_events.json +72 -0
  34. data/spec/fixtures/v3/list_commit_comments.json +572 -0
  35. data/spec/fixtures/v3/organization-repositories.json +4292 -0
  36. data/spec/fixtures/v3/organization-repository.json +42 -0
  37. data/spec/fixtures/v3/organization.json +18 -0
  38. data/spec/fixtures/v3/organization_members.json +576 -0
  39. data/spec/fixtures/v3/organization_team_members.json +16 -0
  40. data/spec/fixtures/v3/organization_team_repos.json +62 -0
  41. data/spec/fixtures/v3/organizations.json +44 -0
  42. data/spec/fixtures/v3/public_events.json +1110 -0
  43. data/spec/fixtures/v3/pull_created.json +138 -0
  44. data/spec/fixtures/v3/pull_request.json +138 -0
  45. data/spec/fixtures/v3/pull_requests.json +187 -0
  46. data/spec/fixtures/v3/repo_events.json +1668 -0
  47. data/spec/fixtures/v3/repo_issues_events.json +134 -0
  48. data/spec/fixtures/v3/team.json +8 -0
  49. data/spec/fixtures/v3/teams.json +4 -4
  50. data/spec/fixtures/v3/tree.json +112 -0
  51. data/spec/fixtures/v3/watched.json +1022 -0
  52. data/spec/helper.rb +3 -3
  53. data/spec/octokit/client/commits_spec.rb +33 -0
  54. data/spec/octokit/client/events_spec.rb +27 -0
  55. data/spec/octokit/client/issue_events_spec.rb +30 -0
  56. data/spec/octokit/client/issues_spec.rb +31 -20
  57. data/spec/octokit/client/labels_spec.rb +1 -1
  58. data/spec/octokit/client/objects_spec.rb +9 -8
  59. data/spec/octokit/client/organizations_spec.rb +56 -67
  60. data/spec/octokit/client/pulls_spec.rb +19 -18
  61. data/spec/octokit/client/repositories_spec.rb +24 -38
  62. data/spec/octokit/client/users_spec.rb +50 -51
  63. data/spec/octokit/client_spec.rb +16 -0
  64. metadata +111 -81
  65. data/puppeteer.jpg +0 -0
  66. data/spec/fixtures/v2/blob.json +0 -1
  67. data/spec/fixtures/v2/comment.json +0 -1
  68. data/spec/fixtures/v2/comments.json +0 -1
  69. data/spec/fixtures/v2/delete_failure.json +0 -1
  70. data/spec/fixtures/v2/delete_token.json +0 -1
  71. data/spec/fixtures/v2/emails.json +0 -1
  72. data/spec/fixtures/v2/followers.json +0 -1
  73. data/spec/fixtures/v2/following.json +0 -1
  74. data/spec/fixtures/v2/issue.json +0 -1
  75. data/spec/fixtures/v2/labels.json +0 -1
  76. data/spec/fixtures/v2/organization.json +0 -1
  77. data/spec/fixtures/v2/organizations.json +0 -1
  78. data/spec/fixtures/v2/public_keys.json +0 -1
  79. data/spec/fixtures/v2/pull.json +0 -1
  80. data/spec/fixtures/v2/pulls.json +0 -1
  81. data/spec/fixtures/v2/tags.json +0 -1
  82. data/spec/fixtures/v2/team.json +0 -1
  83. data/spec/fixtures/v2/teams.json +0 -1
  84. data/spec/fixtures/v2/tree.json +0 -1
@@ -4,17 +4,18 @@ require 'helper'
4
4
  describe Octokit::Client::Pulls do
5
5
 
6
6
  before do
7
- @client = Octokit::Client.new(:login => 'sferik')
7
+ @client = Octokit::Client.new(:login => 'pengwynn')
8
8
  end
9
9
 
10
10
  describe ".create_pull_request" do
11
11
 
12
12
  it "should create a pull request" do
13
- stub_post("https://github.com/api/v2/json/pulls/sferik/rails_admin").
13
+ stub_post("https://api.github.com/repos/pengwynn/octokit/pulls").
14
14
  with(:pull => {:base => "master", :head => "pengwynn:master", :title => "Title", :body => "Body"}).
15
- to_return(:body => fixture("v2/pulls.json"))
16
- issues = @client.create_pull_request("sferik/rails_admin", "master", "pengwynn:master", "Title", "Body")
17
- issues.first.number.should == 251
15
+ to_return(:body => fixture("v3/pull_created.json"))
16
+ pull = @client.create_pull_request("pengwynn/octokit", "master", "pengwynn:master", "Title", "Body")
17
+ pull.number.should == 15
18
+ pull.title.should == "Pull this awesome v3 stuff"
18
19
  end
19
20
 
20
21
  end
@@ -22,11 +23,11 @@ describe Octokit::Client::Pulls do
22
23
  describe ".create_pull_request_for_issue" do
23
24
 
24
25
  it "should create a pull request and attach it to an existing issue" do
25
- stub_post("https://github.com/api/v2/json/pulls/pengwynn/octokit").
26
- with(:pull => {:base => "master", :head => "pengwynn:master", :issue => "34"}).
27
- to_return(:body => fixture("v2/pulls.json"))
28
- issues = @client.create_pull_request_for_issue("pengwynn/octokit", "master", "pengwynn:master", "34")
29
- issues.first.number.should == 251
26
+ stub_post("https://api.github.com/repos/pengwynn/octokit/pulls").
27
+ with(:pull => {:base => "master", :head => "pengwynn:octokit", :issue => "15"}).
28
+ to_return(:body => fixture("v3/pull_created.json"))
29
+ pull = @client.create_pull_request_for_issue("pengwynn/octokit", "master", "pengwynn:octokit", "15")
30
+ pull.number.should == 15
30
31
  end
31
32
 
32
33
  end
@@ -34,10 +35,10 @@ describe Octokit::Client::Pulls do
34
35
  describe ".pull_requests" do
35
36
 
36
37
  it "should return all pull requests" do
37
- stub_get("https://github.com/api/v2/json/pulls/sferik/rails_admin/open").
38
- to_return(:body => fixture("v2/pulls.json"))
39
- pulls = @client.pulls("sferik/rails_admin")
40
- pulls.first.number.should == 251
38
+ stub_get("https://api.github.com/repos/pengwynn/octokit/pulls?state=open").
39
+ to_return(:body => fixture("v3/pull_requests.json"))
40
+ pulls = @client.pulls("pengwynn/octokit")
41
+ pulls.first.number.should == 928
41
42
  end
42
43
 
43
44
  end
@@ -45,10 +46,10 @@ describe Octokit::Client::Pulls do
45
46
  describe ".pull_request" do
46
47
 
47
48
  it "should return a pull request" do
48
- stub_get("https://github.com/api/v2/json/pulls/sferik/rails_admin/251").
49
- to_return(:body => fixture("v2/pull.json"))
50
- pull = @client.pull("sferik/rails_admin", 251)
51
- pull.number.should == 251
49
+ stub_get("https://api.github.com/repos/pengwynn/octokit/pulls/67").
50
+ to_return(:body => fixture("v3/pull_request.json"))
51
+ pull = @client.pull("pengwynn/octokit", 67)
52
+ pull.number.should == 67
52
53
  end
53
54
 
54
55
  end
@@ -73,7 +73,7 @@ describe Octokit::Client::Repositories do
73
73
  it "should watch a repository" do
74
74
  stub_put("/user/watched/sferik/rails_admin").
75
75
  to_return(:status => 204)
76
- @client.watch("sferik/rails_admin").should == ''
76
+ @client.watch("sferik/rails_admin").should be_nil
77
77
  end
78
78
 
79
79
  end
@@ -83,7 +83,7 @@ describe Octokit::Client::Repositories do
83
83
  it "should unwatch a repository" do
84
84
  stub_delete("/user/watched/sferik/rails_admin").
85
85
  to_return(:status => 204)
86
- @client.unwatch("sferik/rails_admin").should == ''
86
+ @client.unwatch("sferik/rails_admin").should be_nil
87
87
  end
88
88
 
89
89
  end
@@ -109,39 +109,13 @@ describe Octokit::Client::Repositories do
109
109
  repository.name.should == "rails_admin"
110
110
  end
111
111
 
112
- end
113
-
114
- describe ".delete_repository" do
115
-
116
- it "should return a delete token" do
117
- stub_post("https://github.com/api/v2/json/repos/delete/sferik/rails_admin").
118
- to_return(:body => fixture("v2/delete_token.json"))
119
- delete_token = @client.delete_repository("sferik/rails_admin")
120
- delete_token.should == "uhihwkkkzu"
121
- end
122
-
123
- end
124
-
125
- describe ".delete_repository!" do
126
-
127
- it "should delete a repository" do
128
- stub_post("https://github.com/api/v2/json/repos/delete/sferik/rails_admin").
129
- to_return(:body => fixture("v2/delete_token.json"))
130
- stub_post("https://github.com/api/v2/json/repos/delete/sferik/rails_admin").
131
- with(:delete_token => "uhihwkkkzu").
132
- to_return(:status => 204)
133
- @client.delete_repo!("sferik/rails_admin")
134
- end
135
-
136
- end
137
-
138
- describe ".delete_repository" do
139
-
140
- it "should return an error for non-existant repo" do
141
- stub_post("https://github.com/api/v2/json/repos/delete/sferik/rails_admin_failure").
142
- to_return(:body => fixture("v2/delete_failure.json"))
143
- response = @client.delete_repository("sferik/rails_admin_failure")
144
- response.error.should == "sferik/rails_admin_failure Repository not found"
112
+ it "should create a repository for an organization" do
113
+ stub_post("/orgs/comorichwebgroup/repos").
114
+ with(:name => "demo").
115
+ to_return(:body => fixture("v3/organization-repository.json"))
116
+ repository = @client.create_repository("demo", {:organization => 'comorichwebgroup'})
117
+ repository.name.should == "demo"
118
+ repository.organization.login.should == "CoMoRichWebGroup"
145
119
  end
146
120
 
147
121
  end
@@ -199,7 +173,7 @@ describe Octokit::Client::Repositories do
199
173
  stub_delete("/repos/sferik/rails_admin/keys/#{103205}").
200
174
  to_return(:status => 204)
201
175
  result = @client.remove_deploy_key("sferik/rails_admin", 103205)
202
- result.should == ''
176
+ result.should be_nil
203
177
  end
204
178
 
205
179
  end
@@ -221,7 +195,7 @@ describe Octokit::Client::Repositories do
221
195
  stub_put("/repos/sferik/rails_admin/collaborators/sferik").
222
196
  to_return(:status => 204)
223
197
  result = @client.add_collaborator("sferik/rails_admin", "sferik")
224
- result.should == ''
198
+ result.should be_nil
225
199
  end
226
200
 
227
201
  end
@@ -232,7 +206,7 @@ describe Octokit::Client::Repositories do
232
206
  stub_delete("/repos/sferik/rails_admin/collaborators/sferik").
233
207
  to_return(:status => 204)
234
208
  result = @client.remove_collaborator("sferik/rails_admin", "sferik")
235
- result.should == ''
209
+ result.should be_nil
236
210
  end
237
211
 
238
212
  end
@@ -342,4 +316,16 @@ describe Octokit::Client::Repositories do
342
316
 
343
317
  end
344
318
 
319
+ describe ".events" do
320
+
321
+ it "should list event for all issues in a repository" do
322
+ stub_get("/repos/pengwynn/octokit/issues/events").
323
+ to_return(:body => fixture("v3/repo_issues_events.json"))
324
+ events = @client.repo_issue_events("pengwynn/octokit")
325
+ events.first.actor.login.should == "ctshryock"
326
+ events.first.event.should == "subscribed"
327
+ end
328
+
329
+ end
330
+
345
331
  end
@@ -80,10 +80,10 @@ describe Octokit::Client::Users do
80
80
  context "with a username passed" do
81
81
 
82
82
  it "should return the user's followers" do
83
- stub_get("https://github.com/api/v2/json/user/show/sferik/followers").
84
- to_return(:body => fixture("v2/followers.json"))
83
+ stub_get("https://api.github.com/users/sferik/followers").
84
+ to_return(:body => fixture("v3/followers.json"))
85
85
  users = @client.followers("sferik")
86
- users.first.should == "puls"
86
+ users.first.login.should == "puls"
87
87
  end
88
88
 
89
89
  end
@@ -91,10 +91,10 @@ describe Octokit::Client::Users do
91
91
  context "without a username passed" do
92
92
 
93
93
  it "should return the user's followers" do
94
- stub_get("https://github.com/api/v2/json/user/show/sferik/followers").
95
- to_return(:body => fixture("v2/followers.json"))
94
+ stub_get("https://api.github.com/users/sferik/followers").
95
+ to_return(:body => fixture("v3/followers.json"))
96
96
  users = @client.followers
97
- users.first.should == "puls"
97
+ users.first.login.should == "puls"
98
98
  end
99
99
 
100
100
  end
@@ -106,10 +106,10 @@ describe Octokit::Client::Users do
106
106
  context "with a username passed" do
107
107
 
108
108
  it "should return the user's following" do
109
- stub_get("https://github.com/api/v2/json/user/show/sferik/following").
110
- to_return(:body => fixture("v2/following.json"))
109
+ stub_get("https://api.github.com/users/sferik/following").
110
+ to_return(:body => fixture("v3/following.json"))
111
111
  users = @client.following("sferik")
112
- users.first.should == "rails"
112
+ users.first.login.should == "rails"
113
113
  end
114
114
 
115
115
  end
@@ -117,10 +117,10 @@ describe Octokit::Client::Users do
117
117
  context "without a username passed" do
118
118
 
119
119
  it "should return the user's following" do
120
- stub_get("https://github.com/api/v2/json/user/show/sferik/following").
121
- to_return(:body => fixture("v2/following.json"))
120
+ stub_get("https://api.github.com/users/sferik/following").
121
+ to_return(:body => fixture("v3/following.json"))
122
122
  users = @client.following
123
- users.first.should == "rails"
123
+ users.first.login.should == "rails"
124
124
  end
125
125
 
126
126
  end
@@ -132,9 +132,9 @@ describe Octokit::Client::Users do
132
132
  context "with one user following another" do
133
133
 
134
134
  it "should return true" do
135
- stub_get("https://github.com/api/v2/json/user/show/sferik/following").
136
- to_return(:body => fixture("v2/following.json"))
137
- follows = @client.follows?("sferik", "pengwynn")
135
+ stub_get("https://api.github.com/user/following/puls").
136
+ to_return(:status => 204, :body => "")
137
+ follows = @client.follows?("sferik", "puls")
138
138
  follows.should be_true
139
139
  end
140
140
 
@@ -143,8 +143,8 @@ describe Octokit::Client::Users do
143
143
  context "with one user not following another" do
144
144
 
145
145
  it "should return false" do
146
- stub_get("https://github.com/api/v2/json/user/show/sferik/following").
147
- to_return(:body => fixture("v2/following.json"))
146
+ stub_get("https://api.github.com/user/following/dogbrainz").
147
+ to_return(:status => 404, :body => "")
148
148
  follows = @client.follows?("sferik", "dogbrainz")
149
149
  follows.should be_false
150
150
  end
@@ -156,10 +156,10 @@ describe Octokit::Client::Users do
156
156
  describe ".follow" do
157
157
 
158
158
  it "should follow a user" do
159
- stub_post("https://github.com/api/v2/json/user/follow/dianakimball").
160
- to_return(:body => fixture("v2/following.json"))
159
+ stub_put("https://api.github.com/user/following/dianakimball").
160
+ to_return(:status => 204, :body => "")
161
161
  following = @client.follow("dianakimball")
162
- following.should include("dianakimball")
162
+ following.should be_true
163
163
  end
164
164
 
165
165
  end
@@ -167,10 +167,10 @@ describe Octokit::Client::Users do
167
167
  describe ".unfollow" do
168
168
 
169
169
  it "should unfollow a user" do
170
- stub_post("https://github.com/api/v2/json/user/unfollow/dogbrainz").
171
- to_return(:body => fixture("v2/following.json"))
170
+ stub_delete("https://api.github.com/user/following/dogbrainz").
171
+ to_return(:status => 204, :body => "")
172
172
  following = @client.unfollow("dogbrainz")
173
- following.should_not include("dogbrainz")
173
+ following.should be_true
174
174
  end
175
175
 
176
176
  end
@@ -180,10 +180,10 @@ describe Octokit::Client::Users do
180
180
  context "with a username passed" do
181
181
 
182
182
  it "should return watched repositories" do
183
- stub_get("https://github.com/api/v2/json/repos/watched/sferik").
184
- to_return(:body => fixture("v2/repositories.json"))
183
+ stub_get("https://api.github.com/users/sferik/watched").
184
+ to_return(:body => fixture("v3/watched.json"))
185
185
  repositories = @client.watched("sferik")
186
- repositories.first.name.should == "One40Proof"
186
+ repositories.first.name.should == "grit"
187
187
  end
188
188
 
189
189
  end
@@ -191,10 +191,10 @@ describe Octokit::Client::Users do
191
191
  context "without a username passed" do
192
192
 
193
193
  it "should return watched repositories" do
194
- stub_get("https://github.com/api/v2/json/repos/watched/sferik").
195
- to_return(:body => fixture("v2/repositories.json"))
194
+ stub_get("https://api.github.com/users/sferik/watched").
195
+ to_return(:body => fixture("v3/watched.json"))
196
196
  repositories = @client.watched
197
- repositories.first.name.should == "One40Proof"
197
+ repositories.first.name.should == "grit"
198
198
  end
199
199
 
200
200
  end
@@ -204,8 +204,8 @@ describe Octokit::Client::Users do
204
204
  describe ".keys" do
205
205
 
206
206
  it "should return public keys" do
207
- stub_get("https://github.com/api/v2/json/user/keys").
208
- to_return(:body => fixture("v2/public_keys.json"))
207
+ stub_get("https://api.github.com/user/keys").
208
+ to_return(:body => fixture("v3/public_keys.json"))
209
209
  public_keys = @client.keys
210
210
  public_keys.first.id.should == 103205
211
211
  end
@@ -215,11 +215,12 @@ describe Octokit::Client::Users do
215
215
  describe ".add_key" do
216
216
 
217
217
  it "should add a public key" do
218
- stub_post("https://github.com/api/v2/json/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("v2/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
218
+ title, 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"
219
+ stub_post("https://api.github.com/user/keys").
220
+ with(:title => title, :key => key).
221
+ to_return(:status => 201, :body => fixture("v3/public_key.json"))
222
+ public_key = @client.add_key(title, key)
223
+ public_key.id.should == 103205
223
224
  end
224
225
 
225
226
  end
@@ -227,11 +228,10 @@ describe Octokit::Client::Users do
227
228
  describe ".remove_key" do
228
229
 
229
230
  it "should remove a public key" do
230
- stub_post("https://github.com/api/v2/json/user/key/remove").
231
- with(:id => 103205).
232
- to_return(:body => fixture("v2/public_keys.json"))
233
- public_keys = @client.remove_key(103205)
234
- public_keys.first.id.should == 103205
231
+ stub_delete("https://api.github.com/user/keys/103205").
232
+ to_return(:status => 204, :body => "")
233
+ response = @client.remove_key(103205)
234
+ response.should be_true
235
235
  end
236
236
 
237
237
  end
@@ -239,8 +239,8 @@ describe Octokit::Client::Users do
239
239
  describe ".emails" do
240
240
 
241
241
  it "should return email addresses" do
242
- stub_get("https://github.com/api/v2/json/user/emails").
243
- to_return(:body => fixture("v2/emails.json"))
242
+ stub_get("https://api.github.com/user/emails").
243
+ to_return(:body => fixture("v3/emails.json"))
244
244
  emails = @client.emails
245
245
  emails.first.should == "sferik@gmail.com"
246
246
  end
@@ -250,23 +250,22 @@ describe Octokit::Client::Users do
250
250
  describe ".add_email" do
251
251
 
252
252
  it "should add an email address" do
253
- stub_post("https://github.com/api/v2/json/user/email/add").
253
+ stub_post("https://api.github.com/user/emails").
254
254
  with(:email => "sferik@gmail.com").
255
- to_return(:body => fixture("v2/emails.json"))
255
+ to_return(:body => fixture("v3/emails.json"))
256
256
  emails = @client.add_email("sferik@gmail.com")
257
257
  emails.first.should == "sferik@gmail.com"
258
258
  end
259
259
 
260
260
  end
261
261
 
262
- describe ".remove_key" do
262
+ describe ".remove_email" do
263
263
 
264
264
  it "should remove an email address" do
265
- stub_post("https://github.com/api/v2/json/user/email/remove").
266
- with(:email => "sferik@gmail.com").
267
- to_return(:body => fixture("v2/emails.json"))
268
- emails = @client.remove_email("sferik@gmail.com")
269
- emails.first.should == "sferik@gmail.com"
265
+ stub_delete("https://api.github.com/user/emails?email=sferik@gmail.com").
266
+ to_return(:status => 204, :body => "")
267
+ response = @client.remove_email("sferik@gmail.com")
268
+ response.should be_true
270
269
  end
271
270
 
272
271
  end
@@ -9,4 +9,20 @@ describe Octokit::Client do
9
9
  Octokit::Client.new(:login => 'foo', :password => 'bar').commits('baz/quux')
10
10
  }.should_not raise_exception
11
11
  end
12
+
13
+ it "should traverse a paginated response if auto_traversal is on" do
14
+ stub_get("https://api.github.com/foo/bar").
15
+ to_return(:status => 200, :body => %q{["stuff"]}, :headers =>
16
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last"} })
17
+
18
+ stub_get("https://api.github.com/foo/bar?page=2").
19
+ to_return(:status => 200, :body => %q{["even more stuff"]}, :headers =>
20
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=3>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last", <https://api.github.com/foo/bar?page=1>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
21
+
22
+ stub_get("https://api.github.com/foo/bar?page=3").
23
+ to_return(:status => 200, :body => %q{["stuffapalooza"]}, :headers =>
24
+ { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })
25
+
26
+ Octokit::Client.new(:auto_traversal => true).get("https://api.github.com/foo/bar", {}, 3).should == ['stuff', 'even more stuff', 'stuffapalooza']
27
+ end
12
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,130 +11,141 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-15 00:00:00.000000000Z
14
+ date: 2012-02-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: addressable
18
- requirement: &70129246095580 !ruby/object:Gem::Requirement
18
+ requirement: &70290067718980 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 2.2.6
23
+ version: '2.2'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70129246095580
26
+ version_requirements: *70290067718980
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
- requirement: &70129246093420 !ruby/object:Gem::Requirement
29
+ requirement: &70290067721200 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 0.7.4
34
+ version: '0.7'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70129246093420
37
+ version_requirements: *70290067721200
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: faraday_middleware
40
- requirement: &70129246092040 !ruby/object:Gem::Requirement
40
+ requirement: &70290067730980 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.7.0
45
+ version: '0.8'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70129246092040
48
+ version_requirements: *70290067730980
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: hashie
51
- requirement: &70129246091200 !ruby/object:Gem::Requirement
51
+ requirement: &70290067778320 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: 1.2.0
56
+ version: '1.2'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70129246091200
59
+ version_requirements: *70290067778320
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: multi_json
62
- requirement: &70129246088920 !ruby/object:Gem::Requirement
62
+ requirement: &70290067795800 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 1.0.2
67
+ version: '1.0'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70129246088920
70
+ version_requirements: *70290067795800
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: json
73
- requirement: &70129246088080 !ruby/object:Gem::Requirement
73
+ requirement: &70290067805640 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
- - - ~>
76
+ - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
- version: '1.6'
78
+ version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70129246088080
81
+ version_requirements: *70290067805640
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rake
84
- requirement: &70129246086920 !ruby/object:Gem::Requirement
84
+ requirement: &70290067814300 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ~>
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
- version: '0.9'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *70129246086920
92
+ version_requirements: *70290067814300
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rspec
95
- requirement: &70129246086120 !ruby/object:Gem::Requirement
95
+ requirement: &70290067823200 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ~>
99
99
  - !ruby/object:Gem::Version
100
- version: '2.6'
100
+ version: '2.8'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *70129246086120
103
+ version_requirements: *70290067823200
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: simplecov
106
- requirement: &70129246085140 !ruby/object:Gem::Requirement
106
+ requirement: &70290067833280 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
- - - ~>
109
+ - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
- version: '0.4'
111
+ version: '0'
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *70129246085140
114
+ version_requirements: *70290067833280
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: webmock
117
- requirement: &70129246084240 !ruby/object:Gem::Requirement
117
+ requirement: &70290067832080 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
- - - ~>
120
+ - - ! '>='
121
121
  - !ruby/object:Gem::Version
122
- version: '1.7'
122
+ version: '0'
123
123
  type: :development
124
124
  prerelease: false
125
- version_requirements: *70129246084240
125
+ version_requirements: *70290067832080
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: yard
128
- requirement: &70129246083520 !ruby/object:Gem::Requirement
128
+ requirement: &70290067831340 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
- - - ~>
131
+ - - ! '>='
132
132
  - !ruby/object:Gem::Version
133
- version: '0.7'
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: *70290067831340
137
+ - !ruby/object:Gem::Dependency
138
+ name: rdiscount
139
+ requirement: &70290067830080 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
134
145
  type: :development
135
146
  prerelease: false
136
- version_requirements: *70129246083520
137
- description: Simple wrapper for the GitHub API v2
147
+ version_requirements: *70290067830080
148
+ description: Simple wrapper for the GitHub API (v2 and v3)
138
149
  email:
139
150
  - wynn.netherland@gmail.com
140
151
  - adam@stacoviak.com
@@ -158,6 +169,7 @@ files:
158
169
  - lib/octokit/authentication.rb
159
170
  - lib/octokit/client.rb
160
171
  - lib/octokit/client/commits.rb
172
+ - lib/octokit/client/events.rb
161
173
  - lib/octokit/client/issues.rb
162
174
  - lib/octokit/client/labels.rb
163
175
  - lib/octokit/client/milestones.rb
@@ -177,63 +189,72 @@ files:
177
189
  - lib/octokit/request.rb
178
190
  - lib/octokit/version.rb
179
191
  - octokit.gemspec
180
- - puppeteer.jpg
181
192
  - spec/faraday/response_spec.rb
182
193
  - spec/fixtures/timeline.json
183
- - spec/fixtures/v2/blob.json
184
194
  - spec/fixtures/v2/blob_metadata.json
185
195
  - spec/fixtures/v2/blobs.json
186
- - spec/fixtures/v2/comment.json
187
- - spec/fixtures/v2/comments.json
188
- - spec/fixtures/v2/delete_failure.json
189
- - spec/fixtures/v2/delete_token.json
190
- - spec/fixtures/v2/emails.json
191
- - spec/fixtures/v2/followers.json
192
- - spec/fixtures/v2/following.json
193
- - spec/fixtures/v2/issue.json
194
196
  - spec/fixtures/v2/issues.json
195
- - spec/fixtures/v2/labels.json
196
197
  - spec/fixtures/v2/network_data.json
197
198
  - spec/fixtures/v2/network_meta.json
198
- - spec/fixtures/v2/organization.json
199
- - spec/fixtures/v2/organizations.json
200
- - spec/fixtures/v2/public_keys.json
201
- - spec/fixtures/v2/pull.json
202
- - spec/fixtures/v2/pulls.json
203
199
  - spec/fixtures/v2/raw.txt
204
200
  - spec/fixtures/v2/repositories.json
205
- - spec/fixtures/v2/tags.json
206
- - spec/fixtures/v2/team.json
207
- - spec/fixtures/v2/teams.json
208
- - spec/fixtures/v2/tree.json
209
201
  - spec/fixtures/v2/tree_metadata.json
210
202
  - spec/fixtures/v2/user.json
211
203
  - spec/fixtures/v2/users.json
204
+ - spec/fixtures/v3/blob.json
212
205
  - spec/fixtures/v3/branches.json
213
206
  - spec/fixtures/v3/collaborators.json
214
207
  - spec/fixtures/v3/comment.json
215
208
  - spec/fixtures/v3/comments.json
216
209
  - spec/fixtures/v3/commit.json
210
+ - spec/fixtures/v3/commit_comment.json
211
+ - spec/fixtures/v3/commit_comments.json
217
212
  - spec/fixtures/v3/commits.json
218
213
  - spec/fixtures/v3/contributors.json
214
+ - spec/fixtures/v3/emails.json
215
+ - spec/fixtures/v3/followers.json
216
+ - spec/fixtures/v3/following.json
219
217
  - spec/fixtures/v3/forks.json
218
+ - spec/fixtures/v3/issue.json
219
+ - spec/fixtures/v3/issue_closed.json
220
+ - spec/fixtures/v3/issue_event.json
221
+ - spec/fixtures/v3/issue_events.json
220
222
  - spec/fixtures/v3/issues.json
221
223
  - spec/fixtures/v3/label.json
222
224
  - spec/fixtures/v3/labels.json
223
225
  - spec/fixtures/v3/languages.json
226
+ - spec/fixtures/v3/list_commit_comments.json
224
227
  - spec/fixtures/v3/milestone.json
225
228
  - spec/fixtures/v3/milestones.json
226
229
  - spec/fixtures/v3/not_found.json
230
+ - spec/fixtures/v3/organization-repositories.json
231
+ - spec/fixtures/v3/organization-repository.json
232
+ - spec/fixtures/v3/organization.json
233
+ - spec/fixtures/v3/organization_members.json
234
+ - spec/fixtures/v3/organization_team_members.json
235
+ - spec/fixtures/v3/organization_team_repos.json
236
+ - spec/fixtures/v3/organizations.json
237
+ - spec/fixtures/v3/public_events.json
227
238
  - spec/fixtures/v3/public_key.json
228
239
  - spec/fixtures/v3/public_keys.json
240
+ - spec/fixtures/v3/pull_created.json
241
+ - spec/fixtures/v3/pull_request.json
242
+ - spec/fixtures/v3/pull_requests.json
243
+ - spec/fixtures/v3/repo_events.json
244
+ - spec/fixtures/v3/repo_issues_events.json
229
245
  - spec/fixtures/v3/repositories.json
230
246
  - spec/fixtures/v3/repository.json
231
247
  - spec/fixtures/v3/tags.json
248
+ - spec/fixtures/v3/team.json
232
249
  - spec/fixtures/v3/teams.json
250
+ - spec/fixtures/v3/tree.json
233
251
  - spec/fixtures/v3/user.json
252
+ - spec/fixtures/v3/watched.json
234
253
  - spec/fixtures/v3/watchers.json
235
254
  - spec/helper.rb
236
255
  - spec/octokit/client/commits_spec.rb
256
+ - spec/octokit/client/events_spec.rb
257
+ - spec/octokit/client/issue_events_spec.rb
237
258
  - spec/octokit/client/issues_spec.rb
238
259
  - spec/octokit/client/labels_spec.rb
239
260
  - spec/octokit/client/milestones_spec.rb
@@ -276,60 +297,70 @@ summary: Wrapper for the GitHub API
276
297
  test_files:
277
298
  - spec/faraday/response_spec.rb
278
299
  - spec/fixtures/timeline.json
279
- - spec/fixtures/v2/blob.json
280
300
  - spec/fixtures/v2/blob_metadata.json
281
301
  - spec/fixtures/v2/blobs.json
282
- - spec/fixtures/v2/comment.json
283
- - spec/fixtures/v2/comments.json
284
- - spec/fixtures/v2/delete_failure.json
285
- - spec/fixtures/v2/delete_token.json
286
- - spec/fixtures/v2/emails.json
287
- - spec/fixtures/v2/followers.json
288
- - spec/fixtures/v2/following.json
289
- - spec/fixtures/v2/issue.json
290
302
  - spec/fixtures/v2/issues.json
291
- - spec/fixtures/v2/labels.json
292
303
  - spec/fixtures/v2/network_data.json
293
304
  - spec/fixtures/v2/network_meta.json
294
- - spec/fixtures/v2/organization.json
295
- - spec/fixtures/v2/organizations.json
296
- - spec/fixtures/v2/public_keys.json
297
- - spec/fixtures/v2/pull.json
298
- - spec/fixtures/v2/pulls.json
299
305
  - spec/fixtures/v2/raw.txt
300
306
  - spec/fixtures/v2/repositories.json
301
- - spec/fixtures/v2/tags.json
302
- - spec/fixtures/v2/team.json
303
- - spec/fixtures/v2/teams.json
304
- - spec/fixtures/v2/tree.json
305
307
  - spec/fixtures/v2/tree_metadata.json
306
308
  - spec/fixtures/v2/user.json
307
309
  - spec/fixtures/v2/users.json
310
+ - spec/fixtures/v3/blob.json
308
311
  - spec/fixtures/v3/branches.json
309
312
  - spec/fixtures/v3/collaborators.json
310
313
  - spec/fixtures/v3/comment.json
311
314
  - spec/fixtures/v3/comments.json
312
315
  - spec/fixtures/v3/commit.json
316
+ - spec/fixtures/v3/commit_comment.json
317
+ - spec/fixtures/v3/commit_comments.json
313
318
  - spec/fixtures/v3/commits.json
314
319
  - spec/fixtures/v3/contributors.json
320
+ - spec/fixtures/v3/emails.json
321
+ - spec/fixtures/v3/followers.json
322
+ - spec/fixtures/v3/following.json
315
323
  - spec/fixtures/v3/forks.json
324
+ - spec/fixtures/v3/issue.json
325
+ - spec/fixtures/v3/issue_closed.json
326
+ - spec/fixtures/v3/issue_event.json
327
+ - spec/fixtures/v3/issue_events.json
316
328
  - spec/fixtures/v3/issues.json
317
329
  - spec/fixtures/v3/label.json
318
330
  - spec/fixtures/v3/labels.json
319
331
  - spec/fixtures/v3/languages.json
332
+ - spec/fixtures/v3/list_commit_comments.json
320
333
  - spec/fixtures/v3/milestone.json
321
334
  - spec/fixtures/v3/milestones.json
322
335
  - spec/fixtures/v3/not_found.json
336
+ - spec/fixtures/v3/organization-repositories.json
337
+ - spec/fixtures/v3/organization-repository.json
338
+ - spec/fixtures/v3/organization.json
339
+ - spec/fixtures/v3/organization_members.json
340
+ - spec/fixtures/v3/organization_team_members.json
341
+ - spec/fixtures/v3/organization_team_repos.json
342
+ - spec/fixtures/v3/organizations.json
343
+ - spec/fixtures/v3/public_events.json
323
344
  - spec/fixtures/v3/public_key.json
324
345
  - spec/fixtures/v3/public_keys.json
346
+ - spec/fixtures/v3/pull_created.json
347
+ - spec/fixtures/v3/pull_request.json
348
+ - spec/fixtures/v3/pull_requests.json
349
+ - spec/fixtures/v3/repo_events.json
350
+ - spec/fixtures/v3/repo_issues_events.json
325
351
  - spec/fixtures/v3/repositories.json
326
352
  - spec/fixtures/v3/repository.json
327
353
  - spec/fixtures/v3/tags.json
354
+ - spec/fixtures/v3/team.json
328
355
  - spec/fixtures/v3/teams.json
356
+ - spec/fixtures/v3/tree.json
329
357
  - spec/fixtures/v3/user.json
358
+ - spec/fixtures/v3/watched.json
330
359
  - spec/fixtures/v3/watchers.json
331
360
  - spec/helper.rb
332
361
  - spec/octokit/client/commits_spec.rb
362
+ - spec/octokit/client/events_spec.rb
363
+ - spec/octokit/client/issue_events_spec.rb
333
364
  - spec/octokit/client/issues_spec.rb
334
365
  - spec/octokit/client/labels_spec.rb
335
366
  - spec/octokit/client/milestones_spec.rb
@@ -345,4 +376,3 @@ test_files:
345
376
  - spec/octokit/client_spec.rb
346
377
  - spec/octokit_spec.rb
347
378
  - spec/repository_spec.rb
348
- has_rdoc: