github_api 0.4.6 → 0.4.7
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/features/cassettes/errors/repos/create.yml +33 -23
- data/features/cassettes/gists/comments/all.yml +116 -106
- data/features/cassettes/gists/comments/first.yml +41 -31
- data/features/cassettes/gists/gist.yml +61 -50
- data/features/cassettes/gists/gists/public_all.yml +31 -58
- data/features/cassettes/gists/gists/user_all.yml +44 -34
- data/features/cassettes/pagination/repos.yml +161 -287
- data/features/cassettes/pagination/repos/commits.yml +174 -299
- data/features/cassettes/pagination/repos/commits/next.yml +166 -161
- data/features/cassettes/pagination/repos/commits/sha.yml +127 -121
- data/features/cassettes/pagination/repos/commits/sha/next.yml +130 -250
- data/features/cassettes/pagination/repos/diff.yml +126 -154
- data/features/cassettes/pagination/repos/diff/next.yml +123 -246
- data/features/cassettes/pagination/repos/next.yml +162 -157
- data/features/cassettes/pagination/repos/per_page/each_page.yml +370 -352
- data/features/cassettes/pagination/repos/per_page/first.yml +127 -121
- data/features/cassettes/repos/branches.yml +38 -65
- data/features/cassettes/repos/tags.yml +127 -175
- data/features/support/vcr.rb +2 -2
- data/lib/github_api/authorization.rb +3 -3
- data/lib/github_api/error.rb +3 -0
- data/lib/github_api/error/client_error.rb +20 -0
- data/lib/github_api/error/invalid_options.rb +18 -0
- data/lib/github_api/error/required_params.rb +18 -0
- data/lib/github_api/error/service_error.rb +1 -1
- data/lib/github_api/error/validations.rb +18 -0
- data/lib/github_api/gists.rb +1 -5
- data/lib/github_api/gists/comments.rb +2 -8
- data/lib/github_api/git_data/blobs.rb +1 -2
- data/lib/github_api/git_data/commits.rb +1 -2
- data/lib/github_api/git_data/references.rb +2 -4
- data/lib/github_api/git_data/trees.rb +1 -1
- data/lib/github_api/issues.rb +1 -2
- data/lib/github_api/issues/comments.rb +2 -2
- data/lib/github_api/issues/labels.rb +2 -4
- data/lib/github_api/issues/milestones.rb +2 -4
- data/lib/github_api/orgs/teams.rb +3 -4
- data/lib/github_api/repos.rb +9 -3
- data/lib/github_api/repos/commits.rb +2 -2
- data/lib/github_api/repos/downloads.rb +1 -2
- data/lib/github_api/repos/hooks.rb +2 -8
- data/lib/github_api/repos/keys.rb +2 -3
- data/lib/github_api/validation.rb +5 -1
- data/lib/github_api/version.rb +1 -1
- data/spec/github/api_factory_spec.rb +2 -1
- data/spec/github/api_spec.rb +4 -2
- data/spec/github/authorization_spec.rb +19 -28
- data/spec/github/authorizations_spec.rb +2 -1
- data/spec/github/client_spec.rb +4 -1
- data/spec/github/deprecation_spec.rb +2 -1
- data/spec/github/error/client_error_spec.rb +28 -0
- data/spec/github/error/invalid_options_spec.rb +21 -0
- data/spec/github/error/required_params_spec.rb +21 -0
- data/spec/github/events_spec.rb +4 -4
- data/spec/github/filter_spec.rb +2 -2
- data/spec/github/gists/comments_spec.rb +8 -4
- data/spec/github/gists_spec.rb +19 -14
- data/spec/github/git_data/blobs_spec.rb +10 -4
- data/spec/github/git_data/commits_spec.rb +13 -6
- data/spec/github/git_data/references_spec.rb +13 -8
- data/spec/github/git_data/tags_spec.rb +8 -3
- data/spec/github/git_data/trees_spec.rb +9 -3
- data/spec/github/issues/comments_spec.rb +10 -3
- data/spec/github/issues/events_spec.rb +8 -3
- data/spec/github/issues/labels_spec.rb +13 -7
- data/spec/github/issues/milestones_spec.rb +10 -3
- data/spec/github/issues_spec.rb +3 -3
- data/spec/github/mime_type_spec.rb +64 -64
- data/spec/github/orgs/members_spec.rb +2 -11
- data/spec/github/orgs/teams_spec.rb +9 -9
- data/spec/github/orgs_spec.rb +22 -8
- data/spec/github/page_iterator_spec.rb +2 -1
- data/spec/github/page_links_spec.rb +2 -1
- data/spec/github/paged_request_spec.rb +2 -1
- data/spec/github/pull_requests/comments_spec.rb +9 -3
- data/spec/github/pull_requests_spec.rb +6 -2
- data/spec/github/repos/collaborators_spec.rb +12 -7
- data/spec/github/repos/commits_spec.rb +20 -14
- data/spec/github/repos/downloads_spec.rb +19 -8
- data/spec/github/repos/forks_spec.rb +6 -3
- data/spec/github/repos/hooks_spec.rb +14 -8
- data/spec/github/repos/keys_spec.rb +8 -6
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -11
- data/spec/github/repos/watching_spec.rb +15 -38
- data/spec/github/repos_spec.rb +35 -39
- data/spec/github/request_spec.rb +4 -0
- data/spec/github/response/helpers_spec.rb +0 -2
- data/spec/github/result_spec.rb +2 -3
- data/spec/github/users/followers_spec.rb +6 -8
- data/spec/github/users_spec.rb +123 -123
- data/spec/github/validation_spec.rb +8 -7
- data/spec/github_spec.rb +6 -7
- data/spec/spec_helper.rb +2 -2
- metadata +36 -21
- data/features/cassettes/gists/star.yml +0 -34
- data/features/cassettes/pagination/repos/per_page/1.yml +0 -134
- data/features/cassettes/repos/teams.yml +0 -38
data/lib/github_api/version.rb
CHANGED
data/spec/github/api_spec.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Github::API do
|
|
4
|
-
|
|
5
4
|
let(:api) { Github::API.new }
|
|
6
5
|
let(:repos) { Github::Repos }
|
|
7
6
|
|
|
@@ -30,8 +29,11 @@ describe Github::API do
|
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
context '_process_basic_auth' do
|
|
32
|
+
let(:github) { Github.new :basic_auth => 'login:password' }
|
|
33
|
+
|
|
34
|
+
after { reset_authentication_for github }
|
|
35
|
+
|
|
33
36
|
it 'should parse authentication params' do
|
|
34
|
-
github = Github.new :basic_auth => 'login:password'
|
|
35
37
|
github.login.should eq 'login'
|
|
36
38
|
github.password.should eq 'password'
|
|
37
39
|
end
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Github::Authorization do
|
|
4
|
-
|
|
5
6
|
let(:client_id) { '234jl23j4l23j4l' }
|
|
6
7
|
let(:client_secret) { 'asasd79sdf9a7asfd7sfd97s' }
|
|
7
8
|
let(:code) { 'c9798sdf97df98ds'}
|
|
8
|
-
let(:github) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
github.client.should be_a OAuth2::Client
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "should assign site from the options hash" do
|
|
15
|
-
github.client.site.should == 'https://github.com'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "should assign 'authorize_url" do
|
|
19
|
-
github.client.authorize_url.should == 'https://github.com/login/oauth/authorize'
|
|
20
|
-
end
|
|
9
|
+
let(:github) {
|
|
10
|
+
Github.new :client_id => client_id, :client_secret => client_secret
|
|
11
|
+
}
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
github.
|
|
13
|
+
after do
|
|
14
|
+
github.client_id, github.client_secret = nil, nil
|
|
15
|
+
reset_authentication_for github
|
|
24
16
|
end
|
|
25
17
|
|
|
26
18
|
context '.client' do
|
|
@@ -29,18 +21,22 @@ describe Github::Authorization do
|
|
|
29
21
|
it "should return OAuth2::Client instance" do
|
|
30
22
|
github.client.should be_a OAuth2::Client
|
|
31
23
|
end
|
|
32
|
-
end
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
it "should assign site from the options hash" do
|
|
26
|
+
github.client.site.should == 'https://github.com'
|
|
27
|
+
end
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
github
|
|
29
|
+
it "should assign 'authorize_url" do
|
|
30
|
+
github.client.authorize_url.should == 'https://github.com/login/oauth/authorize'
|
|
39
31
|
end
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
github.
|
|
33
|
+
it "should assign 'token_url" do
|
|
34
|
+
github.client.token_url.should == 'https://github.com/login/oauth/access_token'
|
|
43
35
|
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context '.auth_code' do
|
|
39
|
+
let(:oauth) { OAuth2::Client.new(client_id, client_secret) }
|
|
44
40
|
|
|
45
41
|
it "should throw an error if no client_id" do
|
|
46
42
|
github.client_id = nil
|
|
@@ -61,10 +57,6 @@ describe Github::Authorization do
|
|
|
61
57
|
end
|
|
62
58
|
|
|
63
59
|
context "authorize_url" do
|
|
64
|
-
before do
|
|
65
|
-
github = Github.new :client_id => client_id, :client_secret => client_secret
|
|
66
|
-
end
|
|
67
|
-
|
|
68
60
|
it "should respond to 'authorize_url' " do
|
|
69
61
|
github.should respond_to :authorize_url
|
|
70
62
|
end
|
|
@@ -84,7 +76,6 @@ describe Github::Authorization do
|
|
|
84
76
|
|
|
85
77
|
context "get_token" do
|
|
86
78
|
before do
|
|
87
|
-
github = Github.new :client_id => client_id, :client_secret => client_secret
|
|
88
79
|
stub_request(:post, 'https://github.com/login/oauth/access_token').
|
|
89
80
|
to_return(:body => '', :status => 200, :headers => {})
|
|
90
81
|
end
|
data/spec/github/client_spec.rb
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Error::ClientError do
|
|
6
|
+
describe '#generate_message' do
|
|
7
|
+
let(:error) { described_class.new('message') }
|
|
8
|
+
let(:attributes) do
|
|
9
|
+
{
|
|
10
|
+
:problem => 'Oh no!',
|
|
11
|
+
:summary => 'Fix this!',
|
|
12
|
+
:resolution => 'Glue it!'
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'generates problem line' do
|
|
17
|
+
error.generate_message(attributes).should include "Problem:\n Oh no!"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'generates summary line' do
|
|
21
|
+
error.generate_message(attributes).should include "Summary:\n Fix this!"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'generates resolution line' do
|
|
25
|
+
error.generate_message(attributes).should include "Resolution:\n Glue it!"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end # Github::Error::ClientError
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Error::InvalidOptions do
|
|
6
|
+
describe '#message' do
|
|
7
|
+
let(:error) { described_class.new({:invalid => true}, [:valid]) }
|
|
8
|
+
|
|
9
|
+
it 'contains the problem in the message' do
|
|
10
|
+
error.message.should include "Invalid option invalid provided for this request."
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'contains the summary in the message' do
|
|
14
|
+
error.message.should include "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast."
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'contains the resolution in the message' do
|
|
18
|
+
error.message.should include "Valid options are: valid, make sure these are the ones you are using"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end # Github::Error::InvalidOptions
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Error::RequiredParams do
|
|
6
|
+
describe '#message' do
|
|
7
|
+
let(:error) { described_class.new({:extra => true}, [:required]) }
|
|
8
|
+
|
|
9
|
+
it 'contains the problem in the message' do
|
|
10
|
+
error.message.should include "Missing required parameters: extra provided for this request."
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'contains the summary in the message' do
|
|
14
|
+
error.message.should include "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast."
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'contains the resolution in the message' do
|
|
18
|
+
error.message.should include "Required parameters are: required, make sure these are the ones you are using"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end # Github::Error::RequiredParams
|
data/spec/github/events_spec.rb
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Github::Events do
|
|
4
|
-
|
|
5
6
|
let(:github) { Github.new }
|
|
6
7
|
let(:user) { 'peter-murach' }
|
|
7
8
|
let(:repo) { 'github' }
|
|
8
9
|
|
|
10
|
+
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
11
|
+
|
|
9
12
|
describe "public" do
|
|
10
13
|
context "resource found" do
|
|
11
14
|
before do
|
|
@@ -61,7 +64,6 @@ describe Github::Events do
|
|
|
61
64
|
end
|
|
62
65
|
|
|
63
66
|
it "should fail to get resource without username" do
|
|
64
|
-
github.user, github.repo = nil, nil
|
|
65
67
|
expect { github.events.repository nil, repo }.to raise_error(ArgumentError)
|
|
66
68
|
end
|
|
67
69
|
|
|
@@ -114,7 +116,6 @@ describe Github::Events do
|
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
it "should fail to get resource without username" do
|
|
117
|
-
github.user, github.repo = nil, nil
|
|
118
119
|
expect { github.events.issue nil, repo }.to raise_error(ArgumentError)
|
|
119
120
|
end
|
|
120
121
|
|
|
@@ -167,7 +168,6 @@ describe Github::Events do
|
|
|
167
168
|
end
|
|
168
169
|
|
|
169
170
|
it "should fail to get resource without username" do
|
|
170
|
-
github.user, github.repo = nil, nil
|
|
171
171
|
expect { github.events.network nil, repo }.to raise_error(ArgumentError)
|
|
172
172
|
end
|
|
173
173
|
|
data/spec/github/filter_spec.rb
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'spec_helper'
|
|
4
4
|
|
|
5
|
+
describe Github::Gists::Comments do
|
|
6
|
+
let(:github) { Github.new }
|
|
5
7
|
let(:gist_id) { '1' }
|
|
6
8
|
let(:comment_id) { 1 }
|
|
7
9
|
|
|
10
|
+
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
11
|
+
|
|
8
12
|
describe "#comments" do
|
|
9
13
|
context 'check aliases' do
|
|
10
14
|
it { github.gists.should respond_to :comments }
|
|
@@ -132,7 +136,7 @@ describe Github::Gists::Comments, :type => :base do
|
|
|
132
136
|
it "should fail to create resource if 'content' input is missing" do
|
|
133
137
|
expect {
|
|
134
138
|
github.gists.create_comment gist_id, inputs.except('body')
|
|
135
|
-
}.to raise_error(
|
|
139
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
136
140
|
end
|
|
137
141
|
|
|
138
142
|
it "should create resource successfully" do
|
|
@@ -184,7 +188,7 @@ describe Github::Gists::Comments, :type => :base do
|
|
|
184
188
|
it "should fail to create resource if 'content' input is missing" do
|
|
185
189
|
expect {
|
|
186
190
|
github.gists.edit_comment comment_id, inputs.except('body')
|
|
187
|
-
}.to raise_error(
|
|
191
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
188
192
|
end
|
|
189
193
|
|
|
190
194
|
it "should create resource successfully" do
|
data/spec/github/gists_spec.rb
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'spec_helper'
|
|
4
4
|
|
|
5
|
+
describe Github::Gists do
|
|
6
|
+
let(:github) { Github.new }
|
|
7
|
+
let(:user) { 'peter-murach' }
|
|
5
8
|
let(:gist_id) { '1' }
|
|
6
9
|
|
|
10
|
+
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
11
|
+
|
|
7
12
|
describe "#gists" do
|
|
8
13
|
context 'check aliases' do
|
|
9
14
|
it { github.gists.should respond_to :gists }
|
|
@@ -60,7 +65,6 @@ describe Github::Gists, :type => :base do
|
|
|
60
65
|
|
|
61
66
|
context '- public' do
|
|
62
67
|
before do
|
|
63
|
-
github.user = nil
|
|
64
68
|
stub_get("/gists/public").
|
|
65
69
|
to_return(:body => fixture('gists/gists.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
66
70
|
end
|
|
@@ -73,15 +77,12 @@ describe Github::Gists, :type => :base do
|
|
|
73
77
|
|
|
74
78
|
context '- authenticated user' do
|
|
75
79
|
before do
|
|
76
|
-
github.user = nil
|
|
77
80
|
github.oauth_token = OAUTH_TOKEN
|
|
78
81
|
stub_get("/gists").
|
|
79
82
|
with(:query => {:access_token => OAUTH_TOKEN}).
|
|
80
83
|
to_return(:body => fixture('gists/gists.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
81
84
|
end
|
|
82
|
-
after
|
|
83
|
-
github.oauth_token = nil
|
|
84
|
-
end
|
|
85
|
+
after { github.oauth_token = nil }
|
|
85
86
|
|
|
86
87
|
it "should get the resources" do
|
|
87
88
|
github.gists.gists
|
|
@@ -137,12 +138,9 @@ describe Github::Gists, :type => :base do
|
|
|
137
138
|
}.to raise_error(Github::Error::NotFound)
|
|
138
139
|
end
|
|
139
140
|
end
|
|
140
|
-
|
|
141
141
|
end # starred
|
|
142
142
|
|
|
143
143
|
describe "#gist" do
|
|
144
|
-
let(:gist_id) { '1' }
|
|
145
|
-
|
|
146
144
|
context 'check aliases' do
|
|
147
145
|
it { github.gists.should respond_to :gist }
|
|
148
146
|
it { github.gists.should respond_to :get_gist }
|
|
@@ -211,16 +209,23 @@ describe Github::Gists, :type => :base do
|
|
|
211
209
|
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
212
210
|
end
|
|
213
211
|
|
|
214
|
-
it "should fail to create resource if '
|
|
212
|
+
it "should fail to create resource if 'files' input is missing" do
|
|
215
213
|
expect {
|
|
216
214
|
github.gists.create_gist inputs.except('files')
|
|
217
|
-
}.to raise_error(
|
|
215
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "should fail to create resource if 'content' input is missing" do
|
|
219
|
+
pending 'add validation for nested attributes'
|
|
220
|
+
expect {
|
|
221
|
+
github.gists.create_gist inputs.except('content')
|
|
222
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
218
223
|
end
|
|
219
224
|
|
|
220
|
-
it "should fail to create resource if '
|
|
225
|
+
it "should fail to create resource if 'public' input is missing" do
|
|
221
226
|
expect {
|
|
222
227
|
github.gists.create_gist inputs.except('public')
|
|
223
|
-
}.to raise_error(
|
|
228
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
224
229
|
end
|
|
225
230
|
|
|
226
231
|
it "should create resource successfully" do
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'spec_helper'
|
|
4
4
|
|
|
5
|
+
describe Github::GitData::Blobs do
|
|
6
|
+
let(:github) { Github.new }
|
|
7
|
+
let(:user) { 'peter-murach' }
|
|
8
|
+
let(:repo) { 'github' }
|
|
5
9
|
let(:sha) { "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" }
|
|
6
10
|
|
|
11
|
+
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
12
|
+
|
|
7
13
|
it { described_class::VALID_BLOB_PARAM_NAMES.should_not be_nil }
|
|
8
14
|
|
|
9
15
|
describe "blob" do
|
|
@@ -69,13 +75,13 @@ describe Github::GitData::Blobs, :type => :base do
|
|
|
69
75
|
it "should fail to create resource if 'content' input is missing" do
|
|
70
76
|
expect {
|
|
71
77
|
github.git_data.create_blob user, repo, inputs.except('content')
|
|
72
|
-
}.to raise_error(
|
|
78
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
73
79
|
end
|
|
74
80
|
|
|
75
81
|
it "should fail to create resource if 'encoding' input is missing" do
|
|
76
82
|
expect {
|
|
77
83
|
github.git_data.create_blob user, repo, inputs.except('encoding')
|
|
78
|
-
}.to raise_error(
|
|
84
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
it "should create resource successfully" do
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Github::GitData::Commits, :type => :base do
|
|
4
|
-
|
|
6
|
+
let(:github) { Github.new }
|
|
7
|
+
let(:user) { 'peter-murach' }
|
|
8
|
+
let(:repo) { 'github' }
|
|
5
9
|
let(:sha) { "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" }
|
|
6
10
|
|
|
11
|
+
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
12
|
+
|
|
7
13
|
it { described_class::VALID_COMMIT_PARAM_NAMES.should_not be_nil }
|
|
8
14
|
|
|
9
15
|
describe "commit" do
|
|
@@ -17,7 +23,9 @@ describe Github::GitData::Commits, :type => :base do
|
|
|
17
23
|
end
|
|
18
24
|
|
|
19
25
|
it "should fail to get resource without sha" do
|
|
20
|
-
expect {
|
|
26
|
+
expect {
|
|
27
|
+
github.git_data.commit(user, repo, nil)
|
|
28
|
+
}.to raise_error(ArgumentError)
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
it "should get the resource" do
|
|
@@ -77,19 +85,19 @@ describe Github::GitData::Commits, :type => :base do
|
|
|
77
85
|
it "should fail to create resource if 'message' input is missing" do
|
|
78
86
|
expect {
|
|
79
87
|
github.git_data.create_commit user, repo, inputs.except('message')
|
|
80
|
-
}.to raise_error(
|
|
88
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
81
89
|
end
|
|
82
90
|
|
|
83
91
|
it "should fail to create resource if 'tree' input is missing" do
|
|
84
92
|
expect {
|
|
85
93
|
github.git_data.create_commit user, repo, inputs.except('tree')
|
|
86
|
-
}.to raise_error(
|
|
94
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
87
95
|
end
|
|
88
96
|
|
|
89
97
|
it "should fail to create resource if 'parents' input is missing" do
|
|
90
98
|
expect {
|
|
91
99
|
github.git_data.create_commit user, repo, inputs.except('parents')
|
|
92
|
-
}.to raise_error(
|
|
100
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
93
101
|
end
|
|
94
102
|
|
|
95
103
|
it "should create resource successfully" do
|
|
@@ -112,7 +120,6 @@ describe Github::GitData::Commits, :type => :base do
|
|
|
112
120
|
before do
|
|
113
121
|
stub_post("/repos/#{user}/#{repo}/git/commits").with(inputs).
|
|
114
122
|
to_return(:body => fixture('git_data/commit.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
115
|
-
|
|
116
123
|
end
|
|
117
124
|
|
|
118
125
|
it "should faile to retrieve resource" do
|