github_api 0.4.11 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -8,11 +8,8 @@ describe Github::PullRequests do
|
|
8
8
|
|
9
9
|
after { reset_authentication_for github }
|
10
10
|
|
11
|
-
describe "#
|
12
|
-
|
13
|
-
it { github.pull_requests.should respond_to :pulls }
|
14
|
-
it { github.pull_requests.should respond_to :requests }
|
15
|
-
end
|
11
|
+
describe "#list" do
|
12
|
+
it { github.pull_requests.should respond_to :all }
|
16
13
|
|
17
14
|
context 'resource found' do
|
18
15
|
let(:inputs) { { 'state'=> 'closed', 'unrelated' => true } }
|
@@ -26,34 +23,34 @@ describe Github::PullRequests do
|
|
26
23
|
end
|
27
24
|
|
28
25
|
it "throws error if pull_request id not provided" do
|
29
|
-
expect { github.pull_requests.
|
26
|
+
expect { github.pull_requests.list nil}.to raise_error(ArgumentError)
|
30
27
|
end
|
31
28
|
|
32
29
|
it "should get the resources" do
|
33
|
-
github.pull_requests.
|
30
|
+
github.pull_requests.list user, repo, inputs
|
34
31
|
a_get("/repos/#{user}/#{repo}/pulls").with(:query => inputs).should have_been_made
|
35
32
|
end
|
36
33
|
|
37
34
|
it "should return array of resources" do
|
38
|
-
pull_requests = github.pull_requests.
|
35
|
+
pull_requests = github.pull_requests.list user, repo, inputs
|
39
36
|
pull_requests.should be_an Array
|
40
37
|
pull_requests.should have(1).items
|
41
38
|
end
|
42
39
|
|
43
40
|
it "should be a mash type" do
|
44
|
-
pull_requests = github.pull_requests.
|
41
|
+
pull_requests = github.pull_requests.list user, repo, inputs
|
45
42
|
pull_requests.first.should be_a Hashie::Mash
|
46
43
|
end
|
47
44
|
|
48
45
|
it "should get pull request information" do
|
49
|
-
pull_requests = github.pull_requests.
|
46
|
+
pull_requests = github.pull_requests.list user, repo, inputs
|
50
47
|
pull_requests.first.title.should == 'new-feature'
|
51
48
|
end
|
52
49
|
|
53
50
|
it "should yield to a block" do
|
54
|
-
github.pull_requests.should_receive(:
|
51
|
+
github.pull_requests.should_receive(:list).with(user, repo).
|
55
52
|
and_yield('web')
|
56
|
-
github.pull_requests.
|
53
|
+
github.pull_requests.list(user, repo) { |param| 'web' }
|
57
54
|
end
|
58
55
|
end
|
59
56
|
|
@@ -65,17 +62,14 @@ describe Github::PullRequests do
|
|
65
62
|
|
66
63
|
it "should return 404 with a message 'Not Found'" do
|
67
64
|
expect {
|
68
|
-
github.pull_requests.
|
65
|
+
github.pull_requests.list user, repo
|
69
66
|
}.to raise_error(Github::Error::NotFound)
|
70
67
|
end
|
71
68
|
end
|
72
|
-
end #
|
69
|
+
end # list
|
73
70
|
|
74
|
-
describe "#
|
75
|
-
|
76
|
-
it { github.pull_requests.should respond_to :pull_request }
|
77
|
-
it { github.pull_requests.should respond_to :get_pull_request }
|
78
|
-
end
|
71
|
+
describe "#get" do
|
72
|
+
it { github.pull_requests.should respond_to :find }
|
79
73
|
|
80
74
|
context 'resource found' do
|
81
75
|
before do
|
@@ -86,23 +80,23 @@ describe Github::PullRequests do
|
|
86
80
|
end
|
87
81
|
|
88
82
|
it "should fail to get resource without pull_request id" do
|
89
|
-
expect { github.pull_requests.
|
83
|
+
expect { github.pull_requests.get nil }.to raise_error(ArgumentError)
|
90
84
|
end
|
91
85
|
|
92
86
|
it "should get the resource" do
|
93
|
-
github.pull_requests.
|
87
|
+
github.pull_requests.get user, repo, pull_request_id
|
94
88
|
a_get("/repos/#{user}/#{repo}/pulls/#{pull_request_id}").
|
95
89
|
should have_been_made
|
96
90
|
end
|
97
91
|
|
98
92
|
it "should get pull_request information" do
|
99
|
-
pull_request = github.pull_requests.
|
93
|
+
pull_request = github.pull_requests.get user, repo, pull_request_id
|
100
94
|
pull_request.number.should eq pull_request_id
|
101
95
|
pull_request.head.user.login.should == 'octocat'
|
102
96
|
end
|
103
97
|
|
104
98
|
it "should return mash" do
|
105
|
-
pull_request = github.pull_requests.
|
99
|
+
pull_request = github.pull_requests.get user, repo, pull_request_id
|
106
100
|
pull_request.should be_a Hashie::Mash
|
107
101
|
end
|
108
102
|
end
|
@@ -117,13 +111,13 @@ describe Github::PullRequests do
|
|
117
111
|
|
118
112
|
it "should fail to retrive resource" do
|
119
113
|
expect {
|
120
|
-
github.pull_requests.
|
114
|
+
github.pull_requests.get user, repo, pull_request_id
|
121
115
|
}.to raise_error(Github::Error::NotFound)
|
122
116
|
end
|
123
117
|
end
|
124
|
-
end #
|
118
|
+
end # get
|
125
119
|
|
126
|
-
describe "
|
120
|
+
describe "#create" do
|
127
121
|
let(:inputs) {
|
128
122
|
{
|
129
123
|
"title" => "Amazing new feature",
|
@@ -143,17 +137,17 @@ describe Github::PullRequests do
|
|
143
137
|
end
|
144
138
|
|
145
139
|
it "should create resource successfully" do
|
146
|
-
github.pull_requests.
|
140
|
+
github.pull_requests.create user, repo, inputs
|
147
141
|
a_post("/repos/#{user}/#{repo}/pulls").with(inputs).should have_been_made
|
148
142
|
end
|
149
143
|
|
150
144
|
it "should return the resource" do
|
151
|
-
pull_request = github.pull_requests.
|
145
|
+
pull_request = github.pull_requests.create user, repo, inputs
|
152
146
|
pull_request.should be_a Hashie::Mash
|
153
147
|
end
|
154
148
|
|
155
149
|
it "should get the request information" do
|
156
|
-
pull_request = github.pull_requests.
|
150
|
+
pull_request = github.pull_requests.create user, repo, inputs
|
157
151
|
pull_request.title.should eql "new-feature"
|
158
152
|
end
|
159
153
|
end
|
@@ -167,13 +161,13 @@ describe Github::PullRequests do
|
|
167
161
|
|
168
162
|
it "should faile to retrieve resource" do
|
169
163
|
expect {
|
170
|
-
github.pull_requests.
|
164
|
+
github.pull_requests.create user, repo, inputs
|
171
165
|
}.to raise_error(Github::Error::NotFound)
|
172
166
|
end
|
173
167
|
end
|
174
|
-
end #
|
168
|
+
end # create
|
175
169
|
|
176
|
-
describe "#
|
170
|
+
describe "#update" do
|
177
171
|
let(:inputs) {
|
178
172
|
{
|
179
173
|
"title" => "new title",
|
@@ -193,20 +187,18 @@ describe Github::PullRequests do
|
|
193
187
|
end
|
194
188
|
|
195
189
|
it "should create resource successfully" do
|
196
|
-
github.pull_requests.
|
190
|
+
github.pull_requests.update user, repo, pull_request_id, inputs
|
197
191
|
a_patch("/repos/#{user}/#{repo}/pulls/#{pull_request_id}").with(inputs).
|
198
192
|
should have_been_made
|
199
193
|
end
|
200
194
|
|
201
195
|
it "should return the resource" do
|
202
|
-
pull_request = github.pull_requests.
|
203
|
-
pull_request_id, inputs
|
196
|
+
pull_request = github.pull_requests.update user, repo, pull_request_id, inputs
|
204
197
|
pull_request.should be_a Hashie::Mash
|
205
198
|
end
|
206
199
|
|
207
200
|
it "should get the pull_request information" do
|
208
|
-
pull_request = github.pull_requests.
|
209
|
-
pull_request_id, inputs
|
201
|
+
pull_request = github.pull_requests.update user, repo, pull_request_id, inputs
|
210
202
|
pull_request.title.should == 'new-feature'
|
211
203
|
end
|
212
204
|
end
|
@@ -222,18 +214,13 @@ describe Github::PullRequests do
|
|
222
214
|
|
223
215
|
it "should faile to retrieve resource" do
|
224
216
|
expect {
|
225
|
-
github.pull_requests.
|
217
|
+
github.pull_requests.update user, repo, pull_request_id, inputs
|
226
218
|
}.to raise_error(Github::Error::NotFound)
|
227
219
|
end
|
228
220
|
end
|
229
|
-
end #
|
221
|
+
end # update
|
230
222
|
|
231
223
|
describe "#commits" do
|
232
|
-
context 'check aliases' do
|
233
|
-
it { github.pull_requests.should respond_to :commits }
|
234
|
-
it { github.pull_requests.should respond_to :request_commits }
|
235
|
-
end
|
236
|
-
|
237
224
|
context 'resource found' do
|
238
225
|
before do
|
239
226
|
stub_get("/repos/#{user}/#{repo}/pulls/#{pull_request_id}/commits").
|
@@ -292,10 +279,7 @@ describe Github::PullRequests do
|
|
292
279
|
end # commits
|
293
280
|
|
294
281
|
describe "#files" do
|
295
|
-
|
296
|
-
it { github.pull_requests.should respond_to :files }
|
297
|
-
it { github.pull_requests.should respond_to :request_files }
|
298
|
-
end
|
282
|
+
it { github.pull_requests.should respond_to :files }
|
299
283
|
|
300
284
|
context 'resource found' do
|
301
285
|
before do
|
@@ -8,41 +8,46 @@ describe Github::Repos::Collaborators do
|
|
8
8
|
|
9
9
|
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
10
10
|
|
11
|
-
describe "
|
11
|
+
describe "#list" do
|
12
12
|
context "resource found" do
|
13
13
|
before do
|
14
14
|
stub_get("/repos/#{user}/#{repo}/collaborators").
|
15
|
-
to_return(:body => fixture('repos/collaborators.json'),
|
15
|
+
to_return(:body => fixture('repos/collaborators.json'),
|
16
|
+
:status => 200,
|
17
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
16
18
|
end
|
17
19
|
|
18
20
|
it "should fail to get resource without username" do
|
19
|
-
expect {
|
21
|
+
expect {
|
22
|
+
github.repos.collaborators.list
|
23
|
+
}.to raise_error(ArgumentError)
|
20
24
|
end
|
21
25
|
|
22
26
|
it "should get the resources" do
|
23
|
-
github.repos.collaborators user, repo
|
27
|
+
github.repos.collaborators.list user, repo
|
24
28
|
a_get("/repos/#{user}/#{repo}/collaborators").should have_been_made
|
25
29
|
end
|
26
30
|
|
27
31
|
it "should return array of resources" do
|
28
|
-
collaborators = github.repos.collaborators user, repo
|
32
|
+
collaborators = github.repos.collaborators.list user, repo
|
29
33
|
collaborators.should be_an Array
|
30
34
|
collaborators.should have(1).items
|
31
35
|
end
|
32
36
|
|
33
37
|
it "should be a mash type" do
|
34
|
-
collaborators = github.repos.collaborators user, repo
|
38
|
+
collaborators = github.repos.collaborators.list user, repo
|
35
39
|
collaborators.first.should be_a Hashie::Mash
|
36
40
|
end
|
37
41
|
|
38
42
|
it "should get collaborator information" do
|
39
|
-
collaborators = github.repos.collaborators user, repo
|
43
|
+
collaborators = github.repos.collaborators.list user, repo
|
40
44
|
collaborators.first.login.should == 'octocat'
|
41
45
|
end
|
42
46
|
|
43
47
|
it "should yield to a block" do
|
44
|
-
github.repos.should_receive(:
|
45
|
-
|
48
|
+
github.repos.collaborators.should_receive(:list).
|
49
|
+
with(user, repo).and_yield('web')
|
50
|
+
github.repos.collaborators.list(user, repo) { |param| 'web' }
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
@@ -54,7 +59,7 @@ describe Github::Repos::Collaborators do
|
|
54
59
|
|
55
60
|
it "should return 404 with a message 'Not Found'" do
|
56
61
|
expect {
|
57
|
-
github.repos.collaborators user, repo
|
62
|
+
github.repos.collaborators.list user, repo
|
58
63
|
}.to raise_error(Github::Error::NotFound)
|
59
64
|
end
|
60
65
|
end
|
@@ -70,13 +75,14 @@ describe Github::Repos::Collaborators do
|
|
70
75
|
|
71
76
|
it "should fail to get resource without collaborator name" do
|
72
77
|
expect {
|
73
|
-
github.repos.collaborator? user, repo, nil
|
78
|
+
github.repos.collaborators.collaborator? user, repo, nil
|
74
79
|
}.to raise_error(ArgumentError)
|
75
80
|
end
|
76
81
|
|
77
82
|
it "should get the resource" do
|
78
|
-
github.repos.collaborator? user, repo, collaborator
|
79
|
-
a_get("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
83
|
+
github.repos.collaborators.collaborator? user, repo, collaborator
|
84
|
+
a_get("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
85
|
+
should have_been_made
|
80
86
|
end
|
81
87
|
|
82
88
|
it "should find collaborator" do
|
@@ -100,21 +106,22 @@ describe Github::Repos::Collaborators do
|
|
100
106
|
end
|
101
107
|
end # collaborator?
|
102
108
|
|
103
|
-
describe "
|
109
|
+
describe "#add" do
|
104
110
|
context "resouce added" do
|
105
111
|
before do
|
106
112
|
stub_put("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
107
|
-
to_return(:body => '', :status => 204,
|
113
|
+
to_return(:body => '', :status => 204,
|
114
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
108
115
|
end
|
109
116
|
|
110
117
|
it "should fail to add resource if 'collaborator' input is missing" do
|
111
118
|
expect {
|
112
|
-
github.repos.
|
119
|
+
github.repos.collaborators.add user, repo, nil
|
113
120
|
}.to raise_error(ArgumentError)
|
114
121
|
end
|
115
122
|
|
116
123
|
it "should add resource successfully" do
|
117
|
-
github.repos.
|
124
|
+
github.repos.collaborators.add user, repo, collaborator
|
118
125
|
a_put("/repos/#{user}/#{repo}/collaborators/#{collaborator}").should have_been_made
|
119
126
|
end
|
120
127
|
end
|
@@ -122,48 +129,52 @@ describe Github::Repos::Collaborators do
|
|
122
129
|
context "failed to add resource" do
|
123
130
|
before do
|
124
131
|
stub_put("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
125
|
-
to_return(:body => '', :status => 404,
|
132
|
+
to_return(:body => '', :status => 404,
|
133
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
126
134
|
end
|
127
135
|
|
128
136
|
it "should fail to add resource" do
|
129
137
|
expect {
|
130
|
-
github.repos.
|
138
|
+
github.repos.collaborators.add user, repo, collaborator
|
131
139
|
}.to raise_error(Github::Error::NotFound)
|
132
140
|
end
|
133
141
|
end
|
134
|
-
end #
|
142
|
+
end # add
|
135
143
|
|
136
|
-
describe "
|
137
|
-
context "resouce
|
144
|
+
describe "#remove" do
|
145
|
+
context "resouce removed" do
|
138
146
|
before do
|
139
147
|
stub_delete("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
140
|
-
to_return(:body => '', :status => 204,
|
148
|
+
to_return(:body => '', :status => 204,
|
149
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
141
150
|
end
|
142
151
|
|
143
152
|
it "should fail to add resource if 'collaborator' input is missing" do
|
144
153
|
expect {
|
145
|
-
github.repos.
|
154
|
+
github.repos.collaborators.remove user, repo, nil
|
146
155
|
}.to raise_error(ArgumentError)
|
147
156
|
end
|
148
157
|
|
149
158
|
it "should add resource successfully" do
|
150
|
-
github.repos.
|
151
|
-
a_delete("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
159
|
+
github.repos.collaborators.remove user, repo, collaborator
|
160
|
+
a_delete("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
161
|
+
should have_been_made
|
152
162
|
end
|
153
163
|
end
|
154
164
|
|
155
165
|
context "failed to remove resource" do
|
156
166
|
before do
|
157
167
|
stub_delete("/repos/#{user}/#{repo}/collaborators/#{collaborator}").
|
158
|
-
to_return(:body => '', :status => 404,
|
168
|
+
to_return(:body => '', :status => 404,
|
169
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
159
170
|
end
|
160
171
|
|
161
172
|
it "should fail to remove resource" do
|
162
173
|
expect {
|
163
|
-
github.repos.
|
174
|
+
github.repos.collaborators.remove user, repo, collaborator
|
164
175
|
}.to raise_error(Github::Error::NotFound)
|
165
176
|
end
|
166
177
|
end
|
167
|
-
end #
|
178
|
+
end # remove
|
168
179
|
|
169
180
|
end # Github::Repos::Collaborators
|
@@ -7,41 +7,76 @@ describe Github::Repos::Commits do
|
|
7
7
|
|
8
8
|
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
9
9
|
|
10
|
-
describe "
|
10
|
+
describe "#compare" do
|
11
|
+
let(:base) { 'master' }
|
12
|
+
let(:head) { 'topic' }
|
13
|
+
|
14
|
+
context 'resource found' do
|
15
|
+
before do
|
16
|
+
stub_get("/repos/#{user}/#{repo}/compare/#{base}...#{head}").
|
17
|
+
to_return(:body => fixture('repos/commit_comparison.json'),
|
18
|
+
:status => 200,
|
19
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should fail to get resource without base" do
|
23
|
+
expect {
|
24
|
+
github.repos.commits.compare user, repo, nil, head
|
25
|
+
}.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should compare successfully" do
|
29
|
+
github.repos.commits.compare user, repo, base, head
|
30
|
+
a_get("/repos/#{user}/#{repo}/compare/#{base}...#{head}").should have_been_made
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get comparison information" do
|
34
|
+
commit = github.repos.commits.compare user, repo, base, head
|
35
|
+
commit.base_commit.commit.author.name.should == 'Monalisa Octocat'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end # compare
|
39
|
+
|
40
|
+
describe "#list" do
|
41
|
+
it { github.repos.commits.should respond_to :all }
|
42
|
+
|
11
43
|
context "resource found" do
|
12
44
|
before do
|
13
45
|
stub_get("/repos/#{user}/#{repo}/commits").
|
14
|
-
to_return(:body => fixture('repos/commits.json'),
|
46
|
+
to_return(:body => fixture('repos/commits.json'),
|
47
|
+
:status => 200,
|
48
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
15
49
|
end
|
16
50
|
|
17
51
|
it "should fail to get resource without username" do
|
18
|
-
expect { github.repos.commits }.to raise_error(ArgumentError)
|
52
|
+
expect { github.repos.commits.list }.to raise_error(ArgumentError)
|
19
53
|
end
|
20
54
|
|
21
55
|
it "should get the resources" do
|
22
|
-
github.repos.commits user, repo
|
56
|
+
github.repos.commits.list user, repo
|
23
57
|
a_get("/repos/#{user}/#{repo}/commits").should have_been_made
|
24
58
|
end
|
25
59
|
|
26
60
|
it "should return array of resources" do
|
27
|
-
commits = github.repos.commits user, repo
|
61
|
+
commits = github.repos.commits.list user, repo
|
28
62
|
commits.should be_an Array
|
29
63
|
commits.should have(1).items
|
30
64
|
end
|
31
65
|
|
32
66
|
it "should be a mash type" do
|
33
|
-
commits = github.repos.commits user, repo
|
67
|
+
commits = github.repos.commits.list user, repo
|
34
68
|
commits.first.should be_a Hashie::Mash
|
35
69
|
end
|
36
70
|
|
37
71
|
it "should get commit information" do
|
38
|
-
commits = github.repos.commits user, repo
|
72
|
+
commits = github.repos.commits.list user, repo
|
39
73
|
commits.first.author.name.should == 'Scott Chacon'
|
40
74
|
end
|
41
75
|
|
42
76
|
it "should yield to a block" do
|
43
|
-
github.repos.should_receive(:
|
44
|
-
|
77
|
+
github.repos.commits.should_receive(:list).
|
78
|
+
with(user, repo).and_yield('web')
|
79
|
+
github.repos.commits.list(user, repo) { |param| 'web' }
|
45
80
|
end
|
46
81
|
end
|
47
82
|
|
@@ -53,15 +88,17 @@ describe Github::Repos::Commits do
|
|
53
88
|
|
54
89
|
it "should return 404 with a message 'Not Found'" do
|
55
90
|
expect {
|
56
|
-
github.repos.commits user, repo
|
91
|
+
github.repos.commits.list user, repo
|
57
92
|
}.to raise_error(Github::Error::NotFound)
|
58
93
|
end
|
59
94
|
end
|
60
|
-
end #
|
95
|
+
end # list
|
61
96
|
|
62
|
-
describe "
|
97
|
+
describe "#get" do
|
63
98
|
let(:sha) { '23432dfosfsufd' }
|
64
99
|
|
100
|
+
it { github.repos.commits.should respond_to :find }
|
101
|
+
|
65
102
|
context "resource found" do
|
66
103
|
before do
|
67
104
|
stub_get("/repos/#{user}/#{repo}/commits/#{sha}").
|
@@ -70,22 +107,22 @@ describe Github::Repos::Commits do
|
|
70
107
|
|
71
108
|
it "should fail to get resource without sha key" do
|
72
109
|
expect {
|
73
|
-
github.repos.
|
110
|
+
github.repos.commits.get user, repo, nil
|
74
111
|
}.to raise_error(ArgumentError)
|
75
112
|
end
|
76
113
|
|
77
114
|
it "should get the resource" do
|
78
|
-
github.repos.
|
115
|
+
github.repos.commits.get user, repo, sha
|
79
116
|
a_get("/repos/#{user}/#{repo}/commits/#{sha}").should have_been_made
|
80
117
|
end
|
81
118
|
|
82
119
|
it "should get commit information" do
|
83
|
-
commit = github.repos.
|
120
|
+
commit = github.repos.commits.get user, repo, sha
|
84
121
|
commit.commit.author.name.should == 'Monalisa Octocat'
|
85
122
|
end
|
86
123
|
|
87
124
|
it "should return mash" do
|
88
|
-
commit = github.repos.
|
125
|
+
commit = github.repos.commits.get user, repo, sha
|
89
126
|
commit.should be_a Hashie::Mash
|
90
127
|
end
|
91
128
|
end
|
@@ -98,11 +135,11 @@ describe Github::Repos::Commits do
|
|
98
135
|
|
99
136
|
it "should fail to retrive resource" do
|
100
137
|
expect {
|
101
|
-
github.repos.
|
138
|
+
github.repos.commits.get user, repo, sha
|
102
139
|
}.to raise_error(Github::Error::NotFound)
|
103
140
|
end
|
104
141
|
end
|
105
|
-
end #
|
142
|
+
end # get
|
106
143
|
|
107
144
|
describe "commit comments" do
|
108
145
|
context "resource found" do
|
@@ -112,33 +149,36 @@ describe Github::Repos::Commits do
|
|
112
149
|
end
|
113
150
|
|
114
151
|
it "should fail to get resource without username" do
|
115
|
-
expect {
|
152
|
+
expect {
|
153
|
+
github.repos.commits.repo_comments
|
154
|
+
}.to raise_error(ArgumentError)
|
116
155
|
end
|
117
156
|
|
118
157
|
it "should get the resources" do
|
119
|
-
github.repos.repo_comments user, repo
|
158
|
+
github.repos.commits.repo_comments user, repo
|
120
159
|
a_get("/repos/#{user}/#{repo}/comments").should have_been_made
|
121
160
|
end
|
122
161
|
|
123
162
|
it "should return array of resources" do
|
124
|
-
repo_comments = github.repos.repo_comments user, repo
|
163
|
+
repo_comments = github.repos.commits.repo_comments user, repo
|
125
164
|
repo_comments.should be_an Array
|
126
165
|
repo_comments.should have(1).items
|
127
166
|
end
|
128
167
|
|
129
168
|
it "should be a mash type" do
|
130
|
-
repo_comments = github.repos.repo_comments user, repo
|
169
|
+
repo_comments = github.repos.commits.repo_comments user, repo
|
131
170
|
repo_comments.first.should be_a Hashie::Mash
|
132
171
|
end
|
133
172
|
|
134
173
|
it "should get commit comment information" do
|
135
|
-
repo_comments = github.repos.repo_comments user, repo
|
174
|
+
repo_comments = github.repos.commits.repo_comments user, repo
|
136
175
|
repo_comments.first.user.login.should == 'octocat'
|
137
176
|
end
|
138
177
|
|
139
178
|
it "should yield to a block" do
|
140
|
-
github.repos.should_receive(:repo_comments).
|
141
|
-
|
179
|
+
github.repos.commits.should_receive(:repo_comments).
|
180
|
+
with(user, repo).and_yield('web')
|
181
|
+
github.repos.commits.repo_comments(user, repo) { |param| 'web' }
|
142
182
|
end
|
143
183
|
end
|
144
184
|
|
@@ -150,11 +190,11 @@ describe Github::Repos::Commits do
|
|
150
190
|
|
151
191
|
it "should return 404 with a message 'Not Found'" do
|
152
192
|
expect {
|
153
|
-
github.repos.repo_comments user, repo
|
193
|
+
github.repos.commits.repo_comments user, repo
|
154
194
|
}.to raise_error(Github::Error::NotFound)
|
155
195
|
end
|
156
196
|
end
|
157
|
-
end #
|
197
|
+
end # repo_comments
|
158
198
|
|
159
199
|
describe "commit_comments" do
|
160
200
|
let(:sha) { '23432dfosfsufd' }
|
@@ -167,35 +207,36 @@ describe Github::Repos::Commits do
|
|
167
207
|
|
168
208
|
it "should fail to get resource without sha key" do
|
169
209
|
expect {
|
170
|
-
github.repos.commit_comments
|
210
|
+
github.repos.commits.commit_comments user, repo, nil
|
171
211
|
}.to raise_error(ArgumentError)
|
172
212
|
end
|
173
213
|
|
174
214
|
it "should get the resource" do
|
175
|
-
github.repos.commit_comments user, repo, sha
|
215
|
+
github.repos.commits.commit_comments user, repo, sha
|
176
216
|
a_get("/repos/#{user}/#{repo}/commits/#{sha}/comments").
|
177
217
|
should have_been_made
|
178
218
|
end
|
179
219
|
|
180
220
|
it "should return array of resources" do
|
181
|
-
commit_comments = github.repos.commit_comments user, repo, sha
|
221
|
+
commit_comments = github.repos.commits.commit_comments user, repo, sha
|
182
222
|
commit_comments.should be_an Array
|
183
223
|
commit_comments.should have(1).items
|
184
224
|
end
|
185
225
|
|
186
226
|
it "should be a mash type" do
|
187
|
-
commit_comments = github.repos.commit_comments user, repo, sha
|
227
|
+
commit_comments = github.repos.commits.commit_comments user, repo, sha
|
188
228
|
commit_comments.first.should be_a Hashie::Mash
|
189
229
|
end
|
190
230
|
|
191
231
|
it "should get commit comment information" do
|
192
|
-
commit_comments = github.repos.commit_comments user, repo, sha
|
232
|
+
commit_comments = github.repos.commits.commit_comments user, repo, sha
|
193
233
|
commit_comments.first.user.login.should == 'octocat'
|
194
234
|
end
|
195
235
|
|
196
236
|
it "should yield to a block" do
|
197
|
-
github.repos.should_receive(:commit_comments).
|
198
|
-
|
237
|
+
github.repos.commits.should_receive(:commit_comments).
|
238
|
+
with(user, repo, sha).and_yield('web')
|
239
|
+
github.repos.commits.commit_comments(user, repo, sha) { |param| 'web' }
|
199
240
|
end
|
200
241
|
end
|
201
242
|
|
@@ -207,13 +248,13 @@ describe Github::Repos::Commits do
|
|
207
248
|
|
208
249
|
it "should fail to retrive resource" do
|
209
250
|
expect {
|
210
|
-
github.repos.commit_comments user, repo, sha
|
251
|
+
github.repos.commits.commit_comments user, repo, sha
|
211
252
|
}.to raise_error(Github::Error::NotFound)
|
212
253
|
end
|
213
254
|
end
|
214
255
|
end # commit_comments
|
215
256
|
|
216
|
-
describe "commit_comment" do
|
257
|
+
describe "#commit_comment" do
|
217
258
|
let(:comment_id) { 1 }
|
218
259
|
|
219
260
|
context "resource found" do
|
@@ -224,22 +265,22 @@ describe Github::Repos::Commits do
|
|
224
265
|
|
225
266
|
it "should fail to get resource without comment id" do
|
226
267
|
expect {
|
227
|
-
github.repos.commit_comment user, repo, nil
|
268
|
+
github.repos.commits.commit_comment user, repo, nil
|
228
269
|
}.to raise_error(ArgumentError)
|
229
270
|
end
|
230
271
|
|
231
272
|
it "should get the resource" do
|
232
|
-
github.repos.commit_comment user, repo, comment_id
|
273
|
+
github.repos.commits.commit_comment user, repo, comment_id
|
233
274
|
a_get("/repos/#{user}/#{repo}/comments/#{comment_id}").should have_been_made
|
234
275
|
end
|
235
276
|
|
236
277
|
it "should get commit comment information" do
|
237
|
-
commit_comment = github.repos.commit_comment user, repo, comment_id
|
278
|
+
commit_comment = github.repos.commits.commit_comment user, repo, comment_id
|
238
279
|
commit_comment.user.login.should == 'octocat'
|
239
280
|
end
|
240
281
|
|
241
282
|
it "should return mash" do
|
242
|
-
commit_comment = github.repos.commit_comment user, repo, comment_id
|
283
|
+
commit_comment = github.repos.commits.commit_comment user, repo, comment_id
|
243
284
|
commit_comment.should be_a Hashie::Mash
|
244
285
|
end
|
245
286
|
end
|
@@ -252,7 +293,7 @@ describe Github::Repos::Commits do
|
|
252
293
|
|
253
294
|
it "should fail to retrive resource" do
|
254
295
|
expect {
|
255
|
-
github.repos.commit_comment user, repo, comment_id
|
296
|
+
github.repos.commits.commit_comment user, repo, comment_id
|
256
297
|
}.to raise_error(Github::Error::NotFound)
|
257
298
|
end
|
258
299
|
end
|
@@ -276,46 +317,46 @@ describe Github::Repos::Commits do
|
|
276
317
|
|
277
318
|
it "should fail to create resource if 'body' input is missing" do
|
278
319
|
expect {
|
279
|
-
github.repos.create_comment user, repo, sha, inputs.except('body')
|
320
|
+
github.repos.commits.create_comment user, repo, sha, inputs.except('body')
|
280
321
|
}.to raise_error(Github::Error::RequiredParams)
|
281
322
|
end
|
282
323
|
|
283
324
|
it "should fail to create resource if 'commit_id' input is missing" do
|
284
325
|
expect {
|
285
|
-
github.repos.create_comment user, repo, sha, inputs.except(:commit_id)
|
326
|
+
github.repos.commits.create_comment user, repo, sha, inputs.except(:commit_id)
|
286
327
|
}.to raise_error(Github::Error::RequiredParams)
|
287
328
|
end
|
288
329
|
|
289
330
|
it "should fail to create resource if 'line' input is missing" do
|
290
331
|
expect {
|
291
|
-
github.repos.create_comment user, repo, sha, inputs.except(:line)
|
332
|
+
github.repos.commits.create_comment user, repo, sha, inputs.except(:line)
|
292
333
|
}.to raise_error(Github::Error::RequiredParams)
|
293
334
|
end
|
294
335
|
|
295
336
|
it "should fail to create resource if 'path' input is missing" do
|
296
337
|
expect {
|
297
|
-
github.repos.create_comment user, repo, sha, inputs.except(:path)
|
338
|
+
github.repos.commits.create_comment user, repo, sha, inputs.except(:path)
|
298
339
|
}.to raise_error(Github::Error::RequiredParams)
|
299
340
|
end
|
300
341
|
|
301
342
|
it "should fail to create resource if 'position' input is missing" do
|
302
343
|
expect {
|
303
|
-
github.repos.create_comment user, repo, sha, inputs.except(:position)
|
344
|
+
github.repos.commits.create_comment user, repo, sha, inputs.except(:position)
|
304
345
|
}.to raise_error(Github::Error::RequiredParams)
|
305
346
|
end
|
306
347
|
|
307
348
|
it "should create resource successfully" do
|
308
|
-
github.repos.create_comment user, repo, sha, inputs
|
349
|
+
github.repos.commits.create_comment user, repo, sha, inputs
|
309
350
|
a_post("/repos/#{user}/#{repo}/commits/#{sha}/comments").with(inputs).should have_been_made
|
310
351
|
end
|
311
352
|
|
312
353
|
it "should return the resource" do
|
313
|
-
comment = github.repos.create_comment user, repo, sha, inputs
|
354
|
+
comment = github.repos.commits.create_comment user, repo, sha, inputs
|
314
355
|
comment.should be_a Hashie::Mash
|
315
356
|
end
|
316
357
|
|
317
358
|
it "should get the commit comment information" do
|
318
|
-
comment = github.repos.create_comment user, repo, sha, inputs
|
359
|
+
comment = github.repos.commits.create_comment user, repo, sha, inputs
|
319
360
|
comment.user.login.should == 'octocat'
|
320
361
|
end
|
321
362
|
end
|
@@ -329,7 +370,7 @@ describe Github::Repos::Commits do
|
|
329
370
|
|
330
371
|
it "should fail to retrieve resource" do
|
331
372
|
expect {
|
332
|
-
github.repos.create_comment user, repo, sha, inputs
|
373
|
+
github.repos.commits.create_comment user, repo, sha, inputs
|
333
374
|
}.to raise_error(Github::Error::NotFound)
|
334
375
|
end
|
335
376
|
end
|
@@ -341,22 +382,24 @@ describe Github::Repos::Commits do
|
|
341
382
|
context "resource deleted successfully" do
|
342
383
|
before do
|
343
384
|
stub_delete("/repos/#{user}/#{repo}/comments/#{comment_id}").
|
344
|
-
to_return(:body => '', :status => 204,
|
385
|
+
to_return(:body => '', :status => 204,
|
386
|
+
:headers => { :content_type => "application/json; charset=utf-8"})
|
345
387
|
end
|
346
388
|
|
347
389
|
it "should fail to delete without 'user/repo' parameters" do
|
348
|
-
|
349
|
-
|
390
|
+
expect {
|
391
|
+
github.repos.commits.delete_comment
|
392
|
+
}.to raise_error(ArgumentError)
|
350
393
|
end
|
351
394
|
|
352
395
|
it "should fail to delete resource without 'comment_id'" do
|
353
396
|
expect {
|
354
|
-
github.repos.delete_comment user, repo, nil
|
397
|
+
github.repos.commits.delete_comment user, repo, nil
|
355
398
|
}.to raise_error(ArgumentError)
|
356
399
|
end
|
357
400
|
|
358
401
|
it "should delete the resource" do
|
359
|
-
github.repos.delete_comment user, repo, comment_id
|
402
|
+
github.repos.commits.delete_comment user, repo, comment_id
|
360
403
|
a_delete("/repos/#{user}/#{repo}/comments/#{comment_id}").should have_been_made
|
361
404
|
end
|
362
405
|
end
|
@@ -370,41 +413,42 @@ describe Github::Repos::Commits do
|
|
370
413
|
|
371
414
|
it "should fail to find resource" do
|
372
415
|
expect {
|
373
|
-
github.repos.delete_comment user, repo, comment_id
|
416
|
+
github.repos.commits.delete_comment user, repo, comment_id
|
374
417
|
}.to raise_error(Github::Error::NotFound)
|
375
418
|
end
|
376
419
|
end
|
377
420
|
end # delete_comment
|
378
421
|
|
379
|
-
describe "update_comment" do
|
422
|
+
describe "#update_comment" do
|
380
423
|
let(:comment_id) { 1 }
|
381
424
|
let(:inputs) { {'body'=> 'web'} }
|
382
425
|
|
383
426
|
context "resouce created" do
|
384
427
|
before do
|
385
428
|
stub_patch("/repos/#{user}/#{repo}/comments/#{comment_id}").with(inputs).
|
386
|
-
to_return(:body => fixture('repos/commit_comment.json'),
|
387
|
-
|
429
|
+
to_return(:body => fixture('repos/commit_comment.json'),
|
430
|
+
:status => 200,
|
431
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
388
432
|
end
|
389
433
|
|
390
434
|
it "should fail to create resource if 'body' input is missing" do
|
391
435
|
expect {
|
392
|
-
github.repos.update_comment user, repo, comment_id, inputs.except('body')
|
436
|
+
github.repos.commits.update_comment user, repo, comment_id, inputs.except('body')
|
393
437
|
}.to raise_error(Github::Error::RequiredParams)
|
394
438
|
end
|
395
439
|
|
396
440
|
it "should create resource successfully" do
|
397
|
-
github.repos.update_comment user, repo, comment_id, inputs
|
441
|
+
github.repos.commits.update_comment user, repo, comment_id, inputs
|
398
442
|
a_patch("/repos/#{user}/#{repo}/comments/#{comment_id}").with(inputs).should have_been_made
|
399
443
|
end
|
400
444
|
|
401
445
|
it "should return the resource" do
|
402
|
-
comment = github.repos.update_comment user, repo, comment_id, inputs
|
446
|
+
comment = github.repos.commits.update_comment user, repo, comment_id, inputs
|
403
447
|
comment.should be_a Hashie::Mash
|
404
448
|
end
|
405
449
|
|
406
450
|
it "should get the commit comment information" do
|
407
|
-
comment = github.repos.update_comment user, repo, comment_id, inputs
|
451
|
+
comment = github.repos.commits.update_comment user, repo, comment_id, inputs
|
408
452
|
comment.user.login.should == 'octocat'
|
409
453
|
end
|
410
454
|
end
|
@@ -418,7 +462,7 @@ describe Github::Repos::Commits do
|
|
418
462
|
|
419
463
|
it "should fail to retrieve resource" do
|
420
464
|
expect {
|
421
|
-
github.repos.update_comment user, repo, comment_id, inputs
|
465
|
+
github.repos.commits.update_comment user, repo, comment_id, inputs
|
422
466
|
}.to raise_error(Github::Error::NotFound)
|
423
467
|
end
|
424
468
|
end
|