github_api 0.4.4 → 0.4.5

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 (62) hide show
  1. data/features/error_codes.feature +1 -1
  2. data/lib/github_api/error.rb +25 -32
  3. data/lib/github_api/error/bad_request.rb +12 -0
  4. data/lib/github_api/error/forbidden.rb +12 -0
  5. data/lib/github_api/error/internal_server_error.rb +12 -0
  6. data/lib/github_api/error/not_found.rb +12 -0
  7. data/lib/github_api/error/service_error.rb +19 -0
  8. data/lib/github_api/error/service_unavailable.rb +12 -0
  9. data/lib/github_api/error/unauthorized.rb +12 -0
  10. data/lib/github_api/error/unprocessable_entity.rb +12 -0
  11. data/lib/github_api/gists.rb +1 -1
  12. data/lib/github_api/orgs/members.rb +2 -2
  13. data/lib/github_api/orgs/teams.rb +2 -2
  14. data/lib/github_api/pull_requests.rb +14 -7
  15. data/lib/github_api/pull_requests/comments.rb +19 -14
  16. data/lib/github_api/repos/collaborators.rb +1 -1
  17. data/lib/github_api/repos/watching.rb +1 -1
  18. data/lib/github_api/response/raise_error.rb +8 -13
  19. data/lib/github_api/users/followers.rb +1 -1
  20. data/lib/github_api/version.rb +1 -1
  21. data/spec/fixtures/pull_requests/comment.json +17 -0
  22. data/spec/fixtures/pull_requests/comments.json +19 -0
  23. data/spec/fixtures/pull_requests/commits.json +27 -0
  24. data/spec/fixtures/pull_requests/files.json +13 -0
  25. data/spec/fixtures/pull_requests/merge_failure.json +5 -0
  26. data/spec/fixtures/pull_requests/merge_success.json +5 -0
  27. data/spec/fixtures/pull_requests/pull_request.json +123 -0
  28. data/spec/fixtures/pull_requests/pull_requests.json +31 -0
  29. data/spec/github/authorizations_spec.rb +5 -5
  30. data/spec/github/events_spec.rb +8 -8
  31. data/spec/github/gists/comments_spec.rb +5 -5
  32. data/spec/github/gists_spec.rb +7 -7
  33. data/spec/github/git_data/blobs_spec.rb +2 -2
  34. data/spec/github/git_data/commits_spec.rb +2 -2
  35. data/spec/github/git_data/references_spec.rb +4 -4
  36. data/spec/github/git_data/tags_spec.rb +2 -2
  37. data/spec/github/git_data/trees_spec.rb +2 -2
  38. data/spec/github/git_data_spec.rb +0 -1
  39. data/spec/github/issues/comments_spec.rb +5 -5
  40. data/spec/github/issues/events_spec.rb +2 -2
  41. data/spec/github/issues/labels_spec.rb +10 -10
  42. data/spec/github/issues/milestones_spec.rb +5 -5
  43. data/spec/github/issues_spec.rb +5 -5
  44. data/spec/github/orgs/members_spec.rb +5 -5
  45. data/spec/github/orgs/teams_spec.rb +11 -11
  46. data/spec/github/orgs_spec.rb +3 -3
  47. data/spec/github/pull_requests/comments_spec.rb +265 -0
  48. data/spec/github/pull_requests_spec.rb +414 -0
  49. data/spec/github/repos/collaborators_spec.rb +3 -3
  50. data/spec/github/repos/commits_spec.rb +8 -8
  51. data/spec/github/repos/downloads_spec.rb +5 -5
  52. data/spec/github/repos/forks_spec.rb +2 -2
  53. data/spec/github/repos/hooks_spec.rb +6 -6
  54. data/spec/github/repos/keys_spec.rb +5 -5
  55. data/spec/github/repos/pub_sub_hubbub_spec.rb +2 -2
  56. data/spec/github/repos/watching_spec.rb +6 -6
  57. data/spec/github/repos_spec.rb +11 -11
  58. data/spec/github/users/emails_spec.rb +5 -0
  59. data/spec/github/users/followers_spec.rb +5 -0
  60. data/spec/github/users/keys_spec.rb +5 -0
  61. data/spec/github/users_spec.rb +2 -2
  62. metadata +23 -2
@@ -9,28 +9,23 @@ module Github
9
9
  def on_complete(env)
10
10
  case env[:status].to_i
11
11
  when 400
12
- raise Github::BadRequest.new(response_message(env), env[:response_headers])
12
+ raise Github::Error::BadRequest.new(env)
13
13
  when 401
14
- raise Github::Unauthorised.new(response_message(env), env[:response_headers])
14
+ raise Github::Error::Unauthorized.new(env)
15
15
  when 403
16
- raise Github::Forbidden.new(response_message(env), env[:response_headers])
16
+ raise Github::Error::Forbidden.new(env)
17
17
  when 404
18
- raise Github::ResourceNotFound.new(response_message(env), env[:response_headers])
19
-
18
+ raise Github::Error::NotFound.new(env)
20
19
  when 422
21
- raise Github::UnprocessableEntity.new(response_message(env), env[:response_headers])
20
+ raise Github::Error::UnprocessableEntity.new(env)
22
21
  when 500
23
- raise Github::InternalServerError.new(response_message(env), env[:response_headers])
22
+ raise Github::Error::InternalServerError.new(env)
24
23
  when 503
25
- raise Github::ServiceUnavailable.new(response_message(env), env[:response_headers])
24
+ raise Github::Error::ServiceUnavailable.new(env)
26
25
  when 400...600
27
- raise Github::Error.new(response_message(env), env[:response_headers])
26
+ raise Github::Error::ServiceError.new(env)
28
27
  end
29
28
  end
30
29
 
31
- def response_message(env)
32
- "#{env[:method].to_s.upcase} #{env[:url].to_s}: #{env[:status]}#{env[:body]}"
33
- end
34
-
35
30
  end # Response::RaiseError
36
31
  end # Github
@@ -65,7 +65,7 @@ module Github
65
65
  _normalize_params_keys(params)
66
66
  get("/user/following/#{user_name}", params)
67
67
  true
68
- rescue Github::ResourceNotFound
68
+ rescue Github::Error::NotFound
69
69
  false
70
70
  end
71
71
 
@@ -4,7 +4,7 @@ module Github
4
4
  module VERSION
5
5
  MAJOR = 0
6
6
  MINOR = 4
7
- PATCH = 4
7
+ PATCH = 5
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
@@ -0,0 +1,17 @@
1
+ {
2
+ "url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1",
3
+ "id": 1,
4
+ "body": "Great stuff",
5
+ "path": "file1.txt",
6
+ "position": 4,
7
+ "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
8
+ "user": {
9
+ "login": "octocat",
10
+ "id": 1,
11
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
12
+ "gravatar_id": "somehexcode",
13
+ "url": "https://api.github.com/users/octocat"
14
+ },
15
+ "created_at": "2011-04-14T16:00:49Z",
16
+ "updated_at": "2011-04-14T16:00:49Z"
17
+ }
@@ -0,0 +1,19 @@
1
+ [
2
+ {
3
+ "url": "https://api.github.com/repos/octocat/Hello-World/pulls/comments/1",
4
+ "id": 1,
5
+ "body": "Great stuff",
6
+ "path": "file1.txt",
7
+ "position": 4,
8
+ "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
9
+ "user": {
10
+ "login": "octocat",
11
+ "id": 1,
12
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
13
+ "gravatar_id": "somehexcode",
14
+ "url": "https://api.github.com/users/octocat"
15
+ },
16
+ "created_at": "2011-04-14T16:00:49Z",
17
+ "updated_at": "2011-04-14T16:00:49Z"
18
+ }
19
+ ]
@@ -0,0 +1,27 @@
1
+ [
2
+ {
3
+ "sha": "7638417db6d59f3c431d3e1f261cc637155684cd",
4
+ "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd",
5
+ "author": {
6
+ "date": "2010-04-10T14:10:01-07:00",
7
+ "name": "Scott Chacon",
8
+ "email": "schacon@gmail.com"
9
+ },
10
+ "committer": {
11
+ "date": "2010-04-10T14:10:01-07:00",
12
+ "name": "Scott Chacon",
13
+ "email": "schacon@gmail.com"
14
+ },
15
+ "message": "added readme, because im a good github citizen\n",
16
+ "tree": {
17
+ "url": "https://api.github.com/repos/octocat/Hello-World/git/trees/691272480426f78a0138979dd3ce63b77f706feb",
18
+ "sha": "691272480426f78a0138979dd3ce63b77f706feb"
19
+ },
20
+ "parents": [
21
+ {
22
+ "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5",
23
+ "sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5"
24
+ }
25
+ ]
26
+ }
27
+ ]
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
4
+ "filename": "file1.txt",
5
+ "status": "added",
6
+ "additions": 103,
7
+ "deletions": 21,
8
+ "changes": 124,
9
+ "blob_url": "https://github.com/octocate/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
10
+ "raw_url": "https://github.com/octocate/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
11
+ "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
12
+ }
13
+ ]
@@ -0,0 +1,5 @@
1
+ {
2
+ "sha": null,
3
+ "merged": false,
4
+ "message": "Failure reason"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
+ "merged": true,
4
+ "message": "Pull Request successfully merged"
5
+ }
@@ -0,0 +1,123 @@
1
+ {
2
+ "url": "https://api.github.com/octocat/Hello-World/pulls/1",
3
+ "html_url": "https://github.com/octocat/Hello-World/pulls/1",
4
+ "diff_url": "https://github.com/octocat/Hello-World/pulls/1.diff",
5
+ "patch_url": "https://github.com/octocat/Hello-World/pulls/1.patch",
6
+ "issue_url": "https://github.com/octocat/Hello-World/issue/1",
7
+ "number": 1,
8
+ "state": "open",
9
+ "title": "new-feature",
10
+ "body": "Please pull these awesome changes",
11
+ "created_at": "2011-01-26T19:01:12Z",
12
+ "updated_at": "2011-01-26T19:01:12Z",
13
+ "closed_at": "2011-01-26T19:01:12Z",
14
+ "merged_at": "2011-01-26T19:01:12Z",
15
+ "_links": {
16
+ "self": {
17
+ "href": "https://api.github.com/octocat/Hello-World/pulls/1"
18
+ },
19
+ "html": {
20
+ "href": "https://github.com/octocat/Hello-World/pull/1"
21
+ },
22
+ "comments": {
23
+ "href": "https://api.github.com/octocat/Hello-World/issues/1/comments"
24
+ },
25
+ "review_comments": {
26
+ "href": "https://api.github.com/octocat/Hello-World/pulls/1/comments"
27
+ }
28
+ },
29
+ "merged": false,
30
+ "mergeable": true,
31
+ "merged_by": {
32
+ "login": "octocat",
33
+ "id": 1,
34
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
35
+ "gravatar_id": "somehexcode",
36
+ "url": "https://api.github.com/users/octocat"
37
+ },
38
+ "comments": 10,
39
+ "commits": 3,
40
+ "additions": 100,
41
+ "deletions": 3,
42
+ "changed_files": 5,
43
+ "head": {
44
+ "label": "new-topic",
45
+ "ref": "new-topic",
46
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
47
+ "user": {
48
+ "login": "octocat",
49
+ "id": 1,
50
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
51
+ "gravatar_id": "somehexcode",
52
+ "url": "https://api.github.com/users/octocat"
53
+ },
54
+ "repo": {
55
+ "url": "https://api.github.com/repos/octocat/Hello-World",
56
+ "html_url": "https://github.com/octocat/Hello-World",
57
+ "clone_url": "https://github.com/octocat/Hello-World.git",
58
+ "git_url": "git://github.com/octocat/Hello-World.git",
59
+ "ssh_url": "git@github.com:octocat/Hello-World.git",
60
+ "svn_url": "https://svn.github.com/octocat/Hello-World",
61
+ "owner": {
62
+ "login": "octocat",
63
+ "id": 1,
64
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
65
+ "gravatar_id": "somehexcode",
66
+ "url": "https://api.github.com/users/octocat"
67
+ },
68
+ "name": "Hello-World",
69
+ "description": "This your first repo!",
70
+ "homepage": "https://github.com",
71
+ "language": null,
72
+ "private": false,
73
+ "fork": false,
74
+ "forks": 9,
75
+ "watchers": 80,
76
+ "size": 108,
77
+ "master_branch": "master",
78
+ "open_issues": 0,
79
+ "pushed_at": "2011-01-26T19:06:43Z",
80
+ "created_at": "2011-01-26T19:01:12Z"
81
+ }
82
+ },
83
+ "base": {
84
+ "label": "master",
85
+ "ref": "master",
86
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
87
+ "user": {
88
+ "login": "octocat",
89
+ "id": 1,
90
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
91
+ "gravatar_id": "somehexcode",
92
+ "url": "https://api.github.com/users/octocat"
93
+ },
94
+ "repo": {
95
+ "url": "https://api.github.com/repos/octocat/Hello-World",
96
+ "html_url": "https://github.com/octocat/Hello-World",
97
+ "clone_url": "https://github.com/octocat/Hello-World.git",
98
+ "git_url": "git://github.com/octocat/Hello-World.git",
99
+ "ssh_url": "git@github.com:octocat/Hello-World.git",
100
+ "svn_url": "https://svn.github.com/octocat/Hello-World",
101
+ "owner": {
102
+ "login": "octocat",
103
+ "id": 1,
104
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
105
+ "gravatar_id": "somehexcode",
106
+ "url": "https://api.github.com/users/octocat"
107
+ },
108
+ "name": "Hello-World",
109
+ "description": "This your first repo!",
110
+ "homepage": "https://github.com",
111
+ "language": null,
112
+ "private": false,
113
+ "fork": false,
114
+ "forks": 9,
115
+ "watchers": 80,
116
+ "size": 108,
117
+ "master_branch": "master",
118
+ "open_issues": 0,
119
+ "pushed_at": "2011-01-26T19:06:43Z",
120
+ "created_at": "2011-01-26T19:01:12Z"
121
+ }
122
+ }
123
+ }
@@ -0,0 +1,31 @@
1
+ [
2
+ {
3
+ "url": "https://api.github.com/octocat/Hello-World/pulls/1",
4
+ "html_url": "https://github.com/octocat/Hello-World/pulls/1",
5
+ "diff_url": "https://github.com/octocat/Hello-World/pulls/1.diff",
6
+ "patch_url": "https://github.com/octocat/Hello-World/pulls/1.patch",
7
+ "issue_url": "https://github.com/octocat/Hello-World/issue/1",
8
+ "number": 1,
9
+ "state": "open",
10
+ "title": "new-feature",
11
+ "body": "Please pull these awesome changes",
12
+ "created_at": "2011-01-26T19:01:12Z",
13
+ "updated_at": "2011-01-26T19:01:12Z",
14
+ "closed_at": "2011-01-26T19:01:12Z",
15
+ "merged_at": "2011-01-26T19:01:12Z",
16
+ "_links": {
17
+ "self": {
18
+ "href": "https://api.github.com/octocat/Hello-World/pulls/1"
19
+ },
20
+ "html": {
21
+ "href": "https://github.com/octocat/Hello-World/pull/1"
22
+ },
23
+ "comments": {
24
+ "href": "https://api.github.com/octocat/Hello-World/issues/1/comments"
25
+ },
26
+ "review_comments": {
27
+ "href": "https://api.github.com/octocat/Hello-World/pulls/1/comments"
28
+ }
29
+ }
30
+ }
31
+ ]
@@ -60,7 +60,7 @@ describe Github::Authorizations do
60
60
  end
61
61
 
62
62
  it "should return 404 with a message 'Not Found'" do
63
- expect { github.oauth.authorizations }.to raise_error(Github::ResourceNotFound)
63
+ expect { github.oauth.authorizations }.to raise_error(Github::Error::NotFound)
64
64
  end
65
65
  end
66
66
  end # authorizations
@@ -104,7 +104,7 @@ describe Github::Authorizations do
104
104
  it "should fail to retrive resource" do
105
105
  expect {
106
106
  github.oauth.authorization authorization_id
107
- }.to raise_error(Github::ResourceNotFound)
107
+ }.to raise_error(Github::Error::NotFound)
108
108
  end
109
109
  end
110
110
  end # authorization
@@ -150,7 +150,7 @@ describe Github::Authorizations do
150
150
  it "should fail to retrieve resource" do
151
151
  expect {
152
152
  github.oauth.create_authorization inputs
153
- }.to raise_error(Github::ResourceNotFound)
153
+ }.to raise_error(Github::Error::NotFound)
154
154
  end
155
155
  end
156
156
  end # create_authorization
@@ -197,7 +197,7 @@ describe Github::Authorizations do
197
197
  it "should fail to retrieve resource" do
198
198
  expect {
199
199
  github.oauth.update_authorization authorization_id, inputs
200
- }.to raise_error(Github::ResourceNotFound)
200
+ }.to raise_error(Github::Error::NotFound)
201
201
  end
202
202
  end
203
203
  end # update_authorization
@@ -234,7 +234,7 @@ describe Github::Authorizations do
234
234
  it "should fail to retrieve resource" do
235
235
  expect {
236
236
  github.oauth.delete_authorization authorization_id
237
- }.to raise_error(Github::ResourceNotFound)
237
+ }.to raise_error(Github::Error::NotFound)
238
238
  end
239
239
  end
240
240
  end # delete_authorization
@@ -48,7 +48,7 @@ describe Github::Events do
48
48
  it "should return 404 with a message 'Not Found'" do
49
49
  expect {
50
50
  github.events.public
51
- }.to raise_error(Github::ResourceNotFound)
51
+ }.to raise_error(Github::Error::NotFound)
52
52
  end
53
53
  end
54
54
  end # public_events
@@ -101,7 +101,7 @@ describe Github::Events do
101
101
  it "should return 404 with a message 'Not Found'" do
102
102
  expect {
103
103
  github.events.repository user, repo
104
- }.to raise_error(Github::ResourceNotFound)
104
+ }.to raise_error(Github::Error::NotFound)
105
105
  end
106
106
  end
107
107
  end # repository
@@ -154,7 +154,7 @@ describe Github::Events do
154
154
  it "should return 404 with a message 'Not Found'" do
155
155
  expect {
156
156
  github.events.issue user, repo
157
- }.to raise_error(Github::ResourceNotFound)
157
+ }.to raise_error(Github::Error::NotFound)
158
158
  end
159
159
  end
160
160
  end # repository
@@ -207,7 +207,7 @@ describe Github::Events do
207
207
  it "should return 404 with a message 'Not Found'" do
208
208
  expect {
209
209
  github.events.network user, repo
210
- }.to raise_error(Github::ResourceNotFound)
210
+ }.to raise_error(Github::Error::NotFound)
211
211
  end
212
212
  end
213
213
  end # network
@@ -260,7 +260,7 @@ describe Github::Events do
260
260
  it "should return 404 with a message 'Not Found'" do
261
261
  expect {
262
262
  github.events.org org
263
- }.to raise_error(Github::ResourceNotFound)
263
+ }.to raise_error(Github::Error::NotFound)
264
264
  end
265
265
  end
266
266
  end # org
@@ -345,7 +345,7 @@ describe Github::Events do
345
345
  it "should return 404 with a message 'Not Found'" do
346
346
  expect {
347
347
  github.events.received user
348
- }.to raise_error(Github::ResourceNotFound)
348
+ }.to raise_error(Github::Error::NotFound)
349
349
  end
350
350
  end
351
351
  end # received
@@ -430,7 +430,7 @@ describe Github::Events do
430
430
  it "should return 404 with a message 'Not Found'" do
431
431
  expect {
432
432
  github.events.performed user
433
- }.to raise_error(Github::ResourceNotFound)
433
+ }.to raise_error(Github::Error::NotFound)
434
434
  end
435
435
  end
436
436
  end # performed
@@ -483,7 +483,7 @@ describe Github::Events do
483
483
  it "should return 404 with a message 'Not Found'" do
484
484
  expect {
485
485
  github.events.user_org user, org
486
- }.to raise_error(Github::ResourceNotFound)
486
+ }.to raise_error(Github::Error::NotFound)
487
487
  end
488
488
  end
489
489
  end # user_org
@@ -59,7 +59,7 @@ describe Github::Gists::Comments, :type => :base do
59
59
  it "should return 404 with a message 'Not Found'" do
60
60
  expect {
61
61
  github.gists.comments gist_id
62
- }.to raise_error(Github::ResourceNotFound)
62
+ }.to raise_error(Github::Error::NotFound)
63
63
  end
64
64
  end
65
65
  end # comments
@@ -110,7 +110,7 @@ describe Github::Gists::Comments, :type => :base do
110
110
  it "should fail to retrive resource" do
111
111
  expect {
112
112
  github.gists.comment comment_id
113
- }.to raise_error(Github::ResourceNotFound)
113
+ }.to raise_error(Github::Error::NotFound)
114
114
  end
115
115
  end
116
116
  end # comment
@@ -162,7 +162,7 @@ describe Github::Gists::Comments, :type => :base do
162
162
  it "should faile to retrieve resource" do
163
163
  expect {
164
164
  github.gists.create_comment gist_id, inputs
165
- }.to raise_error(Github::ResourceNotFound)
165
+ }.to raise_error(Github::Error::NotFound)
166
166
  end
167
167
  end
168
168
  end # create_comment
@@ -214,7 +214,7 @@ describe Github::Gists::Comments, :type => :base do
214
214
  it "should faile to retrieve resource" do
215
215
  expect {
216
216
  github.gists.edit_comment comment_id, inputs
217
- }.to raise_error(Github::ResourceNotFound)
217
+ }.to raise_error(Github::Error::NotFound)
218
218
  end
219
219
  end
220
220
  end # edit_comment
@@ -249,7 +249,7 @@ describe Github::Gists::Comments, :type => :base do
249
249
  it "should faile to retrieve resource" do
250
250
  expect {
251
251
  github.gists.delete_comment comment_id
252
- }.to raise_error(Github::ResourceNotFound)
252
+ }.to raise_error(Github::Error::NotFound)
253
253
  end
254
254
  end
255
255
  end # delete_comment