github_api 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -1
- data/features/README.rdoc +4 -4
- data/features/cassettes/gitignore/get.yml +60 -0
- data/features/cassettes/gitignore/get_raw.yml +224 -0
- data/features/cassettes/gitignore/list.yml +67 -0
- data/features/cassettes/issues/comments/get.yml +71 -0
- data/features/cassettes/issues/comments/list_issue.yml +82 -0
- data/features/cassettes/issues/comments/list_repo.yml +266 -0
- data/features/cassettes/pull_requests/comments/get.yml +159 -0
- data/features/cassettes/pull_requests/comments/list_pull.yml +54 -0
- data/features/cassettes/pull_requests/comments/list_repo.yml +54 -0
- data/features/cassettes/repos/list_repos.yml +129 -0
- data/features/cassettes/users/all.yml +256 -0
- data/features/gitignore.feature +37 -0
- data/features/issues/comments.feature +37 -0
- data/features/pull_requests/comments.feature +27 -0
- data/features/repos.feature +8 -0
- data/features/step_definitions/common_steps.rb +2 -0
- data/features/users.feature +8 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/client.rb +5 -0
- data/lib/github_api/git_data/tags.rb +4 -4
- data/lib/github_api/gitignore.rb +56 -0
- data/lib/github_api/issues/comments.rb +23 -9
- data/lib/github_api/pull_requests/comments.rb +24 -6
- data/lib/github_api/repos.rb +14 -1
- data/lib/github_api/repos/keys.rb +4 -4
- data/lib/github_api/users.rb +21 -0
- data/lib/github_api/users/keys.rb +6 -6
- data/lib/github_api/version.rb +1 -1
- data/spec/fixtures/gitignore/template.json +4 -0
- data/spec/fixtures/gitignore/template_raw +1 -0
- data/spec/fixtures/gitignore/templates.json +9 -0
- data/spec/fixtures/users/users.json +9 -0
- data/spec/github/activity/notifications/mark_spec.rb +1 -1
- data/spec/github/activity/starring/starring_spec.rb +2 -2
- data/spec/github/activity/watching/watching_spec.rb +2 -2
- data/spec/github/git_data/commits/create_spec.rb +75 -0
- data/spec/github/git_data/commits/get_spec.rb +50 -0
- data/spec/github/git_data/commits_spec.rb +1 -126
- data/spec/github/git_data/references/create_spec.rb +67 -0
- data/spec/github/git_data/references/delete_spec.rb +38 -0
- data/spec/github/git_data/references/get_spec.rb +54 -0
- data/spec/github/git_data/references/list_spec.rb +77 -0
- data/spec/github/git_data/references/update_spec.rb +62 -0
- data/spec/github/git_data/references_spec.rb +1 -298
- data/spec/github/git_data/tags/create_spec.rb +61 -0
- data/spec/github/git_data/tags/get_spec.rb +48 -0
- data/spec/github/git_data/tags_spec.rb +0 -108
- data/spec/github/git_data/trees/create_spec.rb +62 -0
- data/spec/github/git_data/trees/get_spec.rb +69 -0
- data/spec/github/git_data/trees_spec.rb +0 -133
- data/spec/github/gitignore/get_spec.rb +54 -0
- data/spec/github/gitignore/list_spec.rb +42 -0
- data/spec/github/issues/comments_spec.rb +46 -11
- data/spec/github/pull_requests/comments_spec.rb +46 -11
- data/spec/github/pull_requests_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +26 -0
- data/spec/github/repos/contents/get_spec.rb +30 -0
- data/spec/github/repos/contents/readme_spec.rb +30 -0
- data/spec/github/repos/hooks/create_spec.rb +68 -0
- data/spec/github/repos/hooks/delete_spec.rb +40 -0
- data/spec/github/repos/hooks/edit_spec.rb +77 -0
- data/spec/github/repos/hooks/get_spec.rb +49 -0
- data/spec/github/repos/hooks/list_spec.rb +54 -0
- data/spec/github/repos/hooks/test_spec.rb +40 -0
- data/spec/github/repos/hooks_spec.rb +2 -337
- data/spec/github/repos/keys/create_spec.rb +50 -0
- data/spec/github/repos/keys/delete_spec.rb +40 -0
- data/spec/github/repos/keys/edit_spec.rb +40 -0
- data/spec/github/repos/keys/get_spec.rb +43 -0
- data/spec/github/repos/keys/list_spec.rb +52 -0
- data/spec/github/repos/keys_spec.rb +2 -213
- data/spec/github/repos/list_spec.rb +19 -3
- data/spec/github/repos/merging/merge_spec.rb +58 -0
- data/spec/github/repos/pub_sub_hubbub_spec.rb +16 -14
- data/spec/github/repos/statuses/create_spec.rb +54 -0
- data/spec/github/repos/statuses/list_spec.rb +53 -0
- data/spec/github/repos/statuses_spec.rb +1 -114
- data/spec/github/users/emails/add_spec.rb +33 -0
- data/spec/github/users/emails/delete_spec.rb +33 -0
- data/spec/github/users/emails/list_spec.rb +52 -0
- data/spec/github/users/followers/list_spec.rb +68 -0
- data/spec/github/users/followers_spec.rb +0 -70
- data/spec/github/users/get_spec.rb +66 -0
- data/spec/github/users/keys/create_spec.rb +51 -0
- data/spec/github/users/keys/delete_spec.rb +37 -0
- data/spec/github/users/keys/get_spec.rb +50 -0
- data/spec/github/users/keys/list_spec.rb +50 -0
- data/spec/github/users/keys/update_spec.rb +56 -0
- data/spec/github/users/list_spec.rb +45 -0
- data/spec/github/users/update_spec.rb +56 -0
- metadata +96 -43
- data/spec/github/repos/contents_spec.rb +0 -65
- data/spec/github/repos/merging_spec.rb +0 -71
- data/spec/github/repos/starring_spec.rb +0 -4
- data/spec/github/users/emails_spec.rb +0 -110
- data/spec/github/users/keys_spec.rb +0 -256
- data/spec/github/users_spec.rb +0 -128
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Hooks, '#list' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:hook_id) { 1 }
|
|
9
|
+
let(:request_path) {"/repos/#{user}/#{repo}/hooks/#{hook_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 "resource removed successfully" do
|
|
19
|
+
let(:body) { '' }
|
|
20
|
+
let(:status) { 204 }
|
|
21
|
+
|
|
22
|
+
it "should fail to delete without 'user/repo' parameters" do
|
|
23
|
+
expect { subject.delete }.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should fail to delete resource without 'hook_id'" do
|
|
27
|
+
expect { subject.delete user, repo }.to raise_error(ArgumentError)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should delete the resource" do
|
|
31
|
+
subject.delete user, repo, hook_id
|
|
32
|
+
a_delete(request_path).should have_been_made
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it_should_behave_like 'request failure' do
|
|
37
|
+
let(:requestable) { subject.delete user, repo, hook_id }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # delete
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Hooks, '#list' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:hook_id) { 1 }
|
|
9
|
+
let(:request_path) {"/repos/#{user}/#{repo}/hooks/#{hook_id}" }
|
|
10
|
+
let(:inputs) {
|
|
11
|
+
{
|
|
12
|
+
:name => 'web',
|
|
13
|
+
:config => {
|
|
14
|
+
:url => "http://something.com/webhook",
|
|
15
|
+
:address => "test@example.com",
|
|
16
|
+
:subdomain => "github",
|
|
17
|
+
:room => "Commits",
|
|
18
|
+
:token => "abc123"
|
|
19
|
+
},
|
|
20
|
+
:active => true,
|
|
21
|
+
:unrelated => true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
before {
|
|
26
|
+
stub_patch(request_path).with(inputs.except(:unrelated)).
|
|
27
|
+
to_return(:body => body, :status => status,
|
|
28
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
after { reset_authentication_for(subject) }
|
|
32
|
+
|
|
33
|
+
context "resource edited successfully" do
|
|
34
|
+
let(:body) { fixture("repos/hook.json") }
|
|
35
|
+
let(:status) { 200 }
|
|
36
|
+
|
|
37
|
+
it "should fail to edit without 'user/repo' parameters" do
|
|
38
|
+
expect { subject.edit }.to raise_error(ArgumentError)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should fail to edit resource without 'name' parameter" do
|
|
42
|
+
expect{
|
|
43
|
+
subject.edit user, repo, inputs.except(:name)
|
|
44
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should fail to edit resource without 'hook_id'" do
|
|
48
|
+
expect { subject.edit user, repo }.to raise_error(ArgumentError)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should fail to edit resource without 'config' parameter" do
|
|
52
|
+
expect {
|
|
53
|
+
subject.edit user, repo, hook_id, inputs.except(:config)
|
|
54
|
+
}.to raise_error(Github::Error::RequiredParams)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should edit the resource" do
|
|
58
|
+
subject.edit user, repo, hook_id, inputs
|
|
59
|
+
a_patch(request_path).with(inputs).should have_been_made
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should return resource" do
|
|
63
|
+
hook = subject.edit user, repo, hook_id, inputs
|
|
64
|
+
hook.should be_a Hashie::Mash
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should be able to retrieve information" do
|
|
68
|
+
hook = subject.edit user, repo, hook_id, inputs
|
|
69
|
+
hook.name.should == 'web'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it_should_behave_like 'request failure' do
|
|
74
|
+
let(:requestable) { subject.edit user, repo, hook_id, inputs }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end # edit
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Hooks, '#get' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:hook_id) { 1 }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/hooks/#{hook_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('repos/hook.json') }
|
|
20
|
+
let(:status) { 200 }
|
|
21
|
+
|
|
22
|
+
it { subject.should respond_to :find }
|
|
23
|
+
|
|
24
|
+
it "should fail to get resource without hook id" do
|
|
25
|
+
expect { subject.get user, repo }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get the resource" do
|
|
29
|
+
subject.get user, repo, hook_id
|
|
30
|
+
a_get(request_path).should have_been_made
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get hook information" do
|
|
34
|
+
hook = subject.get user, repo, hook_id
|
|
35
|
+
hook.id.should == hook_id
|
|
36
|
+
hook.name.should == 'web'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should return mash" do
|
|
40
|
+
hook = subject.get user, repo, hook_id
|
|
41
|
+
hook.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, hook_id }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end # get
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Hooks, '#list' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:request_path) { "/repos/#{user}/#{repo}/hooks" }
|
|
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('repos/hooks.json') }
|
|
19
|
+
let(:status) { 200 }
|
|
20
|
+
|
|
21
|
+
it { subject.should respond_to :all }
|
|
22
|
+
|
|
23
|
+
it { expect { subject.list }.to raise_error(ArgumentError) }
|
|
24
|
+
|
|
25
|
+
it "should fail to get resource without required arguments" do
|
|
26
|
+
expect { subject.list user }.to raise_error(ArgumentError)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should get the resources" do
|
|
30
|
+
subject.list user, repo
|
|
31
|
+
a_get(request_path).should have_been_made
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it_should_behave_like 'an array of resources' do
|
|
35
|
+
let(:requestable) { subject.list user, repo }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should get hook information" do
|
|
39
|
+
hooks = subject.list user, repo
|
|
40
|
+
hooks.first.name.should == 'web'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should yield to a block" do
|
|
44
|
+
yielded = []
|
|
45
|
+
result = subject.list(user, repo) { |obj| yielded << obj }
|
|
46
|
+
yielded.should == result
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it_should_behave_like 'request failure' do
|
|
51
|
+
let(:requestable) { subject.list user, repo }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end # list
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::Repos::Hooks, '#test' do
|
|
6
|
+
let(:user) { 'peter-murach' }
|
|
7
|
+
let(:repo) { 'github' }
|
|
8
|
+
let(:hook_id) { 1 }
|
|
9
|
+
let(:request_path) { "/repos/#{user}/#{repo}/hooks/#{hook_id}/test" }
|
|
10
|
+
|
|
11
|
+
before {
|
|
12
|
+
stub_post(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 tested successfully" do
|
|
19
|
+
let(:body) { '' }
|
|
20
|
+
let(:status) { 204 }
|
|
21
|
+
|
|
22
|
+
it "should fail to test without 'user/repo' parameters" do
|
|
23
|
+
expect { subject.test }.to raise_error(ArgumentError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should fail to test resource without 'hook_id'" do
|
|
27
|
+
expect { subject.test user, repo }.to raise_error(ArgumentError)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should trigger test for the resource" do
|
|
31
|
+
subject.test user, repo, hook_id
|
|
32
|
+
a_post(request_path).should have_been_made
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it_should_behave_like 'request failure' do
|
|
37
|
+
let(:requestable) { subject.test user, repo, hook_id }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # test
|
|
@@ -3,346 +3,11 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe Github::Repos::Hooks do
|
|
6
|
-
let(:github) { Github.new }
|
|
7
|
-
let(:user) { 'peter-murach' }
|
|
8
|
-
let(:repo) { 'github' }
|
|
9
|
-
|
|
10
|
-
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
|
11
6
|
|
|
12
7
|
it { described_class::VALID_HOOK_PARAM_NAMES.should_not be_nil }
|
|
13
|
-
it { described_class::VALID_HOOK_PARAM_VALUES.should_not be_nil }
|
|
14
|
-
it { described_class::REQUIRED_PARAMS.should_not be_nil }
|
|
15
|
-
|
|
16
|
-
describe "#list" do
|
|
17
|
-
it { github.repos.hooks.should respond_to :all }
|
|
18
|
-
|
|
19
|
-
context "resource found" do
|
|
20
|
-
before do
|
|
21
|
-
stub_get("/repos/#{user}/#{repo}/hooks").
|
|
22
|
-
to_return(:body => fixture('repos/hooks.json'), :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 { github.repos.hooks.list }.to raise_error(ArgumentError)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should get the resources" do
|
|
31
|
-
github.repos.hooks.list user, repo
|
|
32
|
-
a_get("/repos/#{user}/#{repo}/hooks").should have_been_made
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should return array of resources" do
|
|
36
|
-
hooks = github.repos.hooks.list user, repo
|
|
37
|
-
hooks.should be_an Array
|
|
38
|
-
hooks.should have(1).items
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should be a mash type" do
|
|
42
|
-
hooks = github.repos.hooks.list user, repo
|
|
43
|
-
hooks.first.should be_a Hashie::Mash
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should get hook information" do
|
|
47
|
-
hooks = github.repos.hooks.list user, repo
|
|
48
|
-
hooks.first.name.should == 'web'
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should yield to a block" do
|
|
52
|
-
github.repos.hooks.should_receive(:list).with(user, repo).and_yield('web')
|
|
53
|
-
github.repos.hooks.list(user, repo) { |param| 'web' }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "resource not found" do
|
|
58
|
-
before do
|
|
59
|
-
stub_get("/repos/#{user}/#{repo}/hooks").
|
|
60
|
-
to_return(:body => "", :status => [404, "Not Found"])
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should return 404 with a message 'Not Found'" do
|
|
64
|
-
expect {
|
|
65
|
-
github.repos.hooks.list user, repo
|
|
66
|
-
}.to raise_error(Github::Error::NotFound)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end # list
|
|
70
|
-
|
|
71
|
-
describe "#get" do
|
|
72
|
-
let(:hook_id) { 1 }
|
|
73
|
-
|
|
74
|
-
it { github.repos.hooks.should respond_to :find }
|
|
75
|
-
|
|
76
|
-
context "resource found" do
|
|
77
|
-
before do
|
|
78
|
-
stub_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
79
|
-
to_return(:body => fixture('repos/hook.json'), :status => 200,
|
|
80
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should fail to get resource without hook id" do
|
|
84
|
-
expect {
|
|
85
|
-
github.repos.hooks.get user, repo, nil
|
|
86
|
-
}.to raise_error(ArgumentError)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should get the resource" do
|
|
90
|
-
github.repos.hooks.get user, repo, hook_id
|
|
91
|
-
a_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "should get hook information" do
|
|
95
|
-
hook = github.repos.hooks.get user, repo, hook_id
|
|
96
|
-
hook.id.should == hook_id
|
|
97
|
-
hook.name.should == 'web'
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "should return mash" do
|
|
101
|
-
hook = github.repos.hooks.get user, repo, hook_id
|
|
102
|
-
hook.should be_a Hashie::Mash
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context "resource not found" do
|
|
107
|
-
before do
|
|
108
|
-
stub_get("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
109
|
-
to_return(:body => fixture('repos/hook.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it "should fail to retrive resource" do
|
|
113
|
-
expect {
|
|
114
|
-
github.repos.hooks.get user, repo, hook_id
|
|
115
|
-
}.to raise_error(Github::Error::NotFound)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end # get
|
|
119
|
-
|
|
120
|
-
describe "#create" do
|
|
121
|
-
let(:inputs) {
|
|
122
|
-
{
|
|
123
|
-
'name' => 'web',
|
|
124
|
-
'config' => {
|
|
125
|
-
'url' => "http://something.com/webhook",
|
|
126
|
-
'address' => "test@example.com",
|
|
127
|
-
'subdomain' => "github",
|
|
128
|
-
'room' => "Commits",
|
|
129
|
-
'token' => "abc123"
|
|
130
|
-
},
|
|
131
|
-
'active' => true,
|
|
132
|
-
'unrelated' => true
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
context "resouce created" do
|
|
137
|
-
before do
|
|
138
|
-
stub_post("/repos/#{user}/#{repo}/hooks").
|
|
139
|
-
with(inputs.except('unrelated')).
|
|
140
|
-
to_return(:body => fixture('repos/hook.json'),
|
|
141
|
-
:status => 201,
|
|
142
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "should fail to create resource if 'name' input is missing" do
|
|
146
|
-
expect {
|
|
147
|
-
github.repos.hooks.create user, repo, inputs.except('name')
|
|
148
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should failt to create resource if 'config' input is missing" do
|
|
152
|
-
expect {
|
|
153
|
-
github.repos.hooks.create user, repo, inputs.except('config')
|
|
154
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "should create resource successfully" do
|
|
158
|
-
github.repos.hooks.create user, repo, inputs
|
|
159
|
-
a_post("/repos/#{user}/#{repo}/hooks").with(inputs).should have_been_made
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "should return the resource" do
|
|
163
|
-
hook = github.repos.hooks.create user, repo, inputs
|
|
164
|
-
hook.should be_a Hashie::Mash
|
|
165
|
-
end
|
|
166
8
|
|
|
167
|
-
|
|
168
|
-
hook = github.repos.hooks.create user, repo, inputs
|
|
169
|
-
hook.name.should == 'web'
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
context "fail to create resource" do
|
|
174
|
-
before do
|
|
175
|
-
stub_post("/repos/#{user}/#{repo}/hooks").with(inputs).
|
|
176
|
-
to_return(:body => fixture('repos/hook.json'), :status => 404,
|
|
177
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it "should fail to retrieve resource" do
|
|
181
|
-
expect {
|
|
182
|
-
github.repos.hooks.create user, repo, inputs
|
|
183
|
-
}.to raise_error(Github::Error::NotFound)
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end # create
|
|
187
|
-
|
|
188
|
-
describe "#edit" do
|
|
189
|
-
let(:hook_id) { 1 }
|
|
190
|
-
let(:inputs) {
|
|
191
|
-
{
|
|
192
|
-
:name => 'web',
|
|
193
|
-
:config => {
|
|
194
|
-
:url => "http://something.com/webhook",
|
|
195
|
-
:address => "test@example.com",
|
|
196
|
-
:subdomain => "github",
|
|
197
|
-
:room => "Commits",
|
|
198
|
-
:token => "abc123"
|
|
199
|
-
},
|
|
200
|
-
:active => true,
|
|
201
|
-
:unrelated => true
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
context "resource edited successfully" do
|
|
206
|
-
before do
|
|
207
|
-
stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
208
|
-
with(inputs.except(:unrelated)).
|
|
209
|
-
to_return(:body => fixture("repos/hook.json"), :status => 200,
|
|
210
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it "should fail to edit without 'user/repo' parameters" do
|
|
214
|
-
expect { github.repos.hooks.edit }.to raise_error(ArgumentError)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
it "should fail to edit resource without 'name' parameter" do
|
|
218
|
-
expect{
|
|
219
|
-
github.repos.hooks.edit user, repo, inputs.except(:name)
|
|
220
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it "should fail to edit resource without 'hook_id'" do
|
|
224
|
-
expect {
|
|
225
|
-
github.repos.hooks.edit user, repo
|
|
226
|
-
}.to raise_error(ArgumentError)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
it "should fail to edit resource without 'config' parameter" do
|
|
230
|
-
expect {
|
|
231
|
-
github.repos.hooks.edit user, repo, hook_id, inputs.except(:config)
|
|
232
|
-
}.to raise_error(Github::Error::RequiredParams)
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it "should edit the resource" do
|
|
236
|
-
github.repos.hooks.edit user, repo, hook_id, inputs
|
|
237
|
-
a_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
238
|
-
with(inputs).should have_been_made
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
it "should return resource" do
|
|
242
|
-
hook = github.repos.hooks.edit user, repo, hook_id, inputs
|
|
243
|
-
hook.should be_a Hashie::Mash
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
it "should be able to retrieve information" do
|
|
247
|
-
hook = github.repos.hooks.edit user, repo, hook_id, inputs
|
|
248
|
-
hook.name.should == 'web'
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
context "failed to edit resource" do
|
|
253
|
-
before do
|
|
254
|
-
stub_patch("/repos/#{user}/#{repo}/hooks/#{hook_id}").with(inputs).
|
|
255
|
-
to_return(:body => fixture("repos/hook.json"), :status => 404,
|
|
256
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it "should fail to find resource" do
|
|
260
|
-
expect {
|
|
261
|
-
github.repos.hooks.edit user, repo, hook_id, inputs
|
|
262
|
-
}.to raise_error(Github::Error::NotFound)
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
end # edit
|
|
266
|
-
|
|
267
|
-
describe "#delete" do
|
|
268
|
-
let(:hook_id) { 1 }
|
|
269
|
-
|
|
270
|
-
context "resource removed successfully" do
|
|
271
|
-
before do
|
|
272
|
-
stub_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
273
|
-
to_return(:body => '', :status => 204,
|
|
274
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
it "should fail to delete without 'user/repo' parameters" do
|
|
278
|
-
expect { github.repos.hooks.delete }.to raise_error(ArgumentError)
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
it "should fail to delete resource without 'hook_id'" do
|
|
282
|
-
expect {
|
|
283
|
-
github.repos.hooks.delete user, repo
|
|
284
|
-
}.to raise_error(ArgumentError)
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
it "should delete the resource" do
|
|
288
|
-
github.repos.hooks.delete user, repo, hook_id
|
|
289
|
-
a_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").should have_been_made
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
context "failed to edit resource" do
|
|
294
|
-
before do
|
|
295
|
-
stub_delete("/repos/#{user}/#{repo}/hooks/#{hook_id}").
|
|
296
|
-
to_return(:body => fixture("repos/hook.json"), :status => 404, :headers => { :content_type => "application/json; charset=utf-8"})
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
it "should fail to find resource" do
|
|
300
|
-
expect {
|
|
301
|
-
github.repos.hooks.delete user, repo, hook_id
|
|
302
|
-
}.to raise_error(Github::Error::NotFound)
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
end # delete
|
|
306
|
-
|
|
307
|
-
describe "#test" do
|
|
308
|
-
let(:hook_id) { 1 }
|
|
309
|
-
|
|
310
|
-
context "resource tested successfully" do
|
|
311
|
-
before do
|
|
312
|
-
stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
|
|
313
|
-
to_return(:body => '', :status => 204,
|
|
314
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
it "should fail to test without 'user/repo' parameters" do
|
|
318
|
-
expect { github.repos.hooks.test }.to raise_error(ArgumentError)
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it "should fail to test resource without 'hook_id'" do
|
|
322
|
-
expect {
|
|
323
|
-
github.repos.hooks.test user, repo
|
|
324
|
-
}.to raise_error(ArgumentError)
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
it "should trigger test for the resource" do
|
|
328
|
-
github.repos.hooks.test user, repo, hook_id
|
|
329
|
-
a_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").should have_been_made
|
|
330
|
-
end
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
context "failed to test resource" do
|
|
334
|
-
before do
|
|
335
|
-
stub_post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test").
|
|
336
|
-
to_return(:body => '', :status => 404,
|
|
337
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
|
338
|
-
end
|
|
9
|
+
it { described_class::VALID_HOOK_PARAM_VALUES.should_not be_nil }
|
|
339
10
|
|
|
340
|
-
|
|
341
|
-
expect {
|
|
342
|
-
github.repos.hooks.test user, repo, hook_id
|
|
343
|
-
}.to raise_error(Github::Error::NotFound)
|
|
344
|
-
end
|
|
345
|
-
end
|
|
346
|
-
end # test
|
|
11
|
+
it { described_class::REQUIRED_PARAMS.should_not be_nil }
|
|
347
12
|
|
|
348
13
|
end # Github::Repos::Hooks
|