github_api 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/README.md +20 -1
  2. data/features/cassettes/issues/events/get.yml +139 -0
  3. data/features/cassettes/issues/events/list_issue.yml +71 -0
  4. data/features/cassettes/issues/events/list_repo.yml +222 -0
  5. data/features/cassettes/issues/labels/list_repo.yml +65 -0
  6. data/features/cassettes/issues/milestones/create.yml +55 -0
  7. data/features/cassettes/issues/milestones/delete.yml +46 -0
  8. data/features/cassettes/issues/milestones/get.yml +175 -0
  9. data/features/cassettes/issues/milestones/list.yml +54 -0
  10. data/features/cassettes/issues/milestones/update.yml +53 -0
  11. data/features/cassettes/repos/contents/archive.yml +43 -84
  12. data/features/cassettes/say/custom.yml +60 -0
  13. data/features/cassettes/say/random.yml +60 -0
  14. data/features/issues/events.feature +38 -0
  15. data/features/issues/labels.feature +14 -0
  16. data/features/issues/milestones.feature +62 -0
  17. data/features/say.feature +68 -0
  18. data/features/step_definitions/common_steps.rb +6 -0
  19. data/features/support/helpers.rb +4 -0
  20. data/lib/github_api.rb +2 -0
  21. data/lib/github_api/client.rb +8 -0
  22. data/lib/github_api/constants.rb +4 -0
  23. data/lib/github_api/issues.rb +74 -46
  24. data/lib/github_api/issues/assignees.rb +2 -1
  25. data/lib/github_api/issues/events.rb +3 -3
  26. data/lib/github_api/issues/milestones.rb +0 -1
  27. data/lib/github_api/rate_limit.rb +2 -0
  28. data/lib/github_api/result.rb +13 -0
  29. data/lib/github_api/say.rb +24 -0
  30. data/lib/github_api/scopes.rb +19 -0
  31. data/lib/github_api/version.rb +1 -1
  32. data/spec/github/git_data/git_data_spec.rb +19 -0
  33. data/spec/github/issues/assignees/check_spec.rb +46 -0
  34. data/spec/github/issues/assignees/list_spec.rb +47 -0
  35. data/spec/github/issues/assignees_spec.rb +0 -96
  36. data/spec/github/issues/create_spec.rb +60 -0
  37. data/spec/github/issues/edit_spec.rb +61 -0
  38. data/spec/github/issues/events_spec.rb +4 -4
  39. data/spec/github/issues/get_spec.rb +49 -0
  40. data/spec/github/issues/issues_spec.rb +19 -0
  41. data/spec/github/issues/list_spec.rb +90 -0
  42. data/spec/github/issues/milestones/create_spec.rb +56 -0
  43. data/spec/github/issues/milestones/delete_spec.rb +42 -0
  44. data/spec/github/issues/milestones/get_spec.rb +49 -0
  45. data/spec/github/issues/milestones/list_spec.rb +52 -0
  46. data/spec/github/issues/milestones/update_spec.rb +57 -0
  47. data/spec/github/issues/milestones_spec.rb +1 -276
  48. data/spec/github/scopes/list_spec.rb +33 -0
  49. data/spec/github/users/followers/follow_spec.rb +33 -0
  50. data/spec/github/users/followers/following_spec.rb +65 -0
  51. data/spec/github/users/followers/is_following_spec.rb +41 -0
  52. data/spec/github/users/followers/list_spec.rb +2 -8
  53. data/spec/github/users/followers/unfollow_spec.rb +33 -0
  54. data/spec/github/users/users_spec.rb +16 -0
  55. metadata +68 -35
  56. data/spec/github/git_data_spec.rb +0 -11
  57. data/spec/github/issues_spec.rb +0 -284
  58. data/spec/github/users/followers_spec.rb +0 -172
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Issues::Milestones, '#create' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:milestone_id) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/milestones/#{milestone_id}" }
10
+
11
+ before {
12
+ stub_delete(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context "resouce removed" do
19
+ let(:body) { fixture('issues/milestone.json') }
20
+ let(:status) { 201 }
21
+
22
+ it "should remove resource successfully" do
23
+ subject.delete user, repo, milestone_id
24
+ a_delete(request_path).should have_been_made
25
+ end
26
+
27
+ it "should return the resource" do
28
+ milestone = subject.delete user, repo, milestone_id
29
+ milestone.should be_a Hashie::Mash
30
+ end
31
+
32
+ it "should get the milestone information" do
33
+ milestone = subject.delete user, repo, milestone_id
34
+ milestone.title.should == 'v1.0'
35
+ end
36
+ end
37
+
38
+ it_should_behave_like 'request failure' do
39
+ let(:requestable) { subject.delete user, repo, milestone_id }
40
+ end
41
+
42
+ end # delete
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Issues::Milestones, '#get' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:milestone_id) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/milestones/#{milestone_id}" }
10
+
11
+ before {
12
+ stub_get(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context "resource found" do
19
+ let(:body) { fixture('issues/milestone.json') }
20
+ let(:status) { 200 }
21
+
22
+ it { subject.should respond_to :find }
23
+
24
+ it "should fail to get resource without milestone id" do
25
+ expect { subject.get user, repo, nil }.to raise_error(ArgumentError)
26
+ end
27
+
28
+ it "should get the resource" do
29
+ subject.get user, repo, milestone_id
30
+ a_get(request_path).should have_been_made
31
+ end
32
+
33
+ it "should get milestone information" do
34
+ milestone = subject.get user, repo, milestone_id
35
+ milestone.number.should == milestone_id
36
+ milestone.title.should == 'v1.0'
37
+ end
38
+
39
+ it "should return mash" do
40
+ milestone = subject.get user, repo, milestone_id
41
+ milestone.should be_a Hashie::Mash
42
+ end
43
+ end
44
+
45
+ it_should_behave_like 'request failure' do
46
+ let(:requestable) { subject.get user, repo, milestone_id }
47
+ end
48
+
49
+ end # get
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Issues::Milestones, '#list' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:request_path) { "/repos/#{user}/#{repo}/milestones" }
9
+
10
+ before {
11
+ stub_get(request_path).to_return(:body => body, :status => status,
12
+ :headers => {:content_type => "application/json; charset=utf-8"})
13
+ }
14
+
15
+ after { reset_authentication_for(subject) }
16
+
17
+ context "resource found" do
18
+ let(:body) { fixture('issues/milestones.json') }
19
+ let(:status) { 200 }
20
+
21
+ it { subject.should respond_to :all }
22
+
23
+ it "should fail to get resource without username" do
24
+ expect { subject.list nil, repo }.to raise_error(ArgumentError)
25
+ end
26
+
27
+ it "should get the resources" do
28
+ subject.list user, repo
29
+ a_get(request_path).should have_been_made
30
+ end
31
+
32
+ it_should_behave_like 'an array of resources' do
33
+ let(:requestable) { subject.list user, repo }
34
+ end
35
+
36
+ it "should get issue information" do
37
+ milestones = subject.list user, repo
38
+ milestones.first.title.should == 'v1.0'
39
+ end
40
+
41
+ it "should yield to a block" do
42
+ yielded = []
43
+ result = subject.list(user, repo) { |obj| yielded << obj }
44
+ yielded.should == result
45
+ end
46
+ end
47
+
48
+ it_should_behave_like 'request failure' do
49
+ let(:requestable) { subject.list user, repo }
50
+ end
51
+
52
+ end # list
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Issues::Milestones, '#update' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:repo) { 'github' }
8
+ let(:milestone_id) { 1 }
9
+ let(:request_path) { "/repos/#{user}/#{repo}/milestones/#{milestone_id}" }
10
+ let(:inputs) {
11
+ {
12
+ "title" => "String",
13
+ "state" => "open or closed",
14
+ "description" => "String",
15
+ "due_on" => "Time"
16
+ }
17
+ }
18
+
19
+ before {
20
+ stub_patch(request_path).with(inputs).
21
+ to_return(:body => body, :status => status,
22
+ :headers => {:content_type => "application/json; charset=utf-8"})
23
+ }
24
+
25
+ after { reset_authentication_for(subject) }
26
+
27
+ context "resouce updated" do
28
+ let(:body) { fixture('issues/milestone.json') }
29
+ let(:status) { 201 }
30
+
31
+ it "should fail to create resource if 'number' input is missing" do
32
+ expect {
33
+ subject.update user, repo, nil, inputs
34
+ }.to raise_error(ArgumentError)
35
+ end
36
+
37
+ it "should update resource successfully" do
38
+ subject.update user, repo, milestone_id, inputs
39
+ a_patch(request_path).with(inputs).should have_been_made
40
+ end
41
+
42
+ it "should return the resource" do
43
+ milestone = subject.update user, repo, milestone_id, inputs
44
+ milestone.should be_a Hashie::Mash
45
+ end
46
+
47
+ it "should get the milestone information" do
48
+ milestone = subject.update user, repo, milestone_id, inputs
49
+ milestone.title.should == 'v1.0'
50
+ end
51
+ end
52
+
53
+ it_should_behave_like 'request failure' do
54
+ let(:requestable) { subject.update user, repo, milestone_id, inputs }
55
+ end
56
+
57
+ end # update
@@ -3,284 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Github::Issues::Milestones do
6
- let(:github) { Github.new }
7
- let(:user) { 'peter-murach' }
8
- let(:repo) { 'github' }
9
-
10
- after { reset_authentication_for github }
11
6
 
12
7
  it { described_class::VALID_MILESTONE_OPTIONS.should_not be_nil }
13
- it { described_class::VALID_MILESTONE_INPUTS.should_not be_nil }
14
-
15
- describe '#list' do
16
- it { github.issues.milestones.should respond_to :all }
17
-
18
- context "resource found" do
19
- before do
20
- stub_get("/repos/#{user}/#{repo}/milestones").
21
- to_return(:body => fixture('issues/milestones.json'),
22
- :status => 200,
23
- :headers => {:content_type => "application/json; charset=utf-8"})
24
- end
25
-
26
- it "should fail to get resource without username" do
27
- expect {
28
- github.issues.milestones.list nil, repo
29
- }.to raise_error(ArgumentError)
30
- end
31
-
32
- it "should get the resources" do
33
- github.issues.milestones.list user, repo
34
- a_get("/repos/#{user}/#{repo}/milestones").should have_been_made
35
- end
36
-
37
- it "should return array of resources" do
38
- milestones = github.issues.milestones.list user, repo
39
- milestones.should be_an Array
40
- milestones.should have(1).items
41
- end
42
-
43
- it "should be a mash type" do
44
- milestones = github.issues.milestones.list user, repo
45
- milestones.first.should be_a Hashie::Mash
46
- end
47
-
48
- it "should get issue information" do
49
- milestones = github.issues.milestones.list user, repo
50
- milestones.first.title.should == 'v1.0'
51
- end
52
-
53
- it "should yield to a block" do
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'
57
- end
58
- end
59
-
60
- context "resource not found" do
61
- before do
62
- stub_get("/repos/#{user}/#{repo}/milestones").
63
- to_return(:body => "", :status => [404, "Not Found"])
64
- end
65
-
66
- it "should return 404 with a message 'Not Found'" do
67
- expect {
68
- github.issues.milestones.list user, repo
69
- }.to raise_error(Github::Error::NotFound)
70
- end
71
- end
72
- end # list
73
-
74
- describe "#get" do
75
- let(:milestone_id) { 1 }
76
-
77
- it { github.issues.milestones.should respond_to :find }
78
-
79
- context "resource found" do
80
- before do
81
- stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
82
- to_return(:body => fixture('issues/milestone.json'),
83
- :status => 200,
84
- :headers => {:content_type => "application/json; charset=utf-8"})
85
- end
86
-
87
- it "should fail to get resource without milestone id" do
88
- expect {
89
- github.issues.milestones.get user, repo, nil
90
- }.to raise_error(ArgumentError)
91
- end
92
-
93
- it "should get the resource" do
94
- github.issues.milestones.get user, repo, milestone_id
95
- a_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").should have_been_made
96
- end
97
-
98
- it "should get milestone information" do
99
- milestone = github.issues.milestones.get user, repo, milestone_id
100
- milestone.number.should == milestone_id
101
- milestone.title.should == 'v1.0'
102
- end
103
-
104
- it "should return mash" do
105
- milestone = github.issues.milestones.get user, repo, milestone_id
106
- milestone.should be_a Hashie::Mash
107
- end
108
- end
109
-
110
- context "resource not found" do
111
- before do
112
- stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
113
- to_return(:body => fixture('issues/milestone.json'),
114
- :status => 404,
115
- :headers => {:content_type => "application/json; charset=utf-8"})
116
- end
117
-
118
- it "should fail to retrive resource" do
119
- expect {
120
- github.issues.milestones.get user, repo, milestone_id
121
- }.to raise_error(Github::Error::NotFound)
122
- end
123
- end
124
- end # get
125
-
126
- describe "create_milestone" do
127
- let(:inputs) {
128
- {
129
- "title" => "String",
130
- "state" => "open or closed",
131
- "description" => "String",
132
- "due_on" => "Time"
133
- }
134
- }
135
-
136
- context "resouce created" do
137
- before do
138
- stub_post("/repos/#{user}/#{repo}/milestones").with(inputs).
139
- to_return(:body => fixture('issues/milestone.json'),
140
- :status => 201,
141
- :headers => {:content_type => "application/json; charset=utf-8"})
142
- end
143
8
 
144
- it "should fail to create resource if 'title' input is missing" do
145
- expect {
146
- github.issues.milestones.create user, repo, inputs.except('title')
147
- }.to raise_error(Github::Error::RequiredParams)
148
- end
149
-
150
- it "should create resource successfully" do
151
- github.issues.milestones.create user, repo, inputs
152
- a_post("/repos/#{user}/#{repo}/milestones").with(inputs).should have_been_made
153
- end
154
-
155
- it "should return the resource" do
156
- milestone = github.issues.milestones.create user, repo, inputs
157
- milestone.should be_a Hashie::Mash
158
- end
159
-
160
- it "should get the milestone information" do
161
- milestone = github.issues.milestones.create user, repo, inputs
162
- milestone.title.should == 'v1.0'
163
- end
164
- end
165
-
166
- context "failed to create resource" do
167
- before do
168
- stub_post("/repos/#{user}/#{repo}/milestones").with(inputs).
169
- to_return(:body => fixture('issues/milestone.json'),
170
- :status => 404,
171
- :headers => {:content_type => "application/json; charset=utf-8"})
172
-
173
- end
174
-
175
- it "should faile to retrieve resource" do
176
- expect {
177
- github.issues.milestones.create user, repo, inputs
178
- }.to raise_error(Github::Error::NotFound)
179
- end
180
- end
181
- end # create
182
-
183
- describe "#update" do
184
- let(:milestone_id) { 1 }
185
- let(:inputs) {
186
- {
187
- "title" => "String",
188
- "state" => "open or closed",
189
- "description" => "String",
190
- "due_on" => "Time"
191
- }
192
- }
193
-
194
- context "resouce updated" do
195
- before do
196
- stub_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
197
- with(inputs).
198
- to_return(:body => fixture('issues/milestone.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
199
- end
200
-
201
- it "should fail to create resource if 'title' input is missing" do
202
- expect {
203
- github.issues.milestones.update user, repo, milestone_id, inputs.except('title')
204
- }.to raise_error(Github::Error::RequiredParams)
205
- end
206
-
207
- it "should update resource successfully" do
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
211
- end
212
-
213
- it "should return the resource" do
214
- milestone = github.issues.milestones.update user, repo, milestone_id, inputs
215
- milestone.should be_a Hashie::Mash
216
- end
217
-
218
- it "should get the milestone information" do
219
- milestone = github.issues.milestones.update user, repo, milestone_id, inputs
220
- milestone.title.should == 'v1.0'
221
- end
222
- end
223
-
224
- context "failed to create resource" do
225
- before do
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"})
231
-
232
- end
233
-
234
- it "should faile to retrieve resource" do
235
- expect {
236
- github.issues.milestones.update user, repo, milestone_id, inputs
237
- }.to raise_error(Github::Error::NotFound)
238
- end
239
- end
240
- end # update
241
-
242
- describe "#delete" do
243
- let(:milestone_id) { 1 }
244
-
245
- context "resouce removed" do
246
- before do
247
- stub_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
248
- to_return(:body => fixture('issues/milestone.json'),
249
- :status => 201,
250
- :headers => {:content_type => "application/json; charset=utf-8"})
251
- end
252
-
253
- it "should remove resource successfully" do
254
- github.issues.milestones.delete user, repo, milestone_id
255
- a_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
256
- should have_been_made
257
- end
258
-
259
- it "should return the resource" do
260
- milestone = github.issues.milestones.delete user, repo, milestone_id
261
- milestone.should be_a Hashie::Mash
262
- end
263
-
264
- it "should get the milestone information" do
265
- milestone = github.issues.milestones.delete user, repo, milestone_id
266
- milestone.title.should == 'v1.0'
267
- end
268
- end
269
-
270
- context "failed to remove resource" do
271
- before do
272
- stub_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").
273
- to_return(:body => fixture('issues/milestone.json'),
274
- :status => 404,
275
- :headers => {:content_type => "application/json; charset=utf-8"})
276
- end
277
-
278
- it "should faile to retrieve resource" do
279
- expect {
280
- github.issues.milestones.delete user, repo, milestone_id
281
- }.to raise_error(Github::Error::NotFound)
282
- end
283
- end
284
- end # delete
9
+ it { described_class::VALID_MILESTONE_INPUTS.should_not be_nil }
285
10
 
286
11
  end # Github::Issues::Milestones