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.
- metadata +4 -140
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -228
- data/Rakefile +0 -52
- data/features/github_api.feature +0 -50
- data/features/step_definitions/github_api_steps.rb +0 -11
- data/features/support/env.rb +0 -13
- data/lib/github_api.rb +0 -73
- data/lib/github_api/api.rb +0 -175
- data/lib/github_api/api/utils.rb +0 -9
- data/lib/github_api/authorization.rb +0 -73
- data/lib/github_api/authorizations.rb +0 -119
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/client.rb +0 -55
- data/lib/github_api/compatibility.rb +0 -23
- data/lib/github_api/configuration.rb +0 -96
- data/lib/github_api/connection.rb +0 -81
- data/lib/github_api/core_ext/array.rb +0 -14
- data/lib/github_api/core_ext/hash.rb +0 -42
- data/lib/github_api/error.rb +0 -35
- data/lib/github_api/events.rb +0 -202
- data/lib/github_api/gists.rb +0 -200
- data/lib/github_api/gists/comments.rb +0 -86
- data/lib/github_api/git_data.rb +0 -26
- data/lib/github_api/git_data/blobs.rb +0 -51
- data/lib/github_api/git_data/commits.rb +0 -78
- data/lib/github_api/git_data/references.rb +0 -113
- data/lib/github_api/git_data/tags.rb +0 -78
- data/lib/github_api/git_data/trees.rb +0 -89
- data/lib/github_api/issues.rb +0 -215
- data/lib/github_api/issues/comments.rb +0 -110
- data/lib/github_api/issues/events.rb +0 -50
- data/lib/github_api/issues/labels.rb +0 -191
- data/lib/github_api/issues/milestones.rb +0 -119
- data/lib/github_api/mime_type.rb +0 -55
- data/lib/github_api/orgs.rb +0 -95
- data/lib/github_api/orgs/members.rb +0 -120
- data/lib/github_api/orgs/teams.rb +0 -245
- data/lib/github_api/pull_requests.rb +0 -224
- data/lib/github_api/pull_requests/comments.rb +0 -144
- data/lib/github_api/repos.rb +0 -286
- data/lib/github_api/repos/collaborators.rb +0 -81
- data/lib/github_api/repos/commits.rb +0 -180
- data/lib/github_api/repos/downloads.rb +0 -155
- data/lib/github_api/repos/forks.rb +0 -48
- data/lib/github_api/repos/hooks.rb +0 -173
- data/lib/github_api/repos/keys.rb +0 -104
- data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
- data/lib/github_api/repos/watching.rb +0 -94
- data/lib/github_api/request.rb +0 -84
- data/lib/github_api/request/basic_auth.rb +0 -31
- data/lib/github_api/request/caching.rb +0 -33
- data/lib/github_api/request/oauth2.rb +0 -33
- data/lib/github_api/response.rb +0 -28
- data/lib/github_api/response/helpers.rb +0 -14
- data/lib/github_api/response/jsonize.rb +0 -26
- data/lib/github_api/response/mashify.rb +0 -24
- data/lib/github_api/response/raise_error.rb +0 -33
- data/lib/github_api/result.rb +0 -42
- data/lib/github_api/users.rb +0 -84
- data/lib/github_api/users/emails.rb +0 -49
- data/lib/github_api/users/followers.rb +0 -98
- data/lib/github_api/users/keys.rb +0 -84
- data/lib/github_api/version.rb +0 -12
- data/spec/README.rdoc +0 -22
- data/spec/coverage_adapter.rb +0 -14
- data/spec/fixtures/auths/authorization.json +0 -14
- data/spec/fixtures/auths/authorizations.json +0 -16
- data/spec/fixtures/events/events.json +0 -29
- data/spec/fixtures/issues/issue.json +0 -56
- data/spec/fixtures/issues/issues.json +0 -58
- data/spec/fixtures/orgs/members.json +0 -9
- data/spec/fixtures/orgs/org.json +0 -18
- data/spec/fixtures/orgs/orgs.json +0 -8
- data/spec/fixtures/orgs/team.json +0 -8
- data/spec/fixtures/orgs/team_repos.json +0 -29
- data/spec/fixtures/orgs/teams.json +0 -7
- data/spec/fixtures/repos/branches.json +0 -9
- data/spec/fixtures/repos/collaborators.json +0 -8
- data/spec/fixtures/repos/commit.json +0 -53
- data/spec/fixtures/repos/commit_comment.json +0 -16
- data/spec/fixtures/repos/commit_comments.json +0 -18
- data/spec/fixtures/repos/commits.json +0 -27
- data/spec/fixtures/repos/contributors.json +0 -8
- data/spec/fixtures/repos/download.json +0 -10
- data/spec/fixtures/repos/download_s3.json +0 -21
- data/spec/fixtures/repos/downloads.json +0 -12
- data/spec/fixtures/repos/fork.json +0 -27
- data/spec/fixtures/repos/forks.json +0 -29
- data/spec/fixtures/repos/hook.json +0 -15
- data/spec/fixtures/repos/hooks.json +0 -10
- data/spec/fixtures/repos/key.json +0 -6
- data/spec/fixtures/repos/keys.json +0 -8
- data/spec/fixtures/repos/languages.json +0 -4
- data/spec/fixtures/repos/repo.json +0 -90
- data/spec/fixtures/repos/repo_comments.json +0 -18
- data/spec/fixtures/repos/repos.json +0 -29
- data/spec/fixtures/repos/tags.json +0 -11
- data/spec/fixtures/repos/teams.json +0 -7
- data/spec/fixtures/repos/watched.json +0 -29
- data/spec/fixtures/repos/watchers.json +0 -8
- data/spec/fixtures/users/user.json +0 -32
- data/spec/github/api_spec.rb +0 -25
- data/spec/github/authorization_spec.rb +0 -176
- data/spec/github/authorizations_spec.rb +0 -242
- data/spec/github/client_spec.rb +0 -50
- data/spec/github/core_ext/hash_spec.rb +0 -44
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/gists/comments_spec.rb +0 -5
- data/spec/github/gists_spec.rb +0 -5
- data/spec/github/git_data/blobs_spec.rb +0 -5
- data/spec/github/git_data/commits_spec.rb +0 -5
- data/spec/github/git_data/references_spec.rb +0 -5
- data/spec/github/git_data/tags_spec.rb +0 -5
- data/spec/github/git_data/trees_spec.rb +0 -5
- data/spec/github/git_data_spec.rb +0 -5
- data/spec/github/issues/comments_spec.rb +0 -5
- data/spec/github/issues/events_spec.rb +0 -5
- data/spec/github/issues/labels_spec.rb +0 -5
- data/spec/github/issues/milestones_spec.rb +0 -5
- data/spec/github/issues_spec.rb +0 -287
- data/spec/github/mime_type_spec.rb +0 -70
- data/spec/github/orgs/members_spec.rb +0 -275
- data/spec/github/orgs/teams_spec.rb +0 -563
- data/spec/github/orgs_spec.rb +0 -160
- data/spec/github/repos/collaborators_spec.rb +0 -169
- data/spec/github/repos/commits_spec.rb +0 -424
- data/spec/github/repos/downloads_spec.rb +0 -236
- data/spec/github/repos/forks_spec.rb +0 -103
- data/spec/github/repos/hooks_spec.rb +0 -307
- data/spec/github/repos/keys_spec.rb +0 -216
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
- data/spec/github/repos/watching_spec.rb +0 -222
- data/spec/github/repos_spec.rb +0 -571
- data/spec/github/result_spec.rb +0 -43
- data/spec/github/users_spec.rb +0 -140
- data/spec/github_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -86
data/spec/github/gists_spec.rb
DELETED
data/spec/github/issues_spec.rb
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe Github::Issues do
|
|
6
|
-
|
|
7
|
-
let(:issues_api) { Github::Issues }
|
|
8
|
-
let(:github) { Github.new }
|
|
9
|
-
let(:user) { 'peter-murach' }
|
|
10
|
-
let(:repo) { 'github' }
|
|
11
|
-
|
|
12
|
-
describe 'modules inclusion' do
|
|
13
|
-
it { issues_api.included_modules.should include Github::Issues::Comments }
|
|
14
|
-
it { issues_api.included_modules.should include Github::Issues::Events }
|
|
15
|
-
it { issues_api.included_modules.should include Github::Issues::Labels }
|
|
16
|
-
it { issues_api.included_modules.should include Github::Issues::Milestones }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe 'issues' do
|
|
20
|
-
it { github.issues.should respond_to :issues }
|
|
21
|
-
it { github.issues.should respond_to :list_issues }
|
|
22
|
-
|
|
23
|
-
context "resource found" do
|
|
24
|
-
before do
|
|
25
|
-
stub_get("/issues").
|
|
26
|
-
to_return(:body => fixture('issues/issues.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should get the resources" do
|
|
30
|
-
github.issues.issues
|
|
31
|
-
a_get("/issues").should have_been_made
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should return array of resources" do
|
|
35
|
-
issues = github.issues.issues
|
|
36
|
-
issues.should be_an Array
|
|
37
|
-
issues.should have(1).items
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should be a mash type" do
|
|
41
|
-
issues = github.issues.issues
|
|
42
|
-
issues.first.should be_a Hashie::Mash
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should get issue information" do
|
|
46
|
-
issues = github.issues.issues
|
|
47
|
-
issues.first.title.should == 'Found a bug'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should yield to a block" do
|
|
51
|
-
github.issues.should_receive(:issues).and_yield('web')
|
|
52
|
-
github.issues.issues { |param| 'web' }.should == 'web'
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "resource not found" do
|
|
57
|
-
before do
|
|
58
|
-
stub_get("/issues").
|
|
59
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should return 404 with a message 'Not Found'" do
|
|
63
|
-
expect { github.issues.issues }.to raise_error(Github::ResourceNotFound)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end # issues
|
|
67
|
-
|
|
68
|
-
describe 'repo_issues' do
|
|
69
|
-
it { github.issues.should respond_to :repo_issues }
|
|
70
|
-
it { github.issues.should respond_to :list_repo_issues }
|
|
71
|
-
it { github.issues.should respond_to :list_repository_issues }
|
|
72
|
-
|
|
73
|
-
context "resource found" do
|
|
74
|
-
before do
|
|
75
|
-
github.user, github.repo = nil, nil
|
|
76
|
-
stub_get("/repos/#{user}/#{repo}/issues").
|
|
77
|
-
to_return(:body => fixture('issues/issues.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should raise error if user-name empty" do
|
|
81
|
-
expect {
|
|
82
|
-
github.issues.repo_issues nil, repo
|
|
83
|
-
}.should raise_error(ArgumentError)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should get the resources" do
|
|
87
|
-
github.issues.repo_issues user, repo
|
|
88
|
-
a_get("/repos/#{user}/#{repo}/issues").should have_been_made
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should return array of resources" do
|
|
92
|
-
repo_issues = github.issues.repo_issues user, repo
|
|
93
|
-
repo_issues.should be_an Array
|
|
94
|
-
repo_issues.should have(1).items
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "should be a mash type" do
|
|
98
|
-
repo_issues = github.issues.repo_issues user, repo
|
|
99
|
-
repo_issues.first.should be_a Hashie::Mash
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "should get repository issue information" do
|
|
103
|
-
repo_issues = github.issues.repo_issues user, repo
|
|
104
|
-
repo_issues.first.title.should == 'Found a bug'
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "should yield to a block" do
|
|
108
|
-
github.issues.should_receive(:issues).with(user, repo).and_yield('web')
|
|
109
|
-
github.issues.issues(user, repo) { |param| 'web' }.should == 'web'
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
context "resource not found" do
|
|
114
|
-
before do
|
|
115
|
-
stub_get("/repos/#{user}/#{repo}/issues").
|
|
116
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should return 404 with a message 'Not Found'" do
|
|
120
|
-
expect {
|
|
121
|
-
github.issues.repo_issues user, repo
|
|
122
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end # repo_issues
|
|
126
|
-
|
|
127
|
-
describe "get_issue" do
|
|
128
|
-
let(:issue_id) { 1347 }
|
|
129
|
-
|
|
130
|
-
it { github.issues.should respond_to :issue }
|
|
131
|
-
it { github.issues.should respond_to :get_issue }
|
|
132
|
-
|
|
133
|
-
context "resource found" do
|
|
134
|
-
before do
|
|
135
|
-
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}").
|
|
136
|
-
to_return(:body => fixture('issues/issue.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "should fail to get resource without issue id" do
|
|
140
|
-
expect { github.issues.issue(user, repo, nil)}.to raise_error(ArgumentError)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "should get the resource" do
|
|
144
|
-
github.issues.issue user, repo, issue_id
|
|
145
|
-
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}").should have_been_made
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "should get issue information" do
|
|
149
|
-
issue = github.issues.issue user, repo, issue_id
|
|
150
|
-
issue.number.should == issue_id
|
|
151
|
-
issue.title.should == 'Found a bug'
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "should return mash" do
|
|
155
|
-
issue = github.issues.issue user, repo, issue_id
|
|
156
|
-
issue.should be_a Hashie::Mash
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
context "resource not found" do
|
|
161
|
-
before do
|
|
162
|
-
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}").
|
|
163
|
-
to_return(:body => fixture('issues/issue.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "should fail to retrive resource" do
|
|
167
|
-
expect {
|
|
168
|
-
github.issues.issue user, repo, issue_id
|
|
169
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end # get_issue
|
|
173
|
-
|
|
174
|
-
describe "create_issue" do
|
|
175
|
-
let(:inputs) {
|
|
176
|
-
{
|
|
177
|
-
"title" => "Found a bug",
|
|
178
|
-
"body" => "I'm having a problem with this.",
|
|
179
|
-
"assignee" => "octocat",
|
|
180
|
-
"milestone" => 1,
|
|
181
|
-
"labels" => [
|
|
182
|
-
"Label1",
|
|
183
|
-
"Label2"
|
|
184
|
-
]
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
context "resouce created" do
|
|
188
|
-
before do
|
|
189
|
-
stub_post("/repos/#{user}/#{repo}/issues").with(inputs).
|
|
190
|
-
to_return(:body => fixture('issues/issue.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it "should fail to create resource if 'title' input is missing" do
|
|
194
|
-
expect {
|
|
195
|
-
github.issues.create_issue user, repo, inputs.except('title')
|
|
196
|
-
}.to raise_error(ArgumentError)
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it "should create resource successfully" do
|
|
200
|
-
github.issues.create_issue user, repo, inputs
|
|
201
|
-
a_post("/repos/#{user}/#{repo}/issues").with(inputs).should have_been_made
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it "should return the resource" do
|
|
205
|
-
issue = github.issues.create_issue user, repo, inputs
|
|
206
|
-
issue.should be_a Hashie::Mash
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "should get the issue information" do
|
|
210
|
-
issue = github.issues.create_issue(user, repo, inputs)
|
|
211
|
-
issue.title.should == 'Found a bug'
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
context "failed to create resource" do
|
|
216
|
-
before do
|
|
217
|
-
stub_post("/repos/#{user}/#{repo}/issues").with(inputs).
|
|
218
|
-
to_return(:body => fixture('issues/issue.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "should faile to retrieve resource" do
|
|
222
|
-
expect {
|
|
223
|
-
github.issues.create_issue user, repo, inputs
|
|
224
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end # create_issue
|
|
228
|
-
|
|
229
|
-
describe "edit_issue" do
|
|
230
|
-
let(:issue_id) { 1349 }
|
|
231
|
-
let(:inputs) {
|
|
232
|
-
{
|
|
233
|
-
"title" => "Found a bug",
|
|
234
|
-
"body" => "I'm having a problem with this.",
|
|
235
|
-
"assignee" => "octocat",
|
|
236
|
-
"milestone" => 1,
|
|
237
|
-
"labels" => [
|
|
238
|
-
"Label1",
|
|
239
|
-
"Label2"
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
context "resource edited successfully" do
|
|
245
|
-
before do
|
|
246
|
-
stub_patch("/repos/#{user}/#{repo}/issues/#{issue_id}").with(inputs).
|
|
247
|
-
to_return(:body => fixture("issues/issue.json"), :status => 200, :headers => { :content_type => "application/json; charset=utf-8"})
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it "should fail to edit without 'user/repo' parameters" do
|
|
251
|
-
github.user, github.repo = nil, nil
|
|
252
|
-
expect {
|
|
253
|
-
github.issues.edit_issue nil, repo, issue_id
|
|
254
|
-
}.to raise_error(ArgumentError)
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
it "should edit the resource" do
|
|
258
|
-
github.issues.edit_issue user, repo, issue_id, inputs
|
|
259
|
-
a_patch("/repos/#{user}/#{repo}/issues/#{issue_id}").with(inputs).should have_been_made
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
it "should return resource" do
|
|
263
|
-
issue = github.issues.edit_issue user, repo, issue_id, inputs
|
|
264
|
-
issue.should be_a Hashie::Mash
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
it "should be able to retrieve information" do
|
|
268
|
-
issue = github.issues.edit_issue user, repo, issue_id, inputs
|
|
269
|
-
issue.title.should == 'Found a bug'
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
context "failed to edit resource" do
|
|
274
|
-
before do
|
|
275
|
-
stub_patch("/repos/#{user}/#{repo}/issues/#{issue_id}").with(inputs).
|
|
276
|
-
to_return(:body => fixture("issues/issue.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
it "should fail to find resource" do
|
|
280
|
-
expect {
|
|
281
|
-
github.issues.edit_issue user, repo, issue_id, inputs
|
|
282
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
end # edit_issue
|
|
286
|
-
|
|
287
|
-
end # Github::Issues
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Github::MimeType do
|
|
4
|
-
|
|
5
|
-
let(:github) { Github.new }
|
|
6
|
-
|
|
7
|
-
it "should lookup mime type for :full" do
|
|
8
|
-
github.lookup_mime(:full).should == 'full+json'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should lookup mime type for :html" do
|
|
12
|
-
github.lookup_mime(:html).should == 'html+json'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should lookup mime type for :html" do
|
|
16
|
-
github.lookup_mime(:text).should == 'text+json'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should lookup mime type for :raw" do
|
|
20
|
-
github.lookup_mime(:raw).should == 'raw+json'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should default to json if no parameters given" do
|
|
24
|
-
Github.should_receive(:parse).and_return 'application/json'
|
|
25
|
-
Github.parse.should == 'application/json'
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should accept header for 'issue' request" do
|
|
29
|
-
Github.should_receive(:parse).with(:issue, :full).
|
|
30
|
-
and_return 'application/vnd.github-issue.full+json'
|
|
31
|
-
Github.parse(:issue, :full).should == 'application/vnd.github-issue.full+json'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should accept header for 'isssue comment' request" do
|
|
35
|
-
Github.should_receive(:parse).with(:issue_comment, :full).
|
|
36
|
-
and_return 'application/vnd.github-issuecomment.full+json'
|
|
37
|
-
Github.parse(:issue_comment, :full).should == 'application/vnd.github-issuecomment.full+json'
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should accept header for 'commit comment' request" do
|
|
41
|
-
Github.should_receive(:parse).with(:commit_comment, :full).
|
|
42
|
-
and_return 'application/vnd.github-commitcomment.full+json'
|
|
43
|
-
Github.parse(:commit_comment, :full).should == 'application/vnd.github-commitcomment.full+json'
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should accept header for 'pull requst' request" do
|
|
47
|
-
Github.should_receive(:parse).with(:pull_request, :full).
|
|
48
|
-
and_return 'application/vnd.github-pull.full+json'
|
|
49
|
-
Github.parse(:pull_request, :full).should == 'application/vnd.github-pull.full+json'
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should accept header for 'pull comment' request" do
|
|
53
|
-
Github.should_receive(:parse).with(:pull_comment, :full).
|
|
54
|
-
and_return 'application/vnd.github-pullcomment.full+json'
|
|
55
|
-
Github.parse(:pull_comment, :full).should == 'application/vnd.github-pullcomment.full+json'
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should accept header for 'gist comment' request" do
|
|
59
|
-
Github.should_receive(:parse).with(:gist_comment, :full).
|
|
60
|
-
and_return 'application/vnd.github-gistcomment.full+json'
|
|
61
|
-
Github.parse(:gist_comment, :full).should == 'application/vnd.github-gistcomment.full+json'
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should accept header for 'blog' request" do
|
|
65
|
-
Github.should_receive(:parse).with(:blob, :blob).
|
|
66
|
-
and_return 'application/vnd.github-blob.raw'
|
|
67
|
-
Github.parse(:blob, :blob).should == 'application/vnd.github-blob.raw'
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
end # Github::MimeType
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Github::Orgs::Members do
|
|
4
|
-
|
|
5
|
-
let(:github) { Github.new }
|
|
6
|
-
let(:member) { 'peter-murach' }
|
|
7
|
-
let(:org) { 'github' }
|
|
8
|
-
|
|
9
|
-
describe "members" do
|
|
10
|
-
context "resource found" do
|
|
11
|
-
before do
|
|
12
|
-
stub_get("/orgs/#{org}/members").
|
|
13
|
-
to_return(:body => fixture('orgs/members.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should fail to get resource without org name" do
|
|
17
|
-
expect { github.orgs.members }.to raise_error(ArgumentError)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should get the resources" do
|
|
21
|
-
github.orgs.members org
|
|
22
|
-
a_get("/orgs/#{org}/members").should have_been_made
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should return array of resources" do
|
|
26
|
-
members = github.orgs.members org
|
|
27
|
-
members.should be_an Array
|
|
28
|
-
members.should have(1).items
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should be a mash type" do
|
|
32
|
-
members = github.orgs.members org
|
|
33
|
-
members.first.should be_a Hashie::Mash
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "should get members information" do
|
|
37
|
-
members = github.orgs.members org
|
|
38
|
-
members.first.login.should == 'octocat'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should yield to a block" do
|
|
42
|
-
github.orgs.should_receive(:members).with(org).and_yield('web')
|
|
43
|
-
github.orgs.members(org) { |param| 'web' }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context "resource not found" do
|
|
48
|
-
before do
|
|
49
|
-
stub_get("/orgs/#{org}/members").
|
|
50
|
-
to_return(:body => fixture('orgs/members.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "should return 404 with a message 'Not Found'" do
|
|
54
|
-
expect {
|
|
55
|
-
github.orgs.members org
|
|
56
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end # members
|
|
60
|
-
|
|
61
|
-
describe "member?" do
|
|
62
|
-
|
|
63
|
-
context "with username ane reponame passed" do
|
|
64
|
-
|
|
65
|
-
context "this repo is being watched by the user"
|
|
66
|
-
before do
|
|
67
|
-
github.oauth_token = nil
|
|
68
|
-
github.user = nil
|
|
69
|
-
stub_get("/orgs/#{org}/members/#{member}").
|
|
70
|
-
to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should return false if resource not found" do
|
|
74
|
-
membership = github.orgs.member? org, member
|
|
75
|
-
membership.should be_false
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "should return true if resoure found" do
|
|
79
|
-
stub_get("/orgs/#{org}/members/#{member}").
|
|
80
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
|
81
|
-
membership = github.orgs.member? org, member
|
|
82
|
-
membership.should be_true
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
context "without org name and member name passed" do
|
|
88
|
-
it "should fail validation " do
|
|
89
|
-
expect { github.orgs.member?(nil, nil) }.to raise_error(ArgumentError)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end # member?
|
|
93
|
-
|
|
94
|
-
describe "public_members" do
|
|
95
|
-
context "resource found" do
|
|
96
|
-
before do
|
|
97
|
-
stub_get("/orgs/#{org}/public_members").
|
|
98
|
-
to_return(:body => fixture('orgs/members.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it "should fail to get resource without org name" do
|
|
102
|
-
expect { github.orgs.public_members }.to raise_error(ArgumentError)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it "should get the resources" do
|
|
106
|
-
github.orgs.public_members org
|
|
107
|
-
a_get("/orgs/#{org}/public_members").should have_been_made
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should return array of resources" do
|
|
111
|
-
public_members = github.orgs.public_members org
|
|
112
|
-
public_members.should be_an Array
|
|
113
|
-
public_members.should have(1).items
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "should be a mash type" do
|
|
117
|
-
public_members = github.orgs.public_members org
|
|
118
|
-
public_members.first.should be_a Hashie::Mash
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "should get public_members information" do
|
|
122
|
-
public_members = github.orgs.public_members org
|
|
123
|
-
public_members.first.login.should == 'octocat'
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "should yield to a block" do
|
|
127
|
-
github.orgs.should_receive(:public_members).with(org).and_yield('web')
|
|
128
|
-
github.orgs.public_members(org) { |param| 'web' }
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context "resource not found" do
|
|
133
|
-
before do
|
|
134
|
-
stub_get("/orgs/#{org}/public_members").
|
|
135
|
-
to_return(:body => fixture('orgs/members.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "should return 404 with a message 'Not Found'" do
|
|
139
|
-
expect {
|
|
140
|
-
github.orgs.public_members org
|
|
141
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end # public_members
|
|
145
|
-
|
|
146
|
-
describe "public_member?" do
|
|
147
|
-
|
|
148
|
-
context "with username ane reponame passed" do
|
|
149
|
-
|
|
150
|
-
context "this repo is being watched by the user"
|
|
151
|
-
before do
|
|
152
|
-
github.oauth_token = nil
|
|
153
|
-
github.user = nil
|
|
154
|
-
stub_get("/orgs/#{org}/public_members/#{member}").
|
|
155
|
-
to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "should return false if resource not found" do
|
|
159
|
-
public_member = github.orgs.public_member? org, member
|
|
160
|
-
public_member.should be_false
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "should return true if resoure found" do
|
|
164
|
-
stub_get("/orgs/#{org}/public_members/#{member}").
|
|
165
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
|
166
|
-
public_member = github.orgs.public_member? org, member
|
|
167
|
-
public_member.should be_true
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
context "without org name and member name passed" do
|
|
173
|
-
it "should fail validation " do
|
|
174
|
-
expect { github.orgs.public_member?(nil, nil) }.to raise_error(ArgumentError)
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
end # public_member?
|
|
178
|
-
|
|
179
|
-
describe "publicize" do
|
|
180
|
-
context "request perfomed successfully" do
|
|
181
|
-
before do
|
|
182
|
-
stub_put("/orgs/#{org}/public_members/#{member}").
|
|
183
|
-
to_return(:body => fixture('orgs/members.json'), :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it "should fail to get resource without org name" do
|
|
187
|
-
expect { github.orgs.publicize }.to raise_error(ArgumentError)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
it "should get the resources" do
|
|
191
|
-
github.orgs.publicize org, member
|
|
192
|
-
a_put("/orgs/#{org}/public_members/#{member}").should have_been_made
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
context "resource not found" do
|
|
197
|
-
before do
|
|
198
|
-
stub_put("/orgs/#{org}/public_members/#{member}").
|
|
199
|
-
to_return(:body => fixture('orgs/members.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it "should return 404 with a message 'Not Found'" do
|
|
203
|
-
expect {
|
|
204
|
-
github.orgs.publicize org, member
|
|
205
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end # publicize
|
|
209
|
-
|
|
210
|
-
describe "conceal" do
|
|
211
|
-
context "request perfomed successfully" do
|
|
212
|
-
before do
|
|
213
|
-
stub_delete("/orgs/#{org}/public_members/#{member}").
|
|
214
|
-
to_return(:body => fixture('orgs/members.json'), :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
it "should fail to get resource without org name" do
|
|
218
|
-
expect { github.orgs.conceal nil, nil }.to raise_error(ArgumentError)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "should get the resources" do
|
|
222
|
-
github.orgs.conceal org, member
|
|
223
|
-
a_delete("/orgs/#{org}/public_members/#{member}").should have_been_made
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
context "resource not found" do
|
|
228
|
-
before do
|
|
229
|
-
stub_delete("/orgs/#{org}/public_members/#{member}").
|
|
230
|
-
to_return(:body => fixture('orgs/members.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
it "should return 404 with a message 'Not Found'" do
|
|
234
|
-
expect {
|
|
235
|
-
github.orgs.conceal org, member
|
|
236
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
end # conceal
|
|
240
|
-
|
|
241
|
-
describe "delete_member" do
|
|
242
|
-
let(:hook_id) { 1 }
|
|
243
|
-
|
|
244
|
-
context "resource deleted successfully" do
|
|
245
|
-
before do
|
|
246
|
-
stub_delete("/orgs/#{org}/members/#{member}").
|
|
247
|
-
to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it "should fail to delete without org and member parameters" do
|
|
251
|
-
expect { github.repos.delete_hook nil, nil }.to raise_error(ArgumentError)
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it "should delete the resource" do
|
|
255
|
-
github.orgs.delete_member org, member
|
|
256
|
-
a_delete("/orgs/#{org}/members/#{member}").should have_been_made
|
|
257
|
-
end
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
context "failed to edit resource" do
|
|
261
|
-
before do
|
|
262
|
-
stub_delete("/orgs/#{org}/members/#{member}").
|
|
263
|
-
to_return(:body => '', :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
|
|
264
|
-
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
it "should fail to find resource" do
|
|
268
|
-
expect {
|
|
269
|
-
github.orgs.delete_member org, member
|
|
270
|
-
}.to raise_error(Github::ResourceNotFound)
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end # delete_member
|
|
274
|
-
|
|
275
|
-
end # Github::Orgs::Members
|