github_api 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/features/gists/comments.feature +8 -8
- data/lib/github_api/gists/comments.rb +15 -15
- data/lib/github_api/repos.rb +3 -1
- data/lib/github_api/repos/comments.rb +6 -5
- data/lib/github_api/requestable.rb +67 -0
- data/lib/github_api/version.rb +1 -1
- data/spec/github/activity/activity_spec.rb +2 -0
- data/spec/github/activity/events/issue_spec.rb +8 -20
- data/spec/github/activity/events/network_spec.rb +8 -20
- data/spec/github/activity/events/org_spec.rb +8 -18
- data/spec/github/activity/events/performed_spec.rb +13 -31
- data/spec/github/activity/events/public_spec.rb +7 -18
- data/spec/github/activity/events/received_spec.rb +12 -31
- data/spec/github/activity/events/repository_spec.rb +8 -20
- data/spec/github/activity/events/user_org_spec.rb +8 -20
- data/spec/github/activity/notifications/list_spec.rb +4 -11
- data/spec/github/activity/starring/list_spec.rb +8 -21
- data/spec/github/activity/watching/list_spec.rb +4 -18
- data/spec/github/gists/comments_spec.rb +24 -23
- data/spec/github/git_data/blobs/create_spec.rb +62 -0
- data/spec/github/git_data/blobs/get_spec.rb +49 -0
- data/spec/github/git_data/blobs_spec.rb +0 -116
- data/spec/github/repos/branch_spec.rb +3 -9
- data/spec/github/repos/branches_spec.rb +5 -13
- data/spec/github/repos/collaborators/add_spec.rb +37 -0
- data/spec/github/repos/collaborators/get_spec.rb +51 -0
- data/spec/github/repos/collaborators/list_spec.rb +51 -0
- data/spec/github/repos/collaborators/remove_spec.rb +37 -0
- data/spec/github/repos/collaborators_spec.rb +1 -176
- data/spec/github/repos/comments/create_spec.rb +2 -33
- data/spec/github/repos/comments/delete_spec.rb +3 -9
- data/spec/github/repos/comments/get_spec.rb +3 -9
- data/spec/github/repos/comments/list_spec.rb +16 -40
- data/spec/github/repos/comments/update_spec.rb +5 -11
- data/spec/github/repos/commits/get_spec.rb +3 -9
- data/spec/github/repos/commits/list_spec.rb +9 -20
- data/spec/github/repos/contributors_spec.rb +5 -13
- data/spec/github/repos/delete_spec.rb +3 -8
- data/spec/github/repos/downloads/create_spec.rb +3 -9
- data/spec/github/repos/downloads/delete_spec.rb +3 -9
- data/spec/github/repos/downloads/get_spec.rb +5 -12
- data/spec/github/repos/downloads/list_spec.rb +8 -18
- data/spec/github/repos/edit_spec.rb +3 -9
- data/spec/github/repos/forks/create_spec.rb +3 -9
- data/spec/github/repos/forks/list_spec.rb +8 -21
- data/spec/github/repos/get_spec.rb +3 -9
- data/spec/github/repos/list_spec.rb +8 -7
- data/spec/github/repos_spec.rb +2 -0
- data/spec/shared/api_interface_behaviour.rb +15 -0
- data/spec/shared/array_of_resources_behaviour.rb +15 -0
- data/spec/shared/request_failure_behaviour.rb +16 -0
- data/spec/spec_helper.rb +1 -1
- metadata +43 -33
@@ -33,30 +33,6 @@ describe Github::Repos::Comments, '#create' do
|
|
33
33
|
}.to raise_error(Github::Error::RequiredParams)
|
34
34
|
end
|
35
35
|
|
36
|
-
it "should fail to create resource if 'commit_id' input is missing" do
|
37
|
-
expect {
|
38
|
-
subject.create user, repo, sha, inputs.except(:commit_id)
|
39
|
-
}.to raise_error(Github::Error::RequiredParams)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should fail to create resource if 'line' input is missing" do
|
43
|
-
expect {
|
44
|
-
subject.create user, repo, sha, inputs.except(:line)
|
45
|
-
}.to raise_error(Github::Error::RequiredParams)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should fail to create resource if 'path' input is missing" do
|
49
|
-
expect {
|
50
|
-
subject.create user, repo, sha, inputs.except(:path)
|
51
|
-
}.to raise_error(Github::Error::RequiredParams)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should fail to create resource if 'position' input is missing" do
|
55
|
-
expect {
|
56
|
-
subject.create user, repo, sha, inputs.except(:position)
|
57
|
-
}.to raise_error(Github::Error::RequiredParams)
|
58
|
-
end
|
59
|
-
|
60
36
|
it "should create resource successfully" do
|
61
37
|
subject.create user, repo, sha, inputs
|
62
38
|
a_post(request_path).with(inputs).should have_been_made
|
@@ -73,14 +49,7 @@ describe Github::Repos::Comments, '#create' do
|
|
73
49
|
end
|
74
50
|
end
|
75
51
|
|
76
|
-
|
77
|
-
let(:
|
78
|
-
let(:status) { 404 }
|
79
|
-
|
80
|
-
it "should fail to retrieve resource" do
|
81
|
-
expect {
|
82
|
-
subject.create user, repo, sha, inputs
|
83
|
-
}.to raise_error(Github::Error::NotFound)
|
84
|
-
end
|
52
|
+
it_should_behave_like 'request failure' do
|
53
|
+
let(:requestable) { subject.create user, repo, sha, inputs }
|
85
54
|
end
|
86
55
|
end # create
|
@@ -36,14 +36,8 @@ describe Github::Repos::Comments, '#delete' do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
let(:
|
41
|
-
let(:status) { 404 }
|
42
|
-
|
43
|
-
it "should fail to find resource" do
|
44
|
-
expect {
|
45
|
-
subject.delete user, repo, comment_id
|
46
|
-
}.to raise_error(Github::Error::NotFound)
|
47
|
-
end
|
39
|
+
it_should_behave_like 'request failure' do
|
40
|
+
let(:requestable) { subject.delete user, repo, comment_id }
|
48
41
|
end
|
42
|
+
|
49
43
|
end # delete
|
@@ -41,14 +41,8 @@ describe Github::Repos::Comments, '#get' do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
let(:
|
46
|
-
let(:status) { 404 }
|
47
|
-
|
48
|
-
it "should fail to retrive resource" do
|
49
|
-
expect {
|
50
|
-
subject.get user, repo, comment_id
|
51
|
-
}.to raise_error(Github::Error::NotFound)
|
52
|
-
end
|
44
|
+
it_should_behave_like 'request failure' do
|
45
|
+
let(:requestable) { subject.get user, repo, comment_id }
|
53
46
|
end
|
47
|
+
|
54
48
|
end # get
|
@@ -31,15 +31,8 @@ describe Github::Repos::Comments, '#list' do
|
|
31
31
|
a_get(request_path).should have_been_made
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
repo_comments.should be_an Array
|
37
|
-
repo_comments.should have(1).items
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should be a mash type" do
|
41
|
-
repo_comments = subject.list user, repo
|
42
|
-
repo_comments.first.should be_a Hashie::Mash
|
34
|
+
it_should_behave_like 'an array of resources' do
|
35
|
+
let(:requestable) { subject.list user, repo }
|
43
36
|
end
|
44
37
|
|
45
38
|
it "should get commit comment information" do
|
@@ -48,21 +41,16 @@ describe Github::Repos::Comments, '#list' do
|
|
48
41
|
end
|
49
42
|
|
50
43
|
it "should yield to a block" do
|
51
|
-
|
52
|
-
subject.list(user, repo) { |
|
44
|
+
yielded = []
|
45
|
+
result = subject.list(user, repo) { |obj| yielded << obj }
|
46
|
+
yielded.should == result
|
53
47
|
end
|
54
48
|
end
|
55
49
|
|
56
|
-
|
57
|
-
let(:
|
58
|
-
let(:status) { [404, "Not Found"] }
|
59
|
-
|
60
|
-
it "should return 404 with a message 'Not Found'" do
|
61
|
-
expect {
|
62
|
-
subject.list user, repo
|
63
|
-
}.to raise_error(Github::Error::NotFound)
|
64
|
-
end
|
50
|
+
it_should_behave_like 'request failure' do
|
51
|
+
let(:requestable) { subject.list user, repo }
|
65
52
|
end
|
53
|
+
|
66
54
|
end # without sha
|
67
55
|
|
68
56
|
context 'with sha' do
|
@@ -83,15 +71,8 @@ describe Github::Repos::Comments, '#list' do
|
|
83
71
|
a_get(request_path).should have_been_made
|
84
72
|
end
|
85
73
|
|
86
|
-
|
87
|
-
|
88
|
-
commit_comments.should be_an Array
|
89
|
-
commit_comments.should have(1).items
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should be a mash type" do
|
93
|
-
commit_comments = subject.list user, repo, :sha => sha
|
94
|
-
commit_comments.first.should be_a Hashie::Mash
|
74
|
+
it_should_behave_like 'an array of resources' do
|
75
|
+
let(:requestable) { subject.list user, repo, :sha => sha }
|
95
76
|
end
|
96
77
|
|
97
78
|
it "should get commit comment information" do
|
@@ -100,21 +81,16 @@ describe Github::Repos::Comments, '#list' do
|
|
100
81
|
end
|
101
82
|
|
102
83
|
it "should yield to a block" do
|
103
|
-
|
104
|
-
subject.list(user, repo, :sha => sha) { |
|
84
|
+
yielded = []
|
85
|
+
result = subject.list(user, repo, :sha => sha) { |obj| yielded << obj }
|
86
|
+
yielded.should == result
|
105
87
|
end
|
106
88
|
end
|
107
89
|
|
108
|
-
|
109
|
-
let(:
|
110
|
-
let(:status) { 404 }
|
111
|
-
|
112
|
-
it "should fail to retrive resource" do
|
113
|
-
expect {
|
114
|
-
subject.list user, repo, :sha => sha
|
115
|
-
}.to raise_error(Github::Error::NotFound)
|
116
|
-
end
|
90
|
+
it_should_behave_like 'request failure' do
|
91
|
+
let(:requestable) { subject.list user, repo, :sha => sha }
|
117
92
|
end
|
93
|
+
|
118
94
|
end # with sha
|
119
95
|
|
120
96
|
end # list
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Github::Repos::Comments, '#
|
5
|
+
describe Github::Repos::Comments, '#update' do
|
6
6
|
let(:user) { 'peter-murach' }
|
7
7
|
let(:repo) { 'github' }
|
8
8
|
let(:comment_id) { 1 }
|
@@ -41,14 +41,8 @@ describe Github::Repos::Comments, '#delete' do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
let(:
|
46
|
-
let(:status) { 404 }
|
47
|
-
|
48
|
-
it "should fail to retrieve resource" do
|
49
|
-
expect {
|
50
|
-
subject.update user, repo, comment_id, inputs
|
51
|
-
}.to raise_error(Github::Error::NotFound)
|
52
|
-
end
|
44
|
+
it_should_behave_like 'request failure' do
|
45
|
+
let(:requestable) { subject.update user, repo, comment_id, inputs }
|
53
46
|
end
|
54
|
-
|
47
|
+
|
48
|
+
end # update
|
@@ -43,14 +43,8 @@ describe Github::Repos::Commits, '#get' do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
let(:
|
48
|
-
let(:status) { 404 }
|
49
|
-
|
50
|
-
it "should fail to retrive resource" do
|
51
|
-
expect {
|
52
|
-
subject.get user, repo, sha
|
53
|
-
}.to raise_error(Github::Error::NotFound)
|
54
|
-
end
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.get user, repo, sha }
|
55
48
|
end
|
49
|
+
|
56
50
|
end # get
|
@@ -19,6 +19,7 @@ describe Github::Repos::Commits, '#list' do
|
|
19
19
|
let(:status) { 200 }
|
20
20
|
|
21
21
|
it { should respond_to :all }
|
22
|
+
|
22
23
|
it "should fail to get resource without username" do
|
23
24
|
expect { subject.list }.to raise_error(ArgumentError)
|
24
25
|
end
|
@@ -28,15 +29,8 @@ describe Github::Repos::Commits, '#list' do
|
|
28
29
|
a_get(request_path).should have_been_made
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
commits.should be_an Array
|
34
|
-
commits.should have(1).items
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be a mash type" do
|
38
|
-
commits = subject.list user, repo
|
39
|
-
commits.first.should be_a Hashie::Mash
|
32
|
+
it_should_behave_like 'an array of resources' do
|
33
|
+
let(:requestable) { subject.list user, repo }
|
40
34
|
end
|
41
35
|
|
42
36
|
it "should get commit information" do
|
@@ -45,19 +39,14 @@ describe Github::Repos::Commits, '#list' do
|
|
45
39
|
end
|
46
40
|
|
47
41
|
it "should yield to a block" do
|
48
|
-
|
49
|
-
subject.list(user, repo) { |
|
42
|
+
yielded = []
|
43
|
+
result = subject.list(user, repo) { |obj| yielded << obj }
|
44
|
+
yielded.should == result
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
53
|
-
|
54
|
-
let(:
|
55
|
-
let(:status) { [404, "Not Found"] }
|
56
|
-
|
57
|
-
it "should return 404 with a message 'Not Found'" do
|
58
|
-
expect {
|
59
|
-
subject.list user, repo
|
60
|
-
}.to raise_error(Github::Error::NotFound)
|
61
|
-
end
|
48
|
+
it_should_behave_like 'request failure' do
|
49
|
+
let(:requestable) { subject.list user, repo }
|
62
50
|
end
|
51
|
+
|
63
52
|
end # list
|
@@ -32,10 +32,8 @@ describe Github::Repos, '#contributors' do
|
|
32
32
|
a_get(request_path).should have_been_made
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
contributors.should be_an Array
|
38
|
-
contributors.should have(1).items
|
35
|
+
it_should_behave_like 'an array of resources' do
|
36
|
+
let(:requestable) { subject.contributors user, repo }
|
39
37
|
end
|
40
38
|
|
41
39
|
it "should get branch information" do
|
@@ -49,14 +47,8 @@ describe Github::Repos, '#contributors' do
|
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
52
|
-
|
53
|
-
let(:
|
54
|
-
let(:status) { 404 }
|
55
|
-
|
56
|
-
it "should fail to get resource" do
|
57
|
-
expect {
|
58
|
-
subject.contributors user, repo
|
59
|
-
}.to raise_error(Github::Error::NotFound)
|
60
|
-
end
|
50
|
+
it_should_behave_like 'request failure' do
|
51
|
+
let(:requestable) { subject.contributors user, repo }
|
61
52
|
end
|
53
|
+
|
62
54
|
end # contributors
|
@@ -31,13 +31,8 @@ describe Github::Repos, '#delete' do
|
|
31
31
|
expect { subject.delete user, nil }.to raise_error(ArgumentError)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
let(:
|
36
|
-
|
37
|
-
it "should fail to delete resource that is not found" do
|
38
|
-
expect {
|
39
|
-
subject.delete user, repo
|
40
|
-
}.to raise_error(Github::Error::NotFound)
|
41
|
-
end
|
34
|
+
it_should_behave_like 'request failure' do
|
35
|
+
let(:requestable) { subject.delete user, repo }
|
42
36
|
end
|
37
|
+
|
43
38
|
end # delete
|
@@ -53,14 +53,8 @@ describe Github::Repos::Downloads, '#create' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
let(:
|
58
|
-
let(:status) { [404, "Not Found"] }
|
59
|
-
|
60
|
-
it "should faile to retrieve resource" do
|
61
|
-
expect {
|
62
|
-
subject.create user, repo, inputs
|
63
|
-
}.to raise_error(Github::Error::NotFound)
|
64
|
-
end
|
56
|
+
it_should_behave_like 'request failure' do
|
57
|
+
let(:requestable) { subject.create user, repo, inputs }
|
65
58
|
end
|
59
|
+
|
66
60
|
end # create
|
@@ -35,14 +35,8 @@ describe Github::Repos::Downloads, '#delete' do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
let(:
|
40
|
-
let(:status) { [404, "Not Found"] }
|
41
|
-
|
42
|
-
it "should fail to find resource" do
|
43
|
-
expect {
|
44
|
-
subject.delete user, repo, download_id
|
45
|
-
}.to raise_error(Github::Error::NotFound)
|
46
|
-
end
|
38
|
+
it_should_behave_like 'request failure' do
|
39
|
+
let(:requestable) { subject.delete user, repo, download_id }
|
47
40
|
end
|
41
|
+
|
48
42
|
end # delete
|
@@ -3,13 +3,12 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Github::Repos::Downloads, '#get' do
|
6
|
-
let(:github) { Github.new }
|
7
6
|
let(:user) { 'peter-murach' }
|
8
7
|
let(:repo) { 'github' }
|
9
8
|
let(:download_id) { 1 }
|
10
9
|
let(:request_path) { "/repos/#{user}/#{repo}/downloads/#{download_id}" }
|
11
10
|
|
12
|
-
after { reset_authentication_for(
|
11
|
+
after { reset_authentication_for(subject) }
|
13
12
|
|
14
13
|
before {
|
15
14
|
stub_get(request_path).
|
@@ -28,7 +27,7 @@ describe Github::Repos::Downloads, '#get' do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
it "should get the resource" do
|
31
|
-
|
30
|
+
subject.get user, repo, download_id
|
32
31
|
a_get(request_path).should have_been_made
|
33
32
|
end
|
34
33
|
|
@@ -44,15 +43,9 @@ describe Github::Repos::Downloads, '#get' do
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
|
48
|
-
let(:
|
49
|
-
let(:status) { [404, "Not Found"] }
|
50
|
-
|
51
|
-
it "should fail to retrive resource" do
|
52
|
-
expect {
|
53
|
-
subject.get user, repo, download_id
|
54
|
-
}.to raise_error(Github::Error::NotFound)
|
55
|
-
end
|
46
|
+
it_should_behave_like 'request failure' do
|
47
|
+
let(:requestable) { subject.get user, repo, download_id }
|
56
48
|
end
|
49
|
+
|
57
50
|
end # get
|
58
51
|
|
@@ -30,15 +30,8 @@ describe Github::Repos::Downloads, '#list' do
|
|
30
30
|
a_get(request_path).should have_been_made
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
downloads.should be_an Array
|
36
|
-
downloads.should have(1).items
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should be a mash type" do
|
40
|
-
downloads = subject.list user, repo
|
41
|
-
downloads.first.should be_a Hashie::Mash
|
33
|
+
it_should_behave_like 'an array of resources' do
|
34
|
+
let(:requestable) { subject.list user, repo }
|
42
35
|
end
|
43
36
|
|
44
37
|
it "should get download information" do
|
@@ -47,17 +40,14 @@ describe Github::Repos::Downloads, '#list' do
|
|
47
40
|
end
|
48
41
|
|
49
42
|
it "should yield to a block" do
|
50
|
-
|
51
|
-
subject.list(user, repo) { |
|
43
|
+
yielded = []
|
44
|
+
result = subject.list(user, repo) { |obj| yielded << obj }
|
45
|
+
yielded.should == result
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
55
|
-
|
56
|
-
let(:
|
57
|
-
let(:status) { [404, "Not Found"] }
|
58
|
-
|
59
|
-
it "should return 404 with a message 'Not Found'" do
|
60
|
-
expect { subject.list user, repo }.to raise_error(Github::Error::NotFound)
|
61
|
-
end
|
49
|
+
it_should_behave_like 'request failure' do
|
50
|
+
let(:requestable) { subject.list user, repo }
|
62
51
|
end
|
52
|
+
|
63
53
|
end # list
|
@@ -53,14 +53,8 @@ describe Github::Repos, '#edit' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
let(:
|
58
|
-
let(:status) { 404 }
|
59
|
-
|
60
|
-
it "should fail to find resource" do
|
61
|
-
expect {
|
62
|
-
subject.edit user, repo, inputs
|
63
|
-
}.to raise_error(Github::Error::NotFound)
|
64
|
-
end
|
56
|
+
it_should_behave_like 'request failure' do
|
57
|
+
let(:requestable) { subject.edit user, repo, inputs }
|
65
58
|
end
|
59
|
+
|
66
60
|
end # edit
|