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.
Files changed (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. 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 { github.user, github.repo, github.oauth_token = nil, nil, nil }
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 'milestones' do
16
- it { github.issues.should respond_to :milestones }
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'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
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
- github.user, github.repo = nil, nil
27
- expect { github.issues.milestones nil, repo }.to raise_error(ArgumentError)
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(:milestones).with(user, repo).and_yield('web')
53
- github.issues.milestones(user, repo) { |param| 'web' }.should == 'web'
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 # milestones
72
+ end # list
70
73
 
71
- describe "milestone" do
74
+ describe "#get" do
72
75
  let(:milestone_id) { 1 }
73
76
 
74
- it { github.issues.should respond_to :milestone }
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'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
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 { github.issues.milestone(user, repo, nil)}.to raise_error(ArgumentError)
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.milestone user, repo, milestone_id
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.milestone user, repo, milestone_id
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.milestone user, repo, milestone_id
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'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
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.milestone user, repo, milestone_id
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 # milestone
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'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
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.create_milestone user, repo, inputs.except('title')
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.create_milestone user, repo, inputs
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.create_milestone user, repo, inputs
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.create_milestone user, repo, inputs
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'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
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.create_milestone user, repo, inputs
177
+ github.issues.milestones.create user, repo, inputs
166
178
  }.to raise_error(Github::Error::NotFound)
167
179
  end
168
180
  end
169
- end # create_milestone
181
+ end # create
170
182
 
171
- describe "update_milestone" do
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}").with(inputs).
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.update_milestone user, repo, milestone_id, inputs.except('title')
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.update_milestone user, repo, milestone_id, inputs
196
- a_patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}").with(inputs).should have_been_made
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.update_milestone user, repo, milestone_id, inputs
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.update_milestone user, repo, milestone_id, inputs
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}").with(inputs).
213
- to_return(:body => fixture('issues/milestone.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
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.update_milestone user, repo, milestone_id, inputs
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 # update_milestone
240
+ end # update
224
241
 
225
- describe "delete_milestone" do
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'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
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.delete_milestone user, repo, milestone_id
236
- a_delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}").should have_been_made
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.delete_milestone user, repo, milestone_id
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.delete_milestone user, repo, milestone_id
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'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
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.delete_milestone user, repo, milestone_id
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 # delete_milestone
284
+ end # delete
263
285
 
264
286
  end # Github::Issues::Milestones
@@ -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 { github.user, github.repo, github.oauth_token = nil, nil, nil }
12
+ after { reset_authentication_for github }
12
13
 
13
- describe 'modules inclusion' do
14
- it { issues_api.included_modules.should include Github::Issues::Comments }
15
- it { issues_api.included_modules.should include Github::Issues::Events }
16
- it { issues_api.included_modules.should include Github::Issues::Labels }
17
- it { issues_api.included_modules.should include Github::Issues::Milestones }
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
- describe 'issues' do
21
- it { github.issues.should respond_to :issues }
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.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.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.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.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(:issues).and_yield('web')
53
- github.issues.issues { |param| 'web' }.should == 'web'
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.issues }.to raise_error(Github::Error::NotFound)
64
+ expect { github.issues.list }.to raise_error(Github::Error::NotFound)
65
65
  end
66
66
  end
67
- end # issues
67
+ end # list
68
68
 
69
- describe 'repo_issues' do
70
- it { github.issues.should respond_to :repo_issues }
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.repo_issues nil, repo
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.repo_issues user, repo
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.repo_issues user, repo
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.repo_issues user, repo
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.repo_issues user, repo
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(:issues).with(user, repo).and_yield('web')
110
- github.issues.issues(user, repo) { |param| 'web' }.should == 'web'
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.repo_issues user, repo
119
+ github.issues.list_repo user, repo
123
120
  }.to raise_error(Github::Error::NotFound)
124
121
  end
125
122
  end
126
- end # repo_issues
123
+ end # list_repo
127
124
 
128
- describe "get_issue" do
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'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
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.issue(user, repo, nil)}.to raise_error(ArgumentError)
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.issue user, repo, issue_id
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.issue user, repo, issue_id
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.issue user, repo, issue_id
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'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
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.issue user, repo, issue_id
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 "create_issue" do
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.create_issue user, repo, inputs.except('title')
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.create_issue user, repo, inputs
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.create_issue user, repo, inputs
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.create_issue(user, repo, inputs)
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.create_issue user, repo, inputs
221
+ github.issues.create user, repo, inputs
225
222
  }.to raise_error(Github::Error::NotFound)
226
223
  end
227
224
  end
228
- end # create_issue
225
+ end # create
229
226
 
230
- describe "edit_issue" do
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.edit_issue nil, repo, issue_id
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.edit_issue user, repo, issue_id, inputs
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.edit_issue user, repo, issue_id, inputs
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.edit_issue user, repo, issue_id, inputs
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.edit_issue user, repo, issue_id, inputs
277
+ github.issues.edit user, repo, issue_id, inputs
282
278
  }.to raise_error(Github::Error::NotFound)
283
279
  end
284
280
  end