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,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Gists, '#list' do
|
6
|
+
let(:user) { 'peter-murach' }
|
7
|
+
let(:body) { fixture('gists/gists.json') }
|
8
|
+
let(:status) { 200 }
|
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 "when unauthenticated user" do
|
18
|
+
let(:request_path) { "/users/#{user}/gists" }
|
19
|
+
|
20
|
+
context "resource found" do
|
21
|
+
it { should respond_to :all }
|
22
|
+
|
23
|
+
it "should get the resources" do
|
24
|
+
subject.list :user => user
|
25
|
+
a_get(request_path).should have_been_made
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like 'an array of resources' do
|
29
|
+
let(:requestable) { subject.list :user => user }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get gist information" do
|
33
|
+
gists = subject.list :user => user
|
34
|
+
gists.first.user.login.should == 'octocat'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should yield to a block" do
|
38
|
+
yielded = []
|
39
|
+
result = subject.list(:user => user) { |obj| yielded << obj }
|
40
|
+
yielded.should == result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it_should_behave_like 'request failure' do
|
45
|
+
let(:requestable) { subject.list :user => user }
|
46
|
+
end
|
47
|
+
end # unauthenticated user
|
48
|
+
|
49
|
+
context 'when public' do
|
50
|
+
let(:request_path) { "/gists/public" }
|
51
|
+
|
52
|
+
it "should get the resources" do
|
53
|
+
subject.list
|
54
|
+
a_get(request_path).should have_been_made
|
55
|
+
end
|
56
|
+
|
57
|
+
it_should_behave_like 'an array of resources' do
|
58
|
+
let(:requestable) { subject.list }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when authenticated user' do
|
63
|
+
let(:request_path) { "/gists" }
|
64
|
+
|
65
|
+
before do
|
66
|
+
subject.oauth_token = OAUTH_TOKEN
|
67
|
+
stub_get(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
68
|
+
to_return(:body => fixture('gists/gists.json'), :status => 200,
|
69
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get the resources" do
|
73
|
+
subject.list
|
74
|
+
a_get(request_path).with(:query => {:access_token => OAUTH_TOKEN}).
|
75
|
+
should have_been_made
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end # list
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Gists, '#star' do
|
6
|
+
let(:gist_id) { 1 }
|
7
|
+
let(:request_path) { "/gists/#{gist_id}/star" }
|
8
|
+
let(:body) { '' }
|
9
|
+
let(:status) { 204 }
|
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
|
+
it "should raise error if gist id not present" do
|
19
|
+
expect { subject.star nil }.to raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'successfully stars a gist' do
|
23
|
+
subject.star gist_id
|
24
|
+
a_put(request_path).should have_been_made
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return 204 with a message 'Not Found'" do
|
28
|
+
subject.star(gist_id).status.should be 204
|
29
|
+
end
|
30
|
+
end # star
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Gists, '#starred' do
|
6
|
+
let(:request_path) { "/gists/starred" }
|
7
|
+
|
8
|
+
before {
|
9
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
10
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
11
|
+
}
|
12
|
+
|
13
|
+
after { reset_authentication_for(subject) }
|
14
|
+
|
15
|
+
context "resource found" do
|
16
|
+
let(:body) { fixture('gists/gists.json') }
|
17
|
+
let(:status) { 200 }
|
18
|
+
|
19
|
+
it "should get the resources" do
|
20
|
+
subject.starred
|
21
|
+
a_get(request_path).should have_been_made
|
22
|
+
end
|
23
|
+
|
24
|
+
it_should_behave_like 'an array of resources' do
|
25
|
+
let(:requestable) { subject.starred }
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get gist information" do
|
29
|
+
gists = subject.starred
|
30
|
+
gists.first.user.login.should == 'octocat'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should yield to a block" do
|
34
|
+
yielded = []
|
35
|
+
result = subject.starred { |obj| yielded << obj }
|
36
|
+
yielded.should == result
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it_should_behave_like 'request failure' do
|
41
|
+
let(:requestable) { subject.starred }
|
42
|
+
end
|
43
|
+
|
44
|
+
end # starred
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Gists, '#unstar' do
|
6
|
+
let(:gist_id) { 1 }
|
7
|
+
let(:request_path) { "/gists/#{gist_id}/star" }
|
8
|
+
let(:body) { '' }
|
9
|
+
let(:status) { 204 }
|
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
|
+
it "should raise error if gist id not present" do
|
19
|
+
expect { subject.unstar nil }.to raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'successfully stars a gist' do
|
23
|
+
subject.unstar gist_id
|
24
|
+
a_delete(request_path).should have_been_made
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return 204 with a message 'Not Found'" do
|
28
|
+
subject.unstar(gist_id).status.should be 204
|
29
|
+
end
|
30
|
+
end # unstar
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Members, '#conceal' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:member) { 'peter-murach' }
|
8
|
+
let(:request_path) { "/orgs/#{org}/public_members/#{member}" }
|
9
|
+
|
10
|
+
before {
|
11
|
+
stub_delete(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 "request perfomed successfully" do
|
18
|
+
let(:body) { fixture('orgs/members.json') }
|
19
|
+
let(:status) { 204 }
|
20
|
+
|
21
|
+
it "should fail to get resource without org name" do
|
22
|
+
expect { subject.conceal }.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should get the resources" do
|
26
|
+
subject.conceal org, member
|
27
|
+
a_delete(request_path).should have_been_made
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_behave_like 'request failure' do
|
32
|
+
let(:requestable) { subject.conceal org, member }
|
33
|
+
end
|
34
|
+
|
35
|
+
end # conceal
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Members, '#delete' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:member) { 'peter-murach' }
|
8
|
+
let(:request_path) { "/orgs/#{org}/members/#{member}" }
|
9
|
+
|
10
|
+
before {
|
11
|
+
stub_delete(request_path).to_return(:body => body, :status => status,
|
12
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
}
|
14
|
+
|
15
|
+
context "resource deleted successfully" do
|
16
|
+
let(:body) { '' }
|
17
|
+
let(:status) { 204 }
|
18
|
+
|
19
|
+
it "should fail to delete without org and member parameters" do
|
20
|
+
expect { subject.delete }.to raise_error(ArgumentError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should delete the resource" do
|
24
|
+
subject.delete org, member
|
25
|
+
a_delete(request_path).should have_been_made
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'request failure' do
|
30
|
+
let(:requestable) { subject.delete org, member }
|
31
|
+
end
|
32
|
+
|
33
|
+
end # delete
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Members, '#list' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:body) { fixture('orgs/members.json') }
|
8
|
+
let(:status) { 200 }
|
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(:request_path) { "/orgs/#{org}/members" }
|
19
|
+
|
20
|
+
it { should respond_to :all }
|
21
|
+
|
22
|
+
it "should fail to get resource without org name" do
|
23
|
+
expect { subject.list nil }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should get the resources" do
|
27
|
+
subject.list org
|
28
|
+
a_get(request_path).should have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_behave_like 'an array of resources' do
|
32
|
+
let(:requestable) { subject.list org }
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get members information" do
|
36
|
+
members = subject.list org
|
37
|
+
members.first.login.should == 'octocat'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should yield to a block" do
|
41
|
+
yielded = []
|
42
|
+
result = subject.list(org) { |obj| yielded << obj }
|
43
|
+
yielded.should == result
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.list org }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "resource found" do
|
52
|
+
let(:request_path) { "/orgs/#{org}/public_members" }
|
53
|
+
|
54
|
+
it "should fail to get resource without org name" do
|
55
|
+
expect { subject.list }.to raise_error(ArgumentError)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should get the resources" do
|
59
|
+
subject.list org, :public => true
|
60
|
+
a_get(request_path).should have_been_made
|
61
|
+
end
|
62
|
+
|
63
|
+
it_should_behave_like 'an array of resources' do
|
64
|
+
let(:requestable) { subject.list org, :public => true }
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should get public_members information" do
|
68
|
+
public_members = subject.list org, :public => true
|
69
|
+
public_members.first.login.should == 'octocat'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should yield to a block" do
|
73
|
+
yielded = []
|
74
|
+
result = subject.list(org, :public => true) { |obj| yielded << obj }
|
75
|
+
yielded.should == result
|
76
|
+
end
|
77
|
+
|
78
|
+
it_should_behave_like 'request failure' do
|
79
|
+
let(:requestable) { subject.list org, :public => true }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # list
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Members, '#member?' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:member) { 'peter-murach' }
|
8
|
+
let(:body) { "" }
|
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 "when private" do
|
18
|
+
let(:request_path) { "/orgs/#{org}/members/#{member}" }
|
19
|
+
|
20
|
+
context "this repo is being watched by the user" do
|
21
|
+
let(:status) { 404 }
|
22
|
+
|
23
|
+
it "should fail validation " do
|
24
|
+
expect { subject.member?(nil, nil) }.to raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return false if resource not found" do
|
28
|
+
membership = subject.member? org, member
|
29
|
+
membership.should be_false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'user is member of an organization' do
|
34
|
+
let(:status) { 204 }
|
35
|
+
|
36
|
+
it "should return true if resoure found" do
|
37
|
+
membership = subject.member? org, member
|
38
|
+
membership.should be_true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when public' do
|
44
|
+
let(:request_path) { "/orgs/#{org}/public_members/#{member}" }
|
45
|
+
|
46
|
+
context "this repo is being watched by the user" do
|
47
|
+
let(:status) { 404 }
|
48
|
+
|
49
|
+
it "should return false if resource not found" do
|
50
|
+
public_member = subject.member? org, member, :public => true
|
51
|
+
public_member.should be_false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'user is member of an organization' do
|
56
|
+
let(:status) { 204 }
|
57
|
+
|
58
|
+
it "should return true if resoure found" do
|
59
|
+
public_member = subject.member? org, member, :public => true
|
60
|
+
public_member.should be_true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end # member?
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::Orgs::Members, '#publicize' do
|
6
|
+
let(:org) { 'github' }
|
7
|
+
let(:member) { 'peter-murach' }
|
8
|
+
let(:request_path) { "/orgs/#{org}/public_members/#{member}" }
|
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 "request perfomed successfully" do
|
18
|
+
let(:body) { fixture('orgs/members.json') }
|
19
|
+
let(:status) { 204 }
|
20
|
+
|
21
|
+
it "should fail to get resource without org name" do
|
22
|
+
expect { subject.publicize }.to raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should get the resources" do
|
26
|
+
subject.publicize org, member
|
27
|
+
a_put(request_path).should have_been_made
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_behave_like 'request failure' do
|
32
|
+
let(:requestable) { subject.publicize org, member }
|
33
|
+
end
|
34
|
+
|
35
|
+
end # publicize
|
@@ -1,282 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Github::Orgs::Members do
|
4
|
-
let(:github) { Github.new }
|
5
|
-
let(:member) { 'peter-murach' }
|
6
|
-
let(:org) { 'github' }
|
7
|
-
|
8
|
-
after { reset_authentication_for github }
|
9
|
-
|
10
|
-
describe "#list" do
|
11
|
-
it { github.orgs.members.should respond_to :all }
|
12
|
-
|
13
|
-
context "resource found" do
|
14
|
-
before do
|
15
|
-
stub_get("/orgs/#{org}/members").
|
16
|
-
to_return(:body => fixture('orgs/members.json'), :status => 200,
|
17
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should fail to get resource without org name" do
|
21
|
-
expect { github.orgs.members.list nil }.to raise_error(ArgumentError)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should get the resources" do
|
25
|
-
github.orgs.members.list org
|
26
|
-
a_get("/orgs/#{org}/members").should have_been_made
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return array of resources" do
|
30
|
-
members = github.orgs.members.list org
|
31
|
-
members.should be_an Array
|
32
|
-
members.should have(1).items
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should be a mash type" do
|
36
|
-
members = github.orgs.members.list org
|
37
|
-
members.first.should be_a Hashie::Mash
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should get members information" do
|
41
|
-
members = github.orgs.members.list org
|
42
|
-
members.first.login.should == 'octocat'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should yield to a block" do
|
46
|
-
github.orgs.members.should_receive(:list).with(org).and_yield('web')
|
47
|
-
github.orgs.members.list(org) { |param| 'web' }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "resource not found" do
|
52
|
-
before do
|
53
|
-
stub_get("/orgs/#{org}/members").
|
54
|
-
to_return(:body => '', :status => 404,
|
55
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should return 404 with a message 'Not Found'" do
|
59
|
-
expect {
|
60
|
-
github.orgs.members.list org
|
61
|
-
}.to raise_error(Github::Error::NotFound)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end # list
|
65
|
-
|
66
|
-
describe "#member?" do
|
67
|
-
context "with username ane reponame passed" do
|
68
|
-
context "this repo is being watched by the user"
|
69
|
-
before do
|
70
|
-
stub_get("/orgs/#{org}/members/#{member}").
|
71
|
-
to_return(:body => "", :status => 404,
|
72
|
-
:headers => {:user_agent => github.user_agent})
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should return false if resource not found" do
|
76
|
-
membership = github.orgs.members.member? org, member
|
77
|
-
membership.should be_false
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should return true if resoure found" do
|
81
|
-
stub_get("/orgs/#{org}/members/#{member}").
|
82
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
83
|
-
membership = github.orgs.members.member? org, member
|
84
|
-
membership.should be_true
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "without org name and member name passed" do
|
89
|
-
it "should fail validation " do
|
90
|
-
expect {
|
91
|
-
github.orgs.members.member?(nil, nil)
|
92
|
-
}.to raise_error(ArgumentError)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end # member?
|
96
|
-
|
97
|
-
describe "#list_public" do
|
98
|
-
context "resource found" do
|
99
|
-
before do
|
100
|
-
stub_get("/orgs/#{org}/public_members").
|
101
|
-
to_return(:body => fixture('orgs/members.json'), :status => 200,
|
102
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should fail to get resource without org name" do
|
106
|
-
expect { github.orgs.members.list_public }.to raise_error(ArgumentError)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should get the resources" do
|
110
|
-
github.orgs.members.list_public org
|
111
|
-
a_get("/orgs/#{org}/public_members").should have_been_made
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should return array of resources" do
|
115
|
-
public_members = github.orgs.members.list_public org
|
116
|
-
public_members.should be_an Array
|
117
|
-
public_members.should have(1).items
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should be a mash type" do
|
121
|
-
public_members = github.orgs.members.list_public org
|
122
|
-
public_members.first.should be_a Hashie::Mash
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should get public_members information" do
|
126
|
-
public_members = github.orgs.members.list_public org
|
127
|
-
public_members.first.login.should == 'octocat'
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should yield to a block" do
|
131
|
-
github.orgs.members.should_receive(:list_public).with(org).and_yield('web')
|
132
|
-
github.orgs.members.list_public(org) { |param| 'web' }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context "resource not found" do
|
137
|
-
before do
|
138
|
-
stub_get("/orgs/#{org}/public_members").
|
139
|
-
to_return(:body => '', :status => 404,
|
140
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should return 404 with a message 'Not Found'" do
|
144
|
-
expect {
|
145
|
-
github.orgs.members.list_public org
|
146
|
-
}.to raise_error(Github::Error::NotFound)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end # list_public
|
150
|
-
|
151
|
-
describe "public_member?" do
|
152
|
-
context "with username ane reponame passed" do
|
153
|
-
context "this repo is being watched by the user"
|
154
|
-
before do
|
155
|
-
stub_get("/orgs/#{org}/public_members/#{member}").
|
156
|
-
to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should return false if resource not found" do
|
160
|
-
public_member = github.orgs.members.public_member? org, member
|
161
|
-
public_member.should be_false
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should return true if resoure found" do
|
165
|
-
stub_get("/orgs/#{org}/public_members/#{member}").
|
166
|
-
to_return(:body => "", :status => 204, :headers => {:user_agent => github.user_agent})
|
167
|
-
public_member = github.orgs.members.public_member? org, member
|
168
|
-
public_member.should be_true
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context "without org name and member name passed" do
|
173
|
-
it "should fail validation " do
|
174
|
-
expect {
|
175
|
-
github.orgs.members.public_member?(nil, nil)
|
176
|
-
}.to raise_error(ArgumentError)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end # public_member?
|
180
|
-
|
181
|
-
describe "publicize" do
|
182
|
-
context "request perfomed successfully" do
|
183
|
-
before do
|
184
|
-
stub_put("/orgs/#{org}/public_members/#{member}").
|
185
|
-
to_return(:body => fixture('orgs/members.json'), :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should fail to get resource without org name" do
|
189
|
-
expect { github.orgs.members.publicize }.to raise_error(ArgumentError)
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should get the resources" do
|
193
|
-
github.orgs.members.publicize org, member
|
194
|
-
a_put("/orgs/#{org}/public_members/#{member}").should have_been_made
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "resource not found" do
|
199
|
-
before do
|
200
|
-
stub_put("/orgs/#{org}/public_members/#{member}").
|
201
|
-
to_return(:body => '', :status => 404,
|
202
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should return 404 with a message 'Not Found'" do
|
206
|
-
expect {
|
207
|
-
github.orgs.members.publicize org, member
|
208
|
-
}.to raise_error(Github::Error::NotFound)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end # publicize
|
212
|
-
|
213
|
-
describe "#conceal" do
|
214
|
-
context "request perfomed successfully" do
|
215
|
-
before do
|
216
|
-
stub_delete("/orgs/#{org}/public_members/#{member}").
|
217
|
-
to_return(:body => fixture('orgs/members.json'), :status => 204,
|
218
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should fail to get resource without org name" do
|
222
|
-
expect {
|
223
|
-
github.orgs.members.conceal nil, nil
|
224
|
-
}.to raise_error(ArgumentError)
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should get the resources" do
|
228
|
-
github.orgs.members.conceal org, member
|
229
|
-
a_delete("/orgs/#{org}/public_members/#{member}").should have_been_made
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
context "resource not found" do
|
234
|
-
before do
|
235
|
-
stub_delete("/orgs/#{org}/public_members/#{member}").
|
236
|
-
to_return(:body => '', :status => 404,
|
237
|
-
:headers => {:content_type => "application/json; charset=utf-8"})
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should return 404 with a message 'Not Found'" do
|
241
|
-
expect {
|
242
|
-
github.orgs.members.conceal org, member
|
243
|
-
}.to raise_error(Github::Error::NotFound)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end # conceal
|
247
|
-
|
248
|
-
describe "#delete" do
|
249
|
-
let(:hook_id) { 1 }
|
250
|
-
|
251
|
-
context "resource deleted successfully" do
|
252
|
-
before do
|
253
|
-
stub_delete("/orgs/#{org}/members/#{member}").
|
254
|
-
to_return(:body => '', :status => 204, :headers => { :content_type => "application/json; charset=utf-8"})
|
255
|
-
end
|
256
|
-
|
257
|
-
it "should fail to delete without org and member parameters" do
|
258
|
-
expect { github.orgs.members.delete nil, nil }.to raise_error(ArgumentError)
|
259
|
-
end
|
260
|
-
|
261
|
-
it "should delete the resource" do
|
262
|
-
github.orgs.members.delete org, member
|
263
|
-
a_delete("/orgs/#{org}/members/#{member}").should have_been_made
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
context "failed to edit resource" do
|
268
|
-
before do
|
269
|
-
stub_delete("/orgs/#{org}/members/#{member}").
|
270
|
-
to_return(:body => '', :status => 404,
|
271
|
-
:headers => { :content_type => "application/json; charset=utf-8"})
|
272
|
-
end
|
273
|
-
|
274
|
-
it "should fail to find resource" do
|
275
|
-
expect {
|
276
|
-
github.orgs.members.delete org, member
|
277
|
-
}.to raise_error(Github::Error::NotFound)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end # delete
|
281
4
|
|
282
5
|
end # Github::Orgs::Members
|