github_api 0.4.11 → 0.5.0.rc1
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/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
|
@@ -7,50 +7,53 @@ describe Github::Issues::Milestones do
|
|
|
7
7
|
let(:user) { 'peter-murach' }
|
|
8
8
|
let(:repo) { 'github' }
|
|
9
9
|
|
|
10
|
-
after {
|
|
10
|
+
after { reset_authentication_for github }
|
|
11
11
|
|
|
12
12
|
it { described_class::VALID_MILESTONE_OPTIONS.should_not be_nil }
|
|
13
13
|
it { described_class::VALID_MILESTONE_INPUTS.should_not be_nil }
|
|
14
14
|
|
|
15
|
-
describe '
|
|
16
|
-
it { github.issues.should respond_to :
|
|
17
|
-
it { github.issues.should respond_to :list_milestones }
|
|
15
|
+
describe '#list' do
|
|
16
|
+
it { github.issues.milestones.should respond_to :all }
|
|
18
17
|
|
|
19
18
|
context "resource found" do
|
|
20
19
|
before do
|
|
21
20
|
stub_get("/repos/#{user}/#{repo}/milestones").
|
|
22
|
-
to_return(:body => fixture('issues/milestones.json'),
|
|
21
|
+
to_return(:body => fixture('issues/milestones.json'),
|
|
22
|
+
:status => 200,
|
|
23
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
it "should fail to get resource without username" do
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
expect {
|
|
28
|
+
github.issues.milestones.list nil, repo
|
|
29
|
+
}.to raise_error(ArgumentError)
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
it "should get the resources" do
|
|
31
|
-
github.issues.milestones user, repo
|
|
33
|
+
github.issues.milestones.list user, repo
|
|
32
34
|
a_get("/repos/#{user}/#{repo}/milestones").should have_been_made
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
it "should return array of resources" do
|
|
36
|
-
milestones = github.issues.milestones user, repo
|
|
38
|
+
milestones = github.issues.milestones.list user, repo
|
|
37
39
|
milestones.should be_an Array
|
|
38
40
|
milestones.should have(1).items
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
it "should be a mash type" do
|
|
42
|
-
milestones = github.issues.milestones user, repo
|
|
44
|
+
milestones = github.issues.milestones.list user, repo
|
|
43
45
|
milestones.first.should be_a Hashie::Mash
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
it "should get issue information" do
|
|
47
|
-
milestones = github.issues.milestones user, repo
|
|
49
|
+
milestones = github.issues.milestones.list user, repo
|
|
48
50
|
milestones.first.title.should == 'v1.0'
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
it "should yield to a block" do
|
|
52
|
-
github.issues.should_receive(:
|
|
53
|
-
|
|
54
|
+
github.issues.milestones.should_receive(:list).
|
|
55
|
+
with(user, repo).and_yield('web')
|
|
56
|
+
github.issues.milestones.list(user, repo) { |param| 'web' }.should == 'web'
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
|
|
@@ -62,41 +65,44 @@ describe Github::Issues::Milestones do
|
|
|
62
65
|
|
|
63
66
|
it "should return 404 with a message 'Not Found'" do
|
|
64
67
|
expect {
|
|
65
|
-
github.issues.milestones user, repo
|
|
68
|
+
github.issues.milestones.list user, repo
|
|
66
69
|
}.to raise_error(Github::Error::NotFound)
|
|
67
70
|
end
|
|
68
71
|
end
|
|
69
|
-
end #
|
|
72
|
+
end # list
|
|
70
73
|
|
|
71
|
-
describe "
|
|
74
|
+
describe "#get" do
|
|
72
75
|
let(:milestone_id) { 1 }
|
|
73
76
|
|
|
74
|
-
it { github.issues.should respond_to :
|
|
75
|
-
it { github.issues.should respond_to :get_milestone }
|
|
77
|
+
it { github.issues.milestones.should respond_to :find }
|
|
76
78
|
|
|
77
79
|
context "resource found" do
|
|
78
80
|
before do
|
|
79
81
|
stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
80
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
82
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
83
|
+
:status => 200,
|
|
84
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
81
85
|
end
|
|
82
86
|
|
|
83
87
|
it "should fail to get resource without milestone id" do
|
|
84
|
-
expect {
|
|
88
|
+
expect {
|
|
89
|
+
github.issues.milestones.get user, repo, nil
|
|
90
|
+
}.to raise_error(ArgumentError)
|
|
85
91
|
end
|
|
86
92
|
|
|
87
93
|
it "should get the resource" do
|
|
88
|
-
github.issues.
|
|
94
|
+
github.issues.milestones.get user, repo, milestone_id
|
|
89
95
|
a_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").should have_been_made
|
|
90
96
|
end
|
|
91
97
|
|
|
92
98
|
it "should get milestone information" do
|
|
93
|
-
milestone = github.issues.
|
|
99
|
+
milestone = github.issues.milestones.get user, repo, milestone_id
|
|
94
100
|
milestone.number.should == milestone_id
|
|
95
101
|
milestone.title.should == 'v1.0'
|
|
96
102
|
end
|
|
97
103
|
|
|
98
104
|
it "should return mash" do
|
|
99
|
-
milestone = github.issues.
|
|
105
|
+
milestone = github.issues.milestones.get user, repo, milestone_id
|
|
100
106
|
milestone.should be_a Hashie::Mash
|
|
101
107
|
end
|
|
102
108
|
end
|
|
@@ -104,16 +110,18 @@ describe Github::Issues::Milestones do
|
|
|
104
110
|
context "resource not found" do
|
|
105
111
|
before do
|
|
106
112
|
stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
107
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
113
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
114
|
+
:status => 404,
|
|
115
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
108
116
|
end
|
|
109
117
|
|
|
110
118
|
it "should fail to retrive resource" do
|
|
111
119
|
expect {
|
|
112
|
-
github.issues.
|
|
120
|
+
github.issues.milestones.get user, repo, milestone_id
|
|
113
121
|
}.to raise_error(Github::Error::NotFound)
|
|
114
122
|
end
|
|
115
123
|
end
|
|
116
|
-
end #
|
|
124
|
+
end # get
|
|
117
125
|
|
|
118
126
|
describe "create_milestone" do
|
|
119
127
|
let(:inputs) {
|
|
@@ -128,27 +136,29 @@ describe Github::Issues::Milestones do
|
|
|
128
136
|
context "resouce created" do
|
|
129
137
|
before do
|
|
130
138
|
stub_post("/repos/#{user}/#{repo}/milestones").with(inputs).
|
|
131
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
139
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
140
|
+
:status => 201,
|
|
141
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
132
142
|
end
|
|
133
143
|
|
|
134
144
|
it "should fail to create resource if 'title' input is missing" do
|
|
135
145
|
expect {
|
|
136
|
-
github.issues.
|
|
146
|
+
github.issues.milestones.create user, repo, inputs.except('title')
|
|
137
147
|
}.to raise_error(Github::Error::RequiredParams)
|
|
138
148
|
end
|
|
139
149
|
|
|
140
150
|
it "should create resource successfully" do
|
|
141
|
-
github.issues.
|
|
151
|
+
github.issues.milestones.create user, repo, inputs
|
|
142
152
|
a_post("/repos/#{user}/#{repo}/milestones").with(inputs).should have_been_made
|
|
143
153
|
end
|
|
144
154
|
|
|
145
155
|
it "should return the resource" do
|
|
146
|
-
milestone = github.issues.
|
|
156
|
+
milestone = github.issues.milestones.create user, repo, inputs
|
|
147
157
|
milestone.should be_a Hashie::Mash
|
|
148
158
|
end
|
|
149
159
|
|
|
150
160
|
it "should get the milestone information" do
|
|
151
|
-
milestone = github.issues.
|
|
161
|
+
milestone = github.issues.milestones.create user, repo, inputs
|
|
152
162
|
milestone.title.should == 'v1.0'
|
|
153
163
|
end
|
|
154
164
|
end
|
|
@@ -156,19 +166,21 @@ describe Github::Issues::Milestones do
|
|
|
156
166
|
context "failed to create resource" do
|
|
157
167
|
before do
|
|
158
168
|
stub_post("/repos/#{user}/#{repo}/milestones").with(inputs).
|
|
159
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
169
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
170
|
+
:status => 404,
|
|
171
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
160
172
|
|
|
161
173
|
end
|
|
162
174
|
|
|
163
175
|
it "should faile to retrieve resource" do
|
|
164
176
|
expect {
|
|
165
|
-
github.issues.
|
|
177
|
+
github.issues.milestones.create user, repo, inputs
|
|
166
178
|
}.to raise_error(Github::Error::NotFound)
|
|
167
179
|
end
|
|
168
180
|
end
|
|
169
|
-
end #
|
|
181
|
+
end # create
|
|
170
182
|
|
|
171
|
-
describe "
|
|
183
|
+
describe "#update" do
|
|
172
184
|
let(:milestone_id) { 1 }
|
|
173
185
|
let(:inputs) {
|
|
174
186
|
{
|
|
@@ -181,68 +193,76 @@ describe Github::Issues::Milestones do
|
|
|
181
193
|
|
|
182
194
|
context "resouce updated" do
|
|
183
195
|
before do
|
|
184
|
-
stub_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
196
|
+
stub_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
197
|
+
with(inputs).
|
|
185
198
|
to_return(:body => fixture('issues/milestone.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
186
199
|
end
|
|
187
200
|
|
|
188
201
|
it "should fail to create resource if 'title' input is missing" do
|
|
189
202
|
expect {
|
|
190
|
-
github.issues.
|
|
203
|
+
github.issues.milestones.update user, repo, milestone_id, inputs.except('title')
|
|
191
204
|
}.to raise_error(Github::Error::RequiredParams)
|
|
192
205
|
end
|
|
193
206
|
|
|
194
207
|
it "should update resource successfully" do
|
|
195
|
-
github.issues.
|
|
196
|
-
a_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
208
|
+
github.issues.milestones.update user, repo, milestone_id, inputs
|
|
209
|
+
a_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
210
|
+
with(inputs).should have_been_made
|
|
197
211
|
end
|
|
198
212
|
|
|
199
213
|
it "should return the resource" do
|
|
200
|
-
milestone = github.issues.
|
|
214
|
+
milestone = github.issues.milestones.update user, repo, milestone_id, inputs
|
|
201
215
|
milestone.should be_a Hashie::Mash
|
|
202
216
|
end
|
|
203
217
|
|
|
204
218
|
it "should get the milestone information" do
|
|
205
|
-
milestone = github.issues.
|
|
219
|
+
milestone = github.issues.milestones.update user, repo, milestone_id, inputs
|
|
206
220
|
milestone.title.should == 'v1.0'
|
|
207
221
|
end
|
|
208
222
|
end
|
|
209
223
|
|
|
210
224
|
context "failed to create resource" do
|
|
211
225
|
before do
|
|
212
|
-
stub_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
213
|
-
|
|
226
|
+
stub_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
227
|
+
with(inputs).
|
|
228
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
229
|
+
:status => 404,
|
|
230
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
214
231
|
|
|
215
232
|
end
|
|
216
233
|
|
|
217
234
|
it "should faile to retrieve resource" do
|
|
218
235
|
expect {
|
|
219
|
-
github.issues.
|
|
236
|
+
github.issues.milestones.update user, repo, milestone_id, inputs
|
|
220
237
|
}.to raise_error(Github::Error::NotFound)
|
|
221
238
|
end
|
|
222
239
|
end
|
|
223
|
-
end #
|
|
240
|
+
end # update
|
|
224
241
|
|
|
225
|
-
describe "
|
|
242
|
+
describe "#delete" do
|
|
226
243
|
let(:milestone_id) { 1 }
|
|
227
244
|
|
|
228
245
|
context "resouce removed" do
|
|
229
246
|
before do
|
|
230
247
|
stub_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
231
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
248
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
249
|
+
:status => 201,
|
|
250
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
232
251
|
end
|
|
233
252
|
|
|
234
253
|
it "should remove resource successfully" do
|
|
235
|
-
github.issues.
|
|
236
|
-
a_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
254
|
+
github.issues.milestones.delete user, repo, milestone_id
|
|
255
|
+
a_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
256
|
+
should have_been_made
|
|
237
257
|
end
|
|
238
258
|
|
|
239
259
|
it "should return the resource" do
|
|
240
|
-
milestone = github.issues.
|
|
260
|
+
milestone = github.issues.milestones.delete user, repo, milestone_id
|
|
241
261
|
milestone.should be_a Hashie::Mash
|
|
242
262
|
end
|
|
243
263
|
|
|
244
264
|
it "should get the milestone information" do
|
|
245
|
-
milestone = github.issues.
|
|
265
|
+
milestone = github.issues.milestones.delete user, repo, milestone_id
|
|
246
266
|
milestone.title.should == 'v1.0'
|
|
247
267
|
end
|
|
248
268
|
end
|
|
@@ -250,15 +270,17 @@ describe Github::Issues::Milestones do
|
|
|
250
270
|
context "failed to remove resource" do
|
|
251
271
|
before do
|
|
252
272
|
stub_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
|
|
253
|
-
to_return(:body => fixture('issues/milestone.json'),
|
|
273
|
+
to_return(:body => fixture('issues/milestone.json'),
|
|
274
|
+
:status => 404,
|
|
275
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
254
276
|
end
|
|
255
277
|
|
|
256
278
|
it "should faile to retrieve resource" do
|
|
257
279
|
expect {
|
|
258
|
-
github.issues.
|
|
280
|
+
github.issues.milestones.delete user, repo, milestone_id
|
|
259
281
|
}.to raise_error(Github::Error::NotFound)
|
|
260
282
|
end
|
|
261
283
|
end
|
|
262
|
-
end #
|
|
284
|
+
end # delete
|
|
263
285
|
|
|
264
286
|
end # Github::Issues::Milestones
|
data/spec/github/issues_spec.rb
CHANGED
|
@@ -7,19 +7,19 @@ describe Github::Issues do
|
|
|
7
7
|
let(:github) { Github.new }
|
|
8
8
|
let(:user) { 'peter-murach' }
|
|
9
9
|
let(:repo) { 'github' }
|
|
10
|
+
let(:issue_id) { 1347 }
|
|
10
11
|
|
|
11
|
-
after {
|
|
12
|
+
after { reset_authentication_for github }
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
it {
|
|
15
|
-
it {
|
|
16
|
-
it {
|
|
17
|
-
it {
|
|
14
|
+
context 'access to apis' do
|
|
15
|
+
it { subject.comments.should be_a Github::Issues::Comments }
|
|
16
|
+
it { subject.events.should be_a Github::Issues::Events }
|
|
17
|
+
it { subject.labels.should be_a Github::Issues::Labels }
|
|
18
|
+
it { subject.milestones.should be_a Github::Issues::Milestones }
|
|
18
19
|
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
it { github.issues.should respond_to
|
|
22
|
-
it { github.issues.should respond_to :list_issues }
|
|
21
|
+
context '#list' do
|
|
22
|
+
it { github.issues.should respond_to(:all) }
|
|
23
23
|
|
|
24
24
|
context "resource found" do
|
|
25
25
|
before do
|
|
@@ -28,29 +28,29 @@ describe Github::Issues do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should get the resources" do
|
|
31
|
-
github.issues.
|
|
31
|
+
github.issues.list
|
|
32
32
|
a_get("/issues").should have_been_made
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should return array of resources" do
|
|
36
|
-
issues = github.issues.
|
|
36
|
+
issues = github.issues.list
|
|
37
37
|
issues.should be_an Array
|
|
38
38
|
issues.should have(1).items
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should be a mash type" do
|
|
42
|
-
issues = github.issues.
|
|
42
|
+
issues = github.issues.list
|
|
43
43
|
issues.first.should be_a Hashie::Mash
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should get issue information" do
|
|
47
|
-
issues = github.issues.
|
|
47
|
+
issues = github.issues.list
|
|
48
48
|
issues.first.title.should == 'Found a bug'
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should yield to a block" do
|
|
52
|
-
github.issues.should_receive(:
|
|
53
|
-
github.issues.
|
|
52
|
+
github.issues.should_receive(:list).and_yield('web')
|
|
53
|
+
github.issues.list { |param| 'web' }.should == 'web'
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -61,53 +61,50 @@ describe Github::Issues do
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "should return 404 with a message 'Not Found'" do
|
|
64
|
-
expect { github.issues.
|
|
64
|
+
expect { github.issues.list }.to raise_error(Github::Error::NotFound)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
|
-
end #
|
|
67
|
+
end # list
|
|
68
68
|
|
|
69
|
-
describe '
|
|
70
|
-
it { github.issues.should respond_to :
|
|
71
|
-
it { github.issues.should respond_to :list_repo_issues }
|
|
72
|
-
it { github.issues.should respond_to :list_repository_issues }
|
|
69
|
+
describe '#list_repo' do
|
|
70
|
+
it { github.issues.should respond_to :list_repository }
|
|
73
71
|
|
|
74
72
|
context "resource found" do
|
|
75
73
|
before do
|
|
76
|
-
github.user, github.repo = nil, nil
|
|
77
74
|
stub_get("/repos/#{user}/#{repo}/issues").
|
|
78
75
|
to_return(:body => fixture('issues/issues.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
79
76
|
end
|
|
80
77
|
|
|
81
78
|
it "should raise error if user-name empty" do
|
|
82
79
|
expect {
|
|
83
|
-
github.issues.
|
|
80
|
+
github.issues.list_repo nil, repo
|
|
84
81
|
}.should raise_error(ArgumentError)
|
|
85
82
|
end
|
|
86
83
|
|
|
87
84
|
it "should get the resources" do
|
|
88
|
-
github.issues.
|
|
85
|
+
github.issues.list_repo user, repo
|
|
89
86
|
a_get("/repos/#{user}/#{repo}/issues").should have_been_made
|
|
90
87
|
end
|
|
91
88
|
|
|
92
89
|
it "should return array of resources" do
|
|
93
|
-
repo_issues = github.issues.
|
|
90
|
+
repo_issues = github.issues.list_repo user, repo
|
|
94
91
|
repo_issues.should be_an Array
|
|
95
92
|
repo_issues.should have(1).items
|
|
96
93
|
end
|
|
97
94
|
|
|
98
95
|
it "should be a mash type" do
|
|
99
|
-
repo_issues = github.issues.
|
|
96
|
+
repo_issues = github.issues.list_repo user, repo
|
|
100
97
|
repo_issues.first.should be_a Hashie::Mash
|
|
101
98
|
end
|
|
102
99
|
|
|
103
100
|
it "should get repository issue information" do
|
|
104
|
-
repo_issues = github.issues.
|
|
101
|
+
repo_issues = github.issues.list_repo user, repo
|
|
105
102
|
repo_issues.first.title.should == 'Found a bug'
|
|
106
103
|
end
|
|
107
104
|
|
|
108
105
|
it "should yield to a block" do
|
|
109
|
-
github.issues.should_receive(:
|
|
110
|
-
github.issues.
|
|
106
|
+
github.issues.should_receive(:list_repo).with(user, repo).and_yield('web')
|
|
107
|
+
github.issues.list_repo(user, repo) { |param| 'web' }.should == 'web'
|
|
111
108
|
end
|
|
112
109
|
end
|
|
113
110
|
|
|
@@ -119,41 +116,39 @@ describe Github::Issues do
|
|
|
119
116
|
|
|
120
117
|
it "should return 404 with a message 'Not Found'" do
|
|
121
118
|
expect {
|
|
122
|
-
github.issues.
|
|
119
|
+
github.issues.list_repo user, repo
|
|
123
120
|
}.to raise_error(Github::Error::NotFound)
|
|
124
121
|
end
|
|
125
122
|
end
|
|
126
|
-
end #
|
|
123
|
+
end # list_repo
|
|
127
124
|
|
|
128
|
-
describe "
|
|
129
|
-
let(:issue_id) { 1347 }
|
|
130
|
-
|
|
131
|
-
it { github.issues.should respond_to :issue }
|
|
132
|
-
it { github.issues.should respond_to :get_issue }
|
|
125
|
+
describe "#find" do
|
|
133
126
|
|
|
134
127
|
context "resource found" do
|
|
135
128
|
before do
|
|
136
129
|
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}").
|
|
137
|
-
to_return(:body => fixture('issues/issue.json'),
|
|
130
|
+
to_return(:body => fixture('issues/issue.json'),
|
|
131
|
+
:status => 200,
|
|
132
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
138
133
|
end
|
|
139
134
|
|
|
140
135
|
it "should fail to get resource without issue id" do
|
|
141
|
-
expect { github.issues.
|
|
136
|
+
expect { github.issues.find(user, repo, nil)}.to raise_error(ArgumentError)
|
|
142
137
|
end
|
|
143
138
|
|
|
144
139
|
it "should get the resource" do
|
|
145
|
-
github.issues.
|
|
140
|
+
github.issues.find user, repo, issue_id
|
|
146
141
|
a_get("/repos/#{user}/#{repo}/issues/#{issue_id}").should have_been_made
|
|
147
142
|
end
|
|
148
143
|
|
|
149
144
|
it "should get issue information" do
|
|
150
|
-
issue = github.issues.
|
|
145
|
+
issue = github.issues.find user, repo, issue_id
|
|
151
146
|
issue.number.should == issue_id
|
|
152
147
|
issue.title.should == 'Found a bug'
|
|
153
148
|
end
|
|
154
149
|
|
|
155
150
|
it "should return mash" do
|
|
156
|
-
issue = github.issues.
|
|
151
|
+
issue = github.issues.find user, repo, issue_id
|
|
157
152
|
issue.should be_a Hashie::Mash
|
|
158
153
|
end
|
|
159
154
|
end
|
|
@@ -161,18 +156,20 @@ describe Github::Issues do
|
|
|
161
156
|
context "resource not found" do
|
|
162
157
|
before do
|
|
163
158
|
stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}").
|
|
164
|
-
to_return(:body => fixture('issues/issue.json'),
|
|
159
|
+
to_return(:body => fixture('issues/issue.json'),
|
|
160
|
+
:status => 404,
|
|
161
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
165
162
|
end
|
|
166
163
|
|
|
167
164
|
it "should fail to retrive resource" do
|
|
168
165
|
expect {
|
|
169
|
-
github.issues.
|
|
166
|
+
github.issues.find user, repo, issue_id
|
|
170
167
|
}.to raise_error(Github::Error::NotFound)
|
|
171
168
|
end
|
|
172
169
|
end
|
|
173
170
|
end # get_issue
|
|
174
171
|
|
|
175
|
-
describe "
|
|
172
|
+
describe "#create" do
|
|
176
173
|
let(:inputs) {
|
|
177
174
|
{
|
|
178
175
|
"title" => "Found a bug",
|
|
@@ -193,22 +190,22 @@ describe Github::Issues do
|
|
|
193
190
|
|
|
194
191
|
it "should fail to create resource if 'title' input is missing" do
|
|
195
192
|
expect {
|
|
196
|
-
github.issues.
|
|
193
|
+
github.issues.create user, repo, inputs.except('title')
|
|
197
194
|
}.to raise_error(Github::Error::RequiredParams)
|
|
198
195
|
end
|
|
199
196
|
|
|
200
197
|
it "should create resource successfully" do
|
|
201
|
-
github.issues.
|
|
198
|
+
github.issues.create user, repo, inputs
|
|
202
199
|
a_post("/repos/#{user}/#{repo}/issues").with(inputs).should have_been_made
|
|
203
200
|
end
|
|
204
201
|
|
|
205
202
|
it "should return the resource" do
|
|
206
|
-
issue = github.issues.
|
|
203
|
+
issue = github.issues.create user, repo, inputs
|
|
207
204
|
issue.should be_a Hashie::Mash
|
|
208
205
|
end
|
|
209
206
|
|
|
210
207
|
it "should get the issue information" do
|
|
211
|
-
issue = github.issues.
|
|
208
|
+
issue = github.issues.create(user, repo, inputs)
|
|
212
209
|
issue.title.should == 'Found a bug'
|
|
213
210
|
end
|
|
214
211
|
end
|
|
@@ -221,14 +218,13 @@ describe Github::Issues do
|
|
|
221
218
|
|
|
222
219
|
it "should faile to retrieve resource" do
|
|
223
220
|
expect {
|
|
224
|
-
github.issues.
|
|
221
|
+
github.issues.create user, repo, inputs
|
|
225
222
|
}.to raise_error(Github::Error::NotFound)
|
|
226
223
|
end
|
|
227
224
|
end
|
|
228
|
-
end #
|
|
225
|
+
end # create
|
|
229
226
|
|
|
230
|
-
describe "
|
|
231
|
-
let(:issue_id) { 1349 }
|
|
227
|
+
describe "#edit" do
|
|
232
228
|
let(:inputs) {
|
|
233
229
|
{
|
|
234
230
|
"title" => "Found a bug",
|
|
@@ -250,22 +246,22 @@ describe Github::Issues do
|
|
|
250
246
|
|
|
251
247
|
it "should fail to edit without 'user/repo' parameters" do
|
|
252
248
|
expect {
|
|
253
|
-
github.issues.
|
|
249
|
+
github.issues.edit nil, repo, issue_id
|
|
254
250
|
}.to raise_error(ArgumentError)
|
|
255
251
|
end
|
|
256
252
|
|
|
257
253
|
it "should edit the resource" do
|
|
258
|
-
github.issues.
|
|
254
|
+
github.issues.edit user, repo, issue_id, inputs
|
|
259
255
|
a_patch("/repos/#{user}/#{repo}/issues/#{issue_id}").with(inputs).should have_been_made
|
|
260
256
|
end
|
|
261
257
|
|
|
262
258
|
it "should return resource" do
|
|
263
|
-
issue = github.issues.
|
|
259
|
+
issue = github.issues.edit user, repo, issue_id, inputs
|
|
264
260
|
issue.should be_a Hashie::Mash
|
|
265
261
|
end
|
|
266
262
|
|
|
267
263
|
it "should be able to retrieve information" do
|
|
268
|
-
issue = github.issues.
|
|
264
|
+
issue = github.issues.edit user, repo, issue_id, inputs
|
|
269
265
|
issue.title.should == 'Found a bug'
|
|
270
266
|
end
|
|
271
267
|
end
|
|
@@ -278,7 +274,7 @@ describe Github::Issues do
|
|
|
278
274
|
|
|
279
275
|
it "should fail to find resource" do
|
|
280
276
|
expect {
|
|
281
|
-
github.issues.
|
|
277
|
+
github.issues.edit user, repo, issue_id, inputs
|
|
282
278
|
}.to raise_error(Github::Error::NotFound)
|
|
283
279
|
end
|
|
284
280
|
end
|