github_api 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +20 -0
- data/README.rdoc +228 -0
- data/Rakefile +52 -0
- data/features/github_api.feature +50 -0
- data/features/options.feature +4 -0
- data/features/pagination.feature +4 -0
- data/features/step_definitions/github_api_steps.rb +11 -0
- data/features/support/env.rb +13 -0
- data/lib/github_api.rb +73 -0
- data/lib/github_api/api.rb +175 -0
- data/lib/github_api/api/utils.rb +9 -0
- data/lib/github_api/authorization.rb +73 -0
- data/lib/github_api/authorizations.rb +119 -0
- data/lib/github_api/cache_control.rb +19 -0
- data/lib/github_api/client.rb +55 -0
- data/lib/github_api/compatibility.rb +23 -0
- data/lib/github_api/configuration.rb +96 -0
- data/lib/github_api/connection.rb +75 -0
- data/lib/github_api/core_ext/array.rb +14 -0
- data/lib/github_api/core_ext/hash.rb +42 -0
- data/lib/github_api/error.rb +35 -0
- data/lib/github_api/events.rb +202 -0
- data/lib/github_api/gists.rb +200 -0
- data/lib/github_api/gists/comments.rb +86 -0
- data/lib/github_api/git_data.rb +26 -0
- data/lib/github_api/git_data/blobs.rb +51 -0
- data/lib/github_api/git_data/commits.rb +78 -0
- data/lib/github_api/git_data/references.rb +113 -0
- data/lib/github_api/git_data/tags.rb +78 -0
- data/lib/github_api/git_data/trees.rb +89 -0
- data/lib/github_api/issues.rb +215 -0
- data/lib/github_api/issues/comments.rb +123 -0
- data/lib/github_api/issues/events.rb +54 -0
- data/lib/github_api/issues/labels.rb +191 -0
- data/lib/github_api/issues/milestones.rb +140 -0
- data/lib/github_api/mime_type.rb +55 -0
- data/lib/github_api/orgs.rb +95 -0
- data/lib/github_api/orgs/members.rb +120 -0
- data/lib/github_api/orgs/teams.rb +245 -0
- data/lib/github_api/pull_requests.rb +224 -0
- data/lib/github_api/pull_requests/comments.rb +144 -0
- data/lib/github_api/repos.rb +286 -0
- data/lib/github_api/repos/collaborators.rb +81 -0
- data/lib/github_api/repos/commits.rb +180 -0
- data/lib/github_api/repos/downloads.rb +155 -0
- data/lib/github_api/repos/forks.rb +48 -0
- data/lib/github_api/repos/hooks.rb +174 -0
- data/lib/github_api/repos/keys.rb +104 -0
- data/lib/github_api/repos/pub_sub_hubbub.rb +102 -0
- data/lib/github_api/repos/watching.rb +94 -0
- data/lib/github_api/request.rb +84 -0
- data/lib/github_api/request/basic_auth.rb +31 -0
- data/lib/github_api/request/caching.rb +33 -0
- data/lib/github_api/request/oauth2.rb +33 -0
- data/lib/github_api/response.rb +28 -0
- data/lib/github_api/response/helpers.rb +14 -0
- data/lib/github_api/response/jsonize.rb +26 -0
- data/lib/github_api/response/mashify.rb +24 -0
- data/lib/github_api/response/raise_error.rb +33 -0
- data/lib/github_api/result.rb +42 -0
- data/lib/github_api/users.rb +84 -0
- data/lib/github_api/users/emails.rb +49 -0
- data/lib/github_api/users/followers.rb +98 -0
- data/lib/github_api/users/keys.rb +84 -0
- data/lib/github_api/version.rb +12 -0
- data/spec/README.rdoc +22 -0
- data/spec/coverage_adapter.rb +15 -0
- data/spec/fixtures/auths/authorization.json +14 -0
- data/spec/fixtures/auths/authorizations.json +16 -0
- data/spec/fixtures/events/events.json +29 -0
- data/spec/fixtures/issues/comment.json +13 -0
- data/spec/fixtures/issues/comments.json +15 -0
- data/spec/fixtures/issues/event.json +13 -0
- data/spec/fixtures/issues/events.json +15 -0
- data/spec/fixtures/issues/issue.json +56 -0
- data/spec/fixtures/issues/issues.json +58 -0
- data/spec/fixtures/issues/milestone.json +18 -0
- data/spec/fixtures/issues/milestones.json +20 -0
- data/spec/fixtures/orgs/members.json +9 -0
- data/spec/fixtures/orgs/org.json +18 -0
- data/spec/fixtures/orgs/orgs.json +8 -0
- data/spec/fixtures/orgs/team.json +8 -0
- data/spec/fixtures/orgs/team_repos.json +29 -0
- data/spec/fixtures/orgs/teams.json +7 -0
- data/spec/fixtures/repos/branches.json +9 -0
- data/spec/fixtures/repos/collaborators.json +8 -0
- data/spec/fixtures/repos/commit.json +53 -0
- data/spec/fixtures/repos/commit_comment.json +16 -0
- data/spec/fixtures/repos/commit_comments.json +18 -0
- data/spec/fixtures/repos/commits.json +27 -0
- data/spec/fixtures/repos/contributors.json +8 -0
- data/spec/fixtures/repos/download.json +10 -0
- data/spec/fixtures/repos/download_s3.json +21 -0
- data/spec/fixtures/repos/downloads.json +12 -0
- data/spec/fixtures/repos/fork.json +27 -0
- data/spec/fixtures/repos/forks.json +29 -0
- data/spec/fixtures/repos/hook.json +15 -0
- data/spec/fixtures/repos/hooks.json +10 -0
- data/spec/fixtures/repos/key.json +6 -0
- data/spec/fixtures/repos/keys.json +8 -0
- data/spec/fixtures/repos/languages.json +4 -0
- data/spec/fixtures/repos/repo.json +90 -0
- data/spec/fixtures/repos/repo_comments.json +18 -0
- data/spec/fixtures/repos/repos.json +29 -0
- data/spec/fixtures/repos/tags.json +11 -0
- data/spec/fixtures/repos/teams.json +7 -0
- data/spec/fixtures/repos/watched.json +29 -0
- data/spec/fixtures/repos/watchers.json +8 -0
- data/spec/fixtures/users/user.json +32 -0
- data/spec/github/api_spec.rb +25 -0
- data/spec/github/authorization_spec.rb +176 -0
- data/spec/github/authorizations_spec.rb +242 -0
- data/spec/github/client_spec.rb +50 -0
- data/spec/github/core_ext/hash_spec.rb +44 -0
- data/spec/github/events_spec.rb +491 -0
- data/spec/github/gists/comments_spec.rb +5 -0
- data/spec/github/gists_spec.rb +5 -0
- data/spec/github/git_data/blobs_spec.rb +5 -0
- data/spec/github/git_data/commits_spec.rb +5 -0
- data/spec/github/git_data/references_spec.rb +5 -0
- data/spec/github/git_data/tags_spec.rb +5 -0
- data/spec/github/git_data/trees_spec.rb +5 -0
- data/spec/github/git_data_spec.rb +5 -0
- data/spec/github/issues/comments_spec.rb +254 -0
- data/spec/github/issues/events_spec.rb +153 -0
- data/spec/github/issues/labels_spec.rb +5 -0
- data/spec/github/issues/milestones_spec.rb +260 -0
- data/spec/github/issues_spec.rb +287 -0
- data/spec/github/mime_type_spec.rb +70 -0
- data/spec/github/orgs/members_spec.rb +275 -0
- data/spec/github/orgs/teams_spec.rb +563 -0
- data/spec/github/orgs_spec.rb +160 -0
- data/spec/github/repos/collaborators_spec.rb +169 -0
- data/spec/github/repos/commits_spec.rb +424 -0
- data/spec/github/repos/downloads_spec.rb +247 -0
- data/spec/github/repos/forks_spec.rb +108 -0
- data/spec/github/repos/hooks_spec.rb +333 -0
- data/spec/github/repos/keys_spec.rb +217 -0
- data/spec/github/repos/pub_sub_hubbub_spec.rb +83 -0
- data/spec/github/repos/watching_spec.rb +222 -0
- data/spec/github/repos_spec.rb +571 -0
- data/spec/github/result_spec.rb +43 -0
- data/spec/github/users_spec.rb +140 -0
- data/spec/github_spec.rb +109 -0
- data/spec/spec_helper.rb +86 -0
- data/spec/support/base.rb +13 -0
- metadata +149 -4
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Github::Issues::Comments do
|
|
4
|
+
include SpecHelpers::Base
|
|
5
|
+
|
|
6
|
+
let(:comments_api) { Github::Issues::Comments }
|
|
7
|
+
|
|
8
|
+
it { comments_api::VALID_ISSUE_COMMENT_PARAM_NAME.should_not be_nil }
|
|
9
|
+
|
|
10
|
+
describe 'comments' do
|
|
11
|
+
let(:issue_id) { 1 }
|
|
12
|
+
|
|
13
|
+
it { github.issues.should respond_to :comments }
|
|
14
|
+
it { github.issues.should respond_to :issue_comments }
|
|
15
|
+
it { github.issues.should respond_to :list_comments }
|
|
16
|
+
it { github.issues.should respond_to :list_issue_comments }
|
|
17
|
+
|
|
18
|
+
context "resource found" do
|
|
19
|
+
before do
|
|
20
|
+
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
|
|
21
|
+
to_return(:body => fixture('issues/comments.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without username" do
|
|
25
|
+
github.user, github.repo = nil, nil
|
|
26
|
+
expect { github.issues.comments user, repo, nil }.to raise_error(ArgumentError)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should get the resources" do
|
|
30
|
+
github.issues.comments user, repo, issue_id
|
|
31
|
+
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").should have_been_made
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should return array of resources" do
|
|
35
|
+
comments = github.issues.comments user, repo, issue_id
|
|
36
|
+
comments.should be_an Array
|
|
37
|
+
comments.should have(1).items
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should be a mash type" do
|
|
41
|
+
comments = github.issues.comments user, repo, issue_id
|
|
42
|
+
comments.first.should be_a Hashie::Mash
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should get issue comment information" do
|
|
46
|
+
comments = github.issues.comments user, repo, issue_id
|
|
47
|
+
comments.first.user.login.should == 'octocat'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should yield to a block" do
|
|
51
|
+
github.issues.should_receive(:comments).with(user, repo, issue_id).and_yield('web')
|
|
52
|
+
github.issues.comments(user, repo, issue_id) { |param| 'web' }.should == 'web'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "resource not found" do
|
|
57
|
+
before do
|
|
58
|
+
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
|
|
59
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should return 404 with a message 'Not Found'" do
|
|
63
|
+
expect {
|
|
64
|
+
github.issues.comments user, repo, issue_id
|
|
65
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end # comments
|
|
69
|
+
|
|
70
|
+
describe "comment" do
|
|
71
|
+
let(:comment_id) { 1 }
|
|
72
|
+
|
|
73
|
+
it { github.issues.should respond_to :comment }
|
|
74
|
+
it { github.issues.should respond_to :issue_comment }
|
|
75
|
+
it { github.issues.should respond_to :get_comment }
|
|
76
|
+
|
|
77
|
+
context "resource found" do
|
|
78
|
+
before do
|
|
79
|
+
stub_get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
|
|
80
|
+
to_return(:body => fixture('issues/comment.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should fail to get resource without comment id" do
|
|
84
|
+
expect { github.issues.comment(user, repo, nil)}.to raise_error(ArgumentError)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should get the resource" do
|
|
88
|
+
github.issues.comment user, repo, comment_id
|
|
89
|
+
a_get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").should have_been_made
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should get comment information" do
|
|
93
|
+
comment = github.issues.comment user, repo, comment_id
|
|
94
|
+
comment.user.id.should == comment_id
|
|
95
|
+
comment.user.login.should == 'octocat'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should return mash" do
|
|
99
|
+
comment = github.issues.comment user, repo, comment_id
|
|
100
|
+
comment.should be_a Hashie::Mash
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context "resource not found" do
|
|
105
|
+
before do
|
|
106
|
+
stub_get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
|
|
107
|
+
to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "should fail to retrive resource" do
|
|
111
|
+
expect {
|
|
112
|
+
github.issues.comment user, repo, comment_id
|
|
113
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end # comment
|
|
117
|
+
|
|
118
|
+
describe "create_comment" do
|
|
119
|
+
let(:issue_id) { 1 }
|
|
120
|
+
let(:inputs) { { 'body' => 'a new comment' } }
|
|
121
|
+
|
|
122
|
+
it { github.issues.should respond_to :create_comment }
|
|
123
|
+
it { github.issues.should respond_to :create_issue_comment }
|
|
124
|
+
|
|
125
|
+
context "resouce created" do
|
|
126
|
+
before do
|
|
127
|
+
stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(inputs).
|
|
128
|
+
to_return(:body => fixture('issues/comment.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "should fail to create resource if 'body' input is missing" do
|
|
132
|
+
expect {
|
|
133
|
+
github.issues.create_comment user, repo, issue_id, inputs.except('body')
|
|
134
|
+
}.to raise_error(ArgumentError)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "should create resource successfully" do
|
|
138
|
+
github.issues.create_comment user, repo, issue_id, inputs
|
|
139
|
+
a_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(inputs).should have_been_made
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should return the resource" do
|
|
143
|
+
comment = github.issues.create_comment user, repo, issue_id, inputs
|
|
144
|
+
comment.should be_a Hashie::Mash
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "should get the comment information" do
|
|
148
|
+
comment = github.issues.create_comment user, repo, issue_id, inputs
|
|
149
|
+
comment.user.login.should == 'octocat'
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
context "failed to create resource" do
|
|
154
|
+
before do
|
|
155
|
+
stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(inputs).
|
|
156
|
+
to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "should fail to retrieve resource" do
|
|
160
|
+
expect {
|
|
161
|
+
github.issues.create_comment user, repo, issue_id, inputs
|
|
162
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end # create_comment
|
|
166
|
+
|
|
167
|
+
describe "edit_comment" do
|
|
168
|
+
let(:comment_id) { 1 }
|
|
169
|
+
let(:inputs) { { 'body' => 'a new comment' } }
|
|
170
|
+
|
|
171
|
+
it { github.issues.should respond_to :edit_comment }
|
|
172
|
+
it { github.issues.should respond_to :edit_issue_comment }
|
|
173
|
+
|
|
174
|
+
context "resouce edited" do
|
|
175
|
+
before do
|
|
176
|
+
stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).
|
|
177
|
+
to_return(:body => fixture('issues/comment.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "should fail to create resource if 'body' input is missing" do
|
|
181
|
+
expect {
|
|
182
|
+
github.issues.edit_comment user, repo, comment_id, inputs.except('body')
|
|
183
|
+
}.to raise_error(ArgumentError)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "should create resource successfully" do
|
|
187
|
+
github.issues.edit_comment user, repo, comment_id, inputs
|
|
188
|
+
a_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).should have_been_made
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "should return the resource" do
|
|
192
|
+
comment = github.issues.edit_comment user, repo, comment_id, inputs
|
|
193
|
+
comment.should be_a Hashie::Mash
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "should get the comment information" do
|
|
197
|
+
comment = github.issues.edit_comment user, repo, comment_id, inputs
|
|
198
|
+
comment.user.login.should == 'octocat'
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
context "failed to create resource" do
|
|
203
|
+
before do
|
|
204
|
+
stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).
|
|
205
|
+
to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "should fail to retrieve resource" do
|
|
209
|
+
expect {
|
|
210
|
+
github.issues.edit_comment user, repo, comment_id, inputs
|
|
211
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end # edit_comment
|
|
215
|
+
|
|
216
|
+
describe "delete_comment" do
|
|
217
|
+
let(:comment_id) { 1 }
|
|
218
|
+
|
|
219
|
+
it { github.issues.should respond_to :delete_comment }
|
|
220
|
+
it { github.issues.should respond_to :delete_issue_comment }
|
|
221
|
+
|
|
222
|
+
context "resouce deleted" do
|
|
223
|
+
before do
|
|
224
|
+
stub_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
|
|
225
|
+
to_return(:body => fixture('issues/comment.json'), :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "should fail to delete resource if comment_id is missing" do
|
|
229
|
+
expect {
|
|
230
|
+
github.issues.delete_comment user, repo, nil
|
|
231
|
+
}.to raise_error(ArgumentError)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it "should create resource successfully" do
|
|
235
|
+
github.issues.delete_comment user, repo, comment_id
|
|
236
|
+
a_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").should have_been_made
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
context "failed to create resource" do
|
|
241
|
+
before do
|
|
242
|
+
stub_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
|
|
243
|
+
to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it "should fail to retrieve resource" do
|
|
247
|
+
expect {
|
|
248
|
+
github.issues.delete_comment user, repo, comment_id
|
|
249
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
end # delete_comment
|
|
253
|
+
|
|
254
|
+
end # Github::Issues::Comments
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Github::Issues::Events do
|
|
4
|
+
include SpecHelpers::Base
|
|
5
|
+
|
|
6
|
+
describe 'events' do
|
|
7
|
+
it { github.issues.should respond_to :events }
|
|
8
|
+
it { github.issues.should respond_to :list_events }
|
|
9
|
+
it { github.issues.should respond_to :issue_events }
|
|
10
|
+
it { github.issues.should respond_to :repo_events }
|
|
11
|
+
|
|
12
|
+
context 'without issue_id' do
|
|
13
|
+
let(:issue_id) { nil }
|
|
14
|
+
|
|
15
|
+
context "resource found" do
|
|
16
|
+
before do
|
|
17
|
+
stub_get("/repos/#{user}/#{repo}/issues/events").
|
|
18
|
+
to_return(:body => fixture('issues/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should fail to get resource without username" do
|
|
22
|
+
github.user, github.repo = nil, nil
|
|
23
|
+
expect { github.issues.events }.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should get the resources" do
|
|
27
|
+
github.issues.events user, repo, issue_id
|
|
28
|
+
a_get("/repos/#{user}/#{repo}/issues/events").should have_been_made
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return array of resources" do
|
|
32
|
+
events = github.issues.events user, repo, issue_id
|
|
33
|
+
events.should be_an Array
|
|
34
|
+
events.should have(1).items
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should be a mash type" do
|
|
38
|
+
events = github.issues.events user, repo, issue_id
|
|
39
|
+
events.first.should be_a Hashie::Mash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should get issue information" do
|
|
43
|
+
events = github.issues.events user, repo, issue_id
|
|
44
|
+
events.first.actor.login.should == 'octocat'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should yield to a block" do
|
|
48
|
+
github.issues.should_receive(:events).with(user, repo, issue_id).and_yield('web')
|
|
49
|
+
github.issues.events(user, repo, issue_id) { |param| 'web' }.should == 'web'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "resource not found" do
|
|
54
|
+
before do
|
|
55
|
+
stub_get("/repos/#{user}/#{repo}/issues/events").
|
|
56
|
+
to_return(:body => "", :status => [404, "Not Found"])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should return 404 with a message 'Not Found'" do
|
|
60
|
+
expect {
|
|
61
|
+
github.issues.events user, repo, issue_id
|
|
62
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end # without issue_id
|
|
67
|
+
|
|
68
|
+
context 'with issue_id' do
|
|
69
|
+
let(:issue_id) { 123 }
|
|
70
|
+
|
|
71
|
+
context "resource found" do
|
|
72
|
+
before do
|
|
73
|
+
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").
|
|
74
|
+
to_return(:body => fixture('issues/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should get the resources" do
|
|
78
|
+
github.issues.events user, repo, issue_id
|
|
79
|
+
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").should have_been_made
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should return array of resources" do
|
|
83
|
+
events = github.issues.events user, repo, issue_id
|
|
84
|
+
events.should be_an Array
|
|
85
|
+
events.should have(1).items
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should be a mash type" do
|
|
89
|
+
events = github.issues.events user, repo, issue_id
|
|
90
|
+
events.first.should be_a Hashie::Mash
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should get issue information" do
|
|
94
|
+
events = github.issues.events user, repo, issue_id
|
|
95
|
+
events.first.actor.login.should == 'octocat'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should yield to a block" do
|
|
99
|
+
github.issues.should_receive(:events).with(user, repo, issue_id).and_yield('web')
|
|
100
|
+
github.issues.events(user, repo, issue_id) { |param| 'web' }.should == 'web'
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end # with issue_id
|
|
104
|
+
end # events
|
|
105
|
+
|
|
106
|
+
describe "event" do
|
|
107
|
+
let(:event_id) { 1 }
|
|
108
|
+
|
|
109
|
+
it { github.issues.should respond_to :event }
|
|
110
|
+
it { github.issues.should respond_to :get_event }
|
|
111
|
+
|
|
112
|
+
context "resource found" do
|
|
113
|
+
before do
|
|
114
|
+
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
115
|
+
to_return(:body => fixture('issues/event.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should fail to get resource without event id" do
|
|
119
|
+
expect { github.issues.event(user, repo, nil)}.to raise_error(ArgumentError)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should get the resource" do
|
|
123
|
+
github.issues.event user, repo, event_id
|
|
124
|
+
a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").should have_been_made
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should get event information" do
|
|
128
|
+
event = github.issues.event user, repo, event_id
|
|
129
|
+
event.actor.id.should == event_id
|
|
130
|
+
event.actor.login.should == 'octocat'
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should return mash" do
|
|
134
|
+
event = github.issues.event user, repo, event_id
|
|
135
|
+
event.should be_a Hashie::Mash
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "resource not found" do
|
|
140
|
+
before do
|
|
141
|
+
stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
|
|
142
|
+
to_return(:body => fixture('issues/event.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should fail to retrive resource" do
|
|
146
|
+
expect {
|
|
147
|
+
github.issues.event user, repo, event_id
|
|
148
|
+
}.to raise_error(Github::ResourceNotFound)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end # event
|
|
152
|
+
|
|
153
|
+
end # Github::Issues:Events
|