github_api 0.8.8 → 0.8.9
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/cassettes/orgs/members/list.yml +139 -0
- data/features/cassettes/orgs/members/list_public.yml +140 -0
- data/features/cassettes/orgs/members/member_false.yml +52 -0
- data/features/cassettes/orgs/members/member_public_false.yml +55 -0
- data/features/cassettes/orgs/members/member_public_true.yml +48 -0
- data/features/orgs/members.feature +57 -0
- data/lib/github_api/connection.rb +4 -4
- data/lib/github_api/orgs/members.rb +28 -35
- data/lib/github_api/orgs/teams.rb +14 -13
- data/lib/github_api/version.rb +1 -1
- data/spec/github/gists/create_spec.rb +64 -0
- data/spec/github/gists/delete_spec.rb +31 -0
- data/spec/github/gists/edit_spec.rb +60 -0
- data/spec/github/gists/fork_spec.rb +41 -0
- data/spec/github/gists/get_spec.rb +47 -0
- data/spec/github/gists/gists_spec.rb +7 -0
- data/spec/github/gists/is_starred_spec.rb +42 -0
- data/spec/github/gists/list_spec.rb +78 -0
- data/spec/github/gists/star_spec.rb +30 -0
- data/spec/github/gists/starred_spec.rb +44 -0
- data/spec/github/gists/unstar_spec.rb +30 -0
- data/spec/github/orgs/members/conceal_spec.rb +35 -0
- data/spec/github/orgs/members/delete_spec.rb +33 -0
- data/spec/github/orgs/members/list_spec.rb +82 -0
- data/spec/github/orgs/members/member_spec.rb +65 -0
- data/spec/github/orgs/members/publicize_spec.rb +35 -0
- data/spec/github/orgs/members_spec.rb +0 -277
- data/spec/github/orgs/teams/add_member_spec.rb +38 -0
- data/spec/github/orgs/teams/add_repo_spec.rb +39 -0
- data/spec/github/orgs/teams/create_spec.rb +58 -0
- data/spec/github/orgs/teams/delete_spec.rb +36 -0
- data/spec/github/orgs/teams/edit_spec.rb +57 -0
- data/spec/github/orgs/teams/get_spec.rb +45 -0
- data/spec/github/orgs/teams/list_members_spec.rb +49 -0
- data/spec/github/orgs/teams/list_repos_spec.rb +49 -0
- data/spec/github/orgs/teams/list_spec.rb +49 -0
- data/spec/github/orgs/teams/remove_member_spec.rb +40 -0
- data/spec/github/orgs/teams/remove_repo_spec.rb +40 -0
- data/spec/github/orgs/teams/team_member_spec.rb +40 -0
- data/spec/github/orgs/teams/team_repo_spec.rb +43 -0
- data/spec/github/orgs/teams_spec.rb +2 -566
- metadata +67 -33
- data/spec/github/gists_spec.rb +0 -470
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#add_member' do
|
6
|
+
let(:team_id) { 1 }
|
7
|
+
let(:user) { 'peter-murach' }
|
8
|
+
let(:request_path) { "/teams/#{team_id}/members/#{user}" }
|
9
|
+
|
10
|
+
before {
|
11
|
+
stub_put(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 "resouce added" do
|
18
|
+
let(:body) { '' }
|
19
|
+
let(:status) { 204 }
|
20
|
+
|
21
|
+
it "should fail to add resource if 'team_id' input is nil" do
|
22
|
+
expect { subject.add_member nil, user }.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should fail to add resource if 'user' input is nil" do
|
26
|
+
expect { subject.add_member team_id, nil }.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should add resource successfully" do
|
30
|
+
subject.add_member team_id, user
|
31
|
+
a_put(request_path).should have_been_made
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like 'request failure' do
|
36
|
+
let(:requestable) { subject.add_member team_id, user }
|
37
|
+
end
|
38
|
+
end # add_member
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#add_repo' do
|
6
|
+
let(:team_id) { 1 }
|
7
|
+
let(:repo) { 'github' }
|
8
|
+
let(:user) { 'peter-murach' }
|
9
|
+
let(:request_path) { "/teams/#{team_id}/repos/#{user}/#{repo}" }
|
10
|
+
|
11
|
+
before {
|
12
|
+
stub_put(request_path).to_return(:body => body, :status => status,
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
}
|
15
|
+
|
16
|
+
after { reset_authentication_for(subject) }
|
17
|
+
|
18
|
+
context "resouce added" do
|
19
|
+
let(:body) { '' }
|
20
|
+
let(:status) { 204 }
|
21
|
+
|
22
|
+
it "should fail to add resource if 'team_id' input is nil" do
|
23
|
+
expect { subject.add_repo nil, user, repo }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should fail to add resource if 'user' input is nil" do
|
27
|
+
expect { subject.add_repo team_id, nil, repo }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should add resource successfully" do
|
31
|
+
subject.add_repo team_id, user, repo
|
32
|
+
a_put(request_path).should have_been_made
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it_should_behave_like 'request failure' do
|
37
|
+
let(:requestable) { subject.add_repo team_id, user, repo }
|
38
|
+
end
|
39
|
+
end # add_repo
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#create' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:request_path) { "/orgs/#{org}/teams" }
|
8
|
+
|
9
|
+
let(:inputs) {
|
10
|
+
{ :name => 'new team',
|
11
|
+
:permissions => 'push',
|
12
|
+
:repo_names => [ 'github/dotfiles' ]
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
before {
|
17
|
+
stub_post(request_path).with(inputs).
|
18
|
+
to_return(:body => body, :status => status,
|
19
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
20
|
+
}
|
21
|
+
|
22
|
+
after { reset_authentication_for(subject) }
|
23
|
+
|
24
|
+
context "resouce created" do
|
25
|
+
let(:body) { fixture('orgs/team.json') }
|
26
|
+
let(:status) { 201 }
|
27
|
+
|
28
|
+
it "should fail to create resource if 'org_name' param is missing" do
|
29
|
+
expect { subject.create nil, inputs }.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should failt to create resource if 'name' input is missing" do
|
33
|
+
expect {
|
34
|
+
subject.create org, inputs.except(:name)
|
35
|
+
}.to raise_error(Github::Error::RequiredParams)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should create resource successfully" do
|
39
|
+
subject.create org, inputs
|
40
|
+
a_post(request_path).with(inputs).should have_been_made
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the resource" do
|
44
|
+
team = subject.create org, inputs
|
45
|
+
team.should be_a Hashie::Mash
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should get the team information" do
|
49
|
+
team = subject.create org, inputs
|
50
|
+
team.name.should == 'Owners'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it_should_behave_like 'request failure' do
|
55
|
+
let(:requestable) { subject.create org, inputs }
|
56
|
+
end
|
57
|
+
|
58
|
+
end # create
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#delete' do
|
6
|
+
let(:team_id) { 1 }
|
7
|
+
let(:request_path) { "/teams/#{team_id}" }
|
8
|
+
|
9
|
+
before {
|
10
|
+
stub_delete(request_path).to_return(:body => body, :status => status,
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
+
}
|
13
|
+
|
14
|
+
after { reset_authentication_for(subject) }
|
15
|
+
|
16
|
+
context "resource deleted successfully" do
|
17
|
+
let(:body) { '' }
|
18
|
+
let(:status) { 204 }
|
19
|
+
|
20
|
+
it { should respond_to :remove }
|
21
|
+
|
22
|
+
it "should fail to delete without 'team_id' parameter" do
|
23
|
+
expect { subject.delete nil }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should delete the resource" do
|
27
|
+
subject.delete team_id
|
28
|
+
a_delete(request_path).should have_been_made
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it_should_behave_like 'request failure' do
|
33
|
+
let(:requestable) { subject.delete team_id }
|
34
|
+
end
|
35
|
+
|
36
|
+
end # delete
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#edit' do
|
6
|
+
let(:team) { 'github' }
|
7
|
+
let(:request_path) { "/teams/#{team}" }
|
8
|
+
|
9
|
+
let(:inputs) {
|
10
|
+
{ :name => 'new team',
|
11
|
+
:permissions => 'push',
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
before {
|
16
|
+
stub_patch(request_path).with(inputs).
|
17
|
+
to_return(:body => body, :status => status,
|
18
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
19
|
+
}
|
20
|
+
|
21
|
+
after { reset_authentication_for(subject) }
|
22
|
+
|
23
|
+
context "resouce edited" do
|
24
|
+
let(:body) { fixture('orgs/team.json') }
|
25
|
+
let(:status) { 200 }
|
26
|
+
|
27
|
+
it "should fail to create resource if 'team name' param is missing" do
|
28
|
+
expect { subject.edit nil, inputs }.to raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should failt to create resource if 'name' input is missing" do
|
32
|
+
expect {
|
33
|
+
subject.edit team, inputs.except(:name)
|
34
|
+
}.to raise_error(Github::Error::RequiredParams)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create resource successfully" do
|
38
|
+
subject.edit team, inputs
|
39
|
+
a_patch(request_path).with(inputs).should have_been_made
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the resource" do
|
43
|
+
edited_team = subject.edit team, inputs
|
44
|
+
edited_team.should be_a Hashie::Mash
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should get the team information" do
|
48
|
+
edited_team = subject.edit team, inputs
|
49
|
+
edited_team.name.should == 'Owners'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it_should_behave_like 'request failure' do
|
54
|
+
let(:requestable) { subject.edit team, inputs }
|
55
|
+
end
|
56
|
+
|
57
|
+
end # edit
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#get' do
|
6
|
+
let(:team) { 'github' }
|
7
|
+
let(:request_path) { "/teams/#{team}" }
|
8
|
+
|
9
|
+
before {
|
10
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
+
}
|
13
|
+
|
14
|
+
after { reset_authentication_for(subject) }
|
15
|
+
|
16
|
+
context "resource found" do
|
17
|
+
let(:body) { fixture('orgs/team.json') }
|
18
|
+
let(:status) { 200 }
|
19
|
+
|
20
|
+
it "should fail to get resource without org name" do
|
21
|
+
expect { subject.get nil }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resource" do
|
25
|
+
subject.get team
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should get team information" do
|
30
|
+
team_res = subject.get team
|
31
|
+
team_res.id.should == 1
|
32
|
+
team_res.name.should == 'Owners'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return mash" do
|
36
|
+
team_res = subject.get team
|
37
|
+
team_res.should be_a Hashie::Mash
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it_should_behave_like 'request failure' do
|
42
|
+
let(:requestable) { subject.get team }
|
43
|
+
end
|
44
|
+
|
45
|
+
end # get
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#list_members' do
|
6
|
+
let(:team_id) { 'github' }
|
7
|
+
let(:request_path) { "/teams/#{team_id}/members" }
|
8
|
+
|
9
|
+
before {
|
10
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
+
}
|
13
|
+
|
14
|
+
after { reset_authentication_for(subject) }
|
15
|
+
|
16
|
+
context "resource found" do
|
17
|
+
let(:body) { fixture('orgs/teams.json') }
|
18
|
+
let(:status) { 200 }
|
19
|
+
|
20
|
+
it "should fail to get resource without org name" do
|
21
|
+
expect { subject.list_members }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resources" do
|
25
|
+
subject.list_members team_id
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'an array of resources' do
|
30
|
+
let(:requestable) { subject.list_members team_id }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get team members information" do
|
34
|
+
teams = subject.list_members team_id
|
35
|
+
teams.first.name.should == 'Owners'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should yield to a block" do
|
39
|
+
yielded = []
|
40
|
+
result = subject.list_members(team_id) { |obj| yielded << obj }
|
41
|
+
yielded.should == result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it_should_behave_like 'request failure' do
|
46
|
+
let(:requestable) { subject.list_members team_id }
|
47
|
+
end
|
48
|
+
|
49
|
+
end # list_members
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#list_repos' do
|
6
|
+
let(:team_id) { 'github' }
|
7
|
+
let(:request_path) { "/teams/#{team_id}/repos" }
|
8
|
+
|
9
|
+
before {
|
10
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
+
}
|
13
|
+
|
14
|
+
after { reset_authentication_for(subject) }
|
15
|
+
|
16
|
+
context "resource found" do
|
17
|
+
let(:body) { fixture('orgs/team_repos.json') }
|
18
|
+
let(:status) { 200 }
|
19
|
+
|
20
|
+
it "should fail to get resource without team name" do
|
21
|
+
expect { subject.list_repos }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resources" do
|
25
|
+
subject.list_repos team_id
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'an array of resources' do
|
30
|
+
let(:requestable) { subject.list_repos team_id }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get teams information" do
|
34
|
+
team_repos = subject.list_repos team_id
|
35
|
+
team_repos.first.name.should == 'github'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should yield to a block" do
|
39
|
+
yielded = []
|
40
|
+
result = subject.list_repos(team_id) { |obj| yielded << obj }
|
41
|
+
yielded.should == result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it_should_behave_like 'request failure' do
|
46
|
+
let(:requestable) { subject.list_repos team_id }
|
47
|
+
end
|
48
|
+
|
49
|
+
end # list_repos
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#list' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:request_path) { "/orgs/#{org}/teams" }
|
8
|
+
|
9
|
+
before {
|
10
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
11
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
12
|
+
}
|
13
|
+
|
14
|
+
after { reset_authentication_for(subject) }
|
15
|
+
|
16
|
+
context "resource found" do
|
17
|
+
let(:body) { fixture('orgs/teams.json') }
|
18
|
+
let(:status) { 200 }
|
19
|
+
|
20
|
+
it "should fail to get resource without org name" do
|
21
|
+
expect { subject.list nil }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get the resources" do
|
25
|
+
subject.list org
|
26
|
+
a_get(request_path).should have_been_made
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'an array of resources' do
|
30
|
+
let(:requestable) { subject.list org }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get teams information" do
|
34
|
+
teams = subject.list org
|
35
|
+
teams.first.name.should == 'Owners'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should yield to a block" do
|
39
|
+
yielded = []
|
40
|
+
result = subject.list(org) { |obj| yielded << obj }
|
41
|
+
yielded.should == result
|
42
|
+
end
|
43
|
+
|
44
|
+
it_should_behave_like 'request failure' do
|
45
|
+
let(:requestable) { subject.list org }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end # list
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Teams, '#remove_member' do
|
6
|
+
let(:team_id) { 1 }
|
7
|
+
let(:user) { 'peter-murach' }
|
8
|
+
let(:repo) { 'github' }
|
9
|
+
let(:request_path) { "/teams/#{team_id}/members/#{user}"}
|
10
|
+
|
11
|
+
before {
|
12
|
+
stub_delete(request_path).to_return(:body => body, :status => status,
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
}
|
15
|
+
|
16
|
+
after { reset_authentication_for(subject) }
|
17
|
+
|
18
|
+
context "resouce deleted" do
|
19
|
+
let(:body) { '' }
|
20
|
+
let(:status) { 204 }
|
21
|
+
|
22
|
+
it "should fail to delete resource if 'team_id' input is nil" do
|
23
|
+
expect { subject.remove_member nil, user }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should fail to delete resource if 'user' input is nil" do
|
27
|
+
expect { subject.remove_member team_id, nil }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should add resource successfully" do
|
31
|
+
subject.remove_member team_id, user
|
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.remove_member team_id, user }
|
38
|
+
end
|
39
|
+
|
40
|
+
end # remove_member
|