github_api 0.3.4 → 0.3.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 (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,236 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Repos::Downloads do
4
-
5
- let(:github) { Github.new }
6
- let(:user) { 'peter-murach' }
7
- let(:repo) { 'github' }
8
-
9
- describe "downloads" do
10
- context "resource found" do
11
- before do
12
- stub_get("/repos/#{user}/#{repo}/downloads").
13
- to_return(:body => fixture('repos/downloads.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
14
- end
15
-
16
- it "should fail to get resource without username" do
17
- github.user, github.repo = nil, nil
18
- expect { github.repos.downloads }.to raise_error(ArgumentError)
19
- end
20
-
21
- it "should get the resources" do
22
- github.repos.downloads user, repo
23
- a_get("/repos/#{user}/#{repo}/downloads").should have_been_made
24
- end
25
-
26
- it "should return array of resources" do
27
- downloads = github.repos.downloads user, repo
28
- downloads.should be_an Array
29
- downloads.should have(1).items
30
- end
31
-
32
- it "should be a mash type" do
33
- downloads = github.repos.downloads user, repo
34
- downloads.first.should be_a Hashie::Mash
35
- end
36
-
37
- it "should get download information" do
38
- downloads = github.repos.downloads user, repo
39
- downloads.first.name.should == 'new_file.jpg'
40
- end
41
-
42
- it "should yield to a block" do
43
- github.repos.should_receive(:downloads).with(user, repo).and_yield('web')
44
- github.repos.downloads(user, repo) { |param| 'web' }
45
- end
46
- end
47
-
48
- context "resource not found" do
49
- before do
50
- stub_get("/repos/#{user}/#{repo}/downloads").
51
- to_return(:body => "", :status => [404, "Not Found"])
52
- end
53
-
54
- it "should return 404 with a message 'Not Found'" do
55
- expect {
56
- github.repos.downloads user, repo
57
- }.to raise_error(Github::ResourceNotFound)
58
- end
59
- end
60
- end # downloads
61
-
62
- describe "download" do
63
- let(:download_id) { 1 }
64
-
65
- context "resource found" do
66
- before do
67
- stub_get("/repos/#{user}/#{repo}/downloads/#{download_id}").
68
- to_return(:body => fixture('repos/download.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
69
- end
70
-
71
- it "should fail to get resource without download id" do
72
- expect { github.repos.download(user, repo, nil)}.to raise_error(ArgumentError)
73
- end
74
-
75
- it "should get the resource" do
76
- github.repos.download user, repo, download_id
77
- a_get("/repos/#{user}/#{repo}/downloads/#{download_id}").should have_been_made
78
- end
79
-
80
- it "should get download information" do
81
- download = github.repos.download user, repo, download_id
82
- download.id.should == download_id
83
- download.name.should == 'new_file.jpg'
84
- end
85
-
86
- it "should return mash" do
87
- download = github.repos.download user, repo, download_id
88
- download.should be_a Hashie::Mash
89
- end
90
- end
91
-
92
- context "resource not found" do
93
- before do
94
- stub_get("/repos/#{user}/#{repo}/downloads/#{download_id}").
95
- to_return(:body => fixture('repos/download.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
96
- end
97
-
98
- it "should fail to retrive resource" do
99
- expect {
100
- github.repos.download user, repo, download_id
101
- }.to raise_error(Github::ResourceNotFound)
102
- end
103
- end
104
- end # download
105
-
106
- describe "delete_download" do
107
- let(:download_id) { 1 }
108
-
109
- context "resource edited successfully" do
110
- before do
111
- stub_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").
112
- to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
113
- end
114
-
115
- it "should fail to delete without 'user/repo' parameters" do
116
- github.user, github.repo = nil, nil
117
- expect { github.repos.delete_download }.to raise_error(ArgumentError)
118
- end
119
-
120
- it "should fail to delete resource without 'download_id'" do
121
- expect {
122
- github.repos.delete_download user, repo
123
- }.to raise_error(ArgumentError)
124
- end
125
-
126
- it "should delete the resource" do
127
- github.repos.delete_download user, repo, download_id
128
- a_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").should have_been_made
129
- end
130
- end
131
-
132
- context "failed to edit resource" do
133
- before do
134
- stub_delete("/repos/#{user}/#{repo}/downloads/#{download_id}").
135
- to_return(:body => fixture("repos/download.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
136
-
137
- end
138
-
139
- it "should fail to find resource" do
140
- expect {
141
- github.repos.delete_download user, repo, download_id
142
- }.to raise_error(Github::ResourceNotFound)
143
- end
144
- end
145
- end # delete_download
146
-
147
- describe "create_download" do
148
- let(:inputs) { {:name => 'new_file.jpg', :size => 114034, :description => "Latest release", :content_type => 'text/plain'} }
149
-
150
- context "resouce created" do
151
- before do
152
- stub_post("/repos/#{user}/#{repo}/downloads").with(inputs).
153
- to_return(:body => fixture('repos/download_s3.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
154
-
155
- end
156
-
157
- it "should fail to create resource if 'name' input is missing" do
158
- expect {
159
- github.repos.create_download user, repo, inputs.except(:name)
160
- }.to raise_error(ArgumentError)
161
- end
162
-
163
- it "should failt to create resource if 'size' input is missing" do
164
- expect {
165
- github.repos.create_download user, repo, inputs.except(:size)
166
- }.to raise_error(ArgumentError)
167
- end
168
-
169
- it "should create resource successfully" do
170
- github.repos.create_download user, repo, inputs
171
- a_post("/repos/#{user}/#{repo}/downloads").with(inputs).should have_been_made
172
- end
173
-
174
- it "should return the resource" do
175
- download = github.repos.create_download user, repo, inputs
176
- download.should be_a Hashie::Mash
177
- end
178
-
179
- it "should get the download information" do
180
- download = github.repos.create_download user, repo, inputs
181
- download.name.should == 'new_file.jpg'
182
- end
183
- end
184
-
185
- context "failed to create resource" do
186
- before do
187
- stub_post("/repos/#{user}/#{repo}/downloads").with(inputs).
188
- to_return(:body => fixture('repos/download_s3.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
189
-
190
- end
191
-
192
- it "should faile to retrieve resource" do
193
- expect {
194
- github.repos.create_download(user, repo, inputs)
195
- }.to raise_error(Github::ResourceNotFound)
196
- end
197
- end
198
- end # create_download
199
-
200
- describe 'upload' do
201
- let(:inputs) { {:name => 'new_file.jpg', :size => 114034, :description => "Latest release", :content_type => 'text/plain'} }
202
- let(:resource) { Hashie::Mash.new ::JSON.parse(fixture('repos/download_s3.json').read) }
203
- let(:file) { 'filename' }
204
-
205
- context 'resource uploaded' do
206
- before do
207
- stub_post('', 'https://github.s3.amazonaws.com/').with(resource).
208
- to_return(:body => '', :status => 200, :headers => {})
209
- end
210
-
211
- it "should fail if resource is of incorrect type" do
212
- expect { github.repos.upload file, file }.to raise_error(ArgumentError)
213
- end
214
-
215
- it "should upload resource successfully" do
216
- github.repos.upload resource, file
217
- a_post('', 'https://github.s3.amazonaws.com').with(resource).should have_been_made
218
- end
219
-
220
- end
221
- context 'failed to upload resource' do
222
- before do
223
- stub_post('', 'https://github.s3.amazonaws.com/').with(resource).
224
- to_return(:body => '', :status => 404, :headers => {})
225
- end
226
-
227
- it "should faile to retrieve resource" do
228
- expect {
229
- github.repos.upload resource, file
230
- }.to raise_error(Github::ResourceNotFound)
231
- end
232
-
233
- end
234
- end # upload
235
-
236
- end # Github::Repos::Downloads
@@ -1,103 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Repos::Forks do
4
-
5
- let(:github) { Github.new }
6
- let(:user) { 'peter-murach' }
7
- let(:repo) { 'github' }
8
-
9
- describe "forks" do
10
- context "resource found" do
11
- before do
12
- stub_get("/repos/#{user}/#{repo}/forks").
13
- to_return(:body => fixture('repos/forks.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
14
- end
15
-
16
- it "should fail to get resource without username" do
17
- github.user, github.repo = nil, nil
18
- expect { github.repos.forks }.to raise_error(ArgumentError)
19
- end
20
-
21
- it "should get the resources" do
22
- github.repos.forks user, repo
23
- a_get("/repos/#{user}/#{repo}/forks").should have_been_made
24
- end
25
-
26
- it "should return array of resources" do
27
- forks = github.repos.forks user, repo
28
- forks.should be_an Array
29
- forks.should have(1).items
30
- end
31
-
32
- it "should be a mash type" do
33
- forks = github.repos.forks user, repo
34
- forks.first.should be_a Hashie::Mash
35
- end
36
-
37
- it "should get fork information" do
38
- forks = github.repos.forks user, repo
39
- forks.first.name.should == 'Hello-World'
40
- end
41
-
42
- it "should yield to a block" do
43
- github.repos.should_receive(:forks).with(user, repo).and_yield('web')
44
- github.repos.forks(user, repo) { |param| 'web' }
45
- end
46
- end
47
-
48
- context "resource not found" do
49
- before do
50
- stub_get("/repos/#{user}/#{repo}/forks").
51
- to_return(:body => "", :status => [404, "Not Found"])
52
- end
53
-
54
- it "should return 404 with a message 'Not Found'" do
55
- expect {
56
- github.repos.forks user, repo
57
- }.to raise_error(Github::ResourceNotFound)
58
- end
59
- end
60
- end # forks
61
-
62
- describe "create_hook" do
63
- let(:inputs) { {:org => 'github'} }
64
-
65
- context "resouce created" do
66
- before do
67
- stub_post("/repos/#{user}/#{repo}/forks").with(inputs).
68
- to_return(:body => fixture('repos/fork.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
69
-
70
- end
71
-
72
- it "should create resource successfully" do
73
- github.repos.create_fork(user, repo, inputs)
74
- a_post("/repos/#{user}/#{repo}/forks").with(inputs).should have_been_made
75
- end
76
-
77
- it "should return the resource" do
78
- fork = github.repos.create_fork user, repo, inputs
79
- fork.should be_a Hashie::Mash
80
- end
81
-
82
- it "should get the fork information" do
83
- fork = github.repos.create_fork(user, repo, inputs)
84
- fork.name.should == 'Hello-World'
85
- end
86
- end
87
-
88
- context "failed to create resource" do
89
- before do
90
- stub_post("/repos/#{user}/#{repo}/forks").with(inputs).
91
- to_return(:body => fixture('repos/fork.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
92
-
93
- end
94
-
95
- it "should faile to retrieve resource" do
96
- expect {
97
- github.repos.create_fork user, repo, inputs
98
- }.to raise_error(Github::ResourceNotFound)
99
- end
100
- end
101
- end # create_fork
102
-
103
- end # Github::Repos::Forks
@@ -1,307 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Repos::Hooks do
4
-
5
- let(:github) { Github.new }
6
- let(:user) { 'peter-murach' }
7
- let(:repo) { 'github' }
8
-
9
- describe "hooks" do
10
- context "resource found" do
11
- before do
12
- stub_get("/repos/#{user}/#{repo}/hooks").
13
- to_return(:body => fixture('repos/hooks.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
14
- end
15
-
16
- it "should fail to get resource without username" do
17
- github.user, github.repo = nil, nil
18
- expect { github.repos.hooks }.to raise_error(ArgumentError)
19
- end
20
-
21
- it "should get the resources" do
22
- github.repos.hooks user, repo
23
- a_get("/repos/#{user}/#{repo}/hooks").should have_been_made
24
- end
25
-
26
- it "should return array of resources" do
27
- hooks = github.repos.hooks user, repo
28
- hooks.should be_an Array
29
- hooks.should have(1).items
30
- end
31
-
32
- it "should be a mash type" do
33
- hooks = github.repos.hooks user, repo
34
- hooks.first.should be_a Hashie::Mash
35
- end
36
-
37
- it "should get hook information" do
38
- hooks = github.repos.hooks(user, repo)
39
- hooks.first.name.should == 'web'
40
- end
41
-
42
- it "should yield to a block" do
43
- github.repos.should_receive(:hooks).with(user, repo).and_yield('web')
44
- github.repos.hooks(user, repo) { |param| 'web' }
45
- end
46
- end
47
-
48
- context "resource not found" do
49
- before do
50
- stub_get("/repos/#{user}/#{repo}/hooks").
51
- to_return(:body => "", :status => [404, "Not Found"])
52
- end
53
-
54
- it "should return 404 with a message 'Not Found'" do
55
- expect {
56
- github.repos.hooks user, repo
57
- }.to raise_error(Github::ResourceNotFound)
58
- end
59
- end
60
- end # hooks
61
-
62
- describe "hook" do
63
- let(:hook_id) { 1 }
64
-
65
- context "resource found" do
66
- before do
67
- stub_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").
68
- to_return(:body => fixture('repos/hook.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
69
- end
70
-
71
- it "should fail to get resource without hook id" do
72
- expect { github.repos.hook(user, repo, nil)}.to raise_error(ArgumentError)
73
- end
74
-
75
- it "should get the resource" do
76
- github.repos.hook user, repo, hook_id
77
- a_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
78
- end
79
-
80
- it "should get hook information" do
81
- hook = github.repos.hook user, repo, hook_id
82
- hook.id.should == hook_id
83
- hook.name.should == 'web'
84
- end
85
-
86
- it "should return mash" do
87
- hook = github.repos.hook user, repo, hook_id
88
- hook.should be_a Hashie::Mash
89
- end
90
-
91
- end
92
-
93
- context "resource not found" do
94
- before do
95
- stub_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").
96
- to_return(:body => fixture('repos/hook.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
97
- end
98
-
99
- it "should fail to retrive resource" do
100
- expect {
101
- github.repos.hook(user, repo, hook_id)
102
- }.to raise_error(Github::ResourceNotFound)
103
- end
104
- end
105
- end # hook
106
-
107
- describe "create_hook" do
108
- let(:inputs) { {:name => 'web', :config => {:url => "http://something.com/webhook"}, :active => true}}
109
-
110
- context "resouce created" do
111
- before do
112
- stub_post("/repos/#{user}/#{repo}/hooks").with(inputs).
113
- to_return(:body => fixture('repos/hook.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
114
-
115
- end
116
-
117
- it "should fail to create resource if 'name' input is missing" do
118
- expect {
119
- github.repos.create_hook(user, repo, inputs.except(:name) )
120
- }.to raise_error(ArgumentError)
121
- end
122
-
123
- it "should failt to create resource if 'config' input is missing" do
124
- expect {
125
- github.repos.create_hook(user, repo, inputs.except(:config) )
126
- }.to raise_error(ArgumentError)
127
- end
128
-
129
- it "should create resource successfully" do
130
- github.repos.create_hook(user, repo, inputs)
131
- a_post("/repos/#{user}/#{repo}/hooks").with(inputs).should have_been_made
132
- end
133
-
134
- it "should return the resource" do
135
- hook = github.repos.create_hook user, repo, inputs
136
- hook.should be_a Hashie::Mash
137
- end
138
-
139
- it "should get the hook information" do
140
- hook = github.repos.create_hook(user, repo, inputs)
141
- hook.name.should == 'web'
142
- end
143
- end
144
-
145
- context "failed to create resource" do
146
- before do
147
- stub_post("/repos/#{user}/#{repo}/hooks").with(inputs).
148
- to_return(:body => fixture('repos/hook.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
149
-
150
- end
151
-
152
- it "should faile to retrieve resource" do
153
- expect {
154
- github.repos.create_hook(user, repo, inputs)
155
- }.to raise_error(Github::ResourceNotFound)
156
- end
157
- end
158
- end # create_hook
159
-
160
- describe "edit_hook" do
161
- let(:hook_id) { 1 }
162
- let(:inputs) { {:name => 'web', :config => {:url => "http://something.com/webhook"}, :active => true}}
163
-
164
- context "resource edited successfully" do
165
- before do
166
- stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).
167
- to_return(:body => fixture("repos/hook.json"), :status => 200, :headers => { :content_type => "application/json; charset=utf-8"})
168
- end
169
-
170
- it "should fail to edit without 'user/repo' parameters" do
171
- github.user, github.repo = nil, nil
172
- expect { github.repos.edit_hook }.to raise_error(ArgumentError)
173
- end
174
-
175
- it "should fail to edit resource without 'name' parameter" do
176
- expect{
177
- github.repos.edit_hook user, repo, inputs.except(:name)
178
- }.to raise_error(ArgumentError)
179
- end
180
-
181
- it "should fail to edit resource without 'hook_id'" do
182
- expect {
183
- github.repos.edit_hook user, repo
184
- }.to raise_error(ArgumentError)
185
- end
186
-
187
- it "should fail to edit resource without 'config' parameter" do
188
- expect {
189
- github.repos.edit_hook user, repo, hook_id, inputs.except(:config)
190
- }.to raise_error(ArgumentError)
191
- end
192
-
193
- it "should edit the resource" do
194
- github.repos.edit_hook user, repo, hook_id, inputs
195
- a_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).should have_been_made
196
- end
197
-
198
- it "should return resource" do
199
- hook = github.repos.edit_hook user, repo, hook_id, inputs
200
- hook.should be_a Hashie::Mash
201
- end
202
-
203
- it "should be able to retrieve information" do
204
- hook = github.repos.edit_hook user, repo, hook_id, inputs
205
- hook.name.should == 'web'
206
- end
207
-
208
- end
209
-
210
- context "failed to edit resource" do
211
- before do
212
- stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).
213
- to_return(:body => fixture("repos/hook.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
214
-
215
- end
216
-
217
- it "should fail to find resource" do
218
- expect {
219
- github.repos.edit_hook user, repo, hook_id, inputs
220
- }.to raise_error(Github::ResourceNotFound)
221
- end
222
- end
223
- end # edit_hook
224
-
225
- describe "delete_hook" do
226
- let(:hook_id) { 1 }
227
-
228
- context "resource edited successfully" do
229
- before do
230
- stub_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").
231
- to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
232
- end
233
-
234
- it "should fail to delete without 'user/repo' parameters" do
235
- github.user, github.repo = nil, nil
236
- expect { github.repos.delete_hook }.to raise_error(ArgumentError)
237
- end
238
-
239
- it "should fail to delete resource without 'hook_id'" do
240
- expect {
241
- github.repos.delete_hook user, repo
242
- }.to raise_error(ArgumentError)
243
- end
244
-
245
- it "should delete the resource" do
246
- github.repos.delete_hook user, repo, hook_id
247
- a_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
248
- end
249
- end
250
-
251
- context "failed to edit resource" do
252
- before do
253
- stub_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").
254
- to_return(:body => fixture("repos/hook.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
255
-
256
- end
257
-
258
- it "should fail to find resource" do
259
- expect {
260
- github.repos.delete_hook user, repo, hook_id
261
- }.to raise_error(Github::ResourceNotFound)
262
- end
263
- end
264
- end # delete_hook
265
-
266
- describe "test_hook" do
267
- let(:hook_id) { 1 }
268
-
269
- context "resource edited successfully" do
270
- before do
271
- stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
272
- to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
273
- end
274
-
275
- it "should fail to test without 'user/repo' parameters" do
276
- github.user, github.repo = nil, nil
277
- expect { github.repos.test_hook }.to raise_error(ArgumentError)
278
- end
279
-
280
- it "should fail to test resource without 'hook_id'" do
281
- expect {
282
- github.repos.test_hook user, repo
283
- }.to raise_error(ArgumentError)
284
- end
285
-
286
- it "should trigger test for the resource" do
287
- github.repos.test_hook user, repo, hook_id
288
- a_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").should have_been_made
289
- end
290
- end
291
-
292
- context "failed to test resource" do
293
- before do
294
- stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
295
- to_return(:body => '', :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
296
-
297
- end
298
-
299
- it "should fail to find resource" do
300
- expect {
301
- github.repos.test_hook user, repo, hook_id
302
- }.to raise_error(Github::ResourceNotFound)
303
- end
304
- end
305
- end # test_hook
306
-
307
- end # Github::Repos::Hooks