github_api 0.8.11 → 0.9.0
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 +21 -14
- data/features/activity/notifications.feature +15 -0
- data/features/cassettes/activity/notifications/list_user.yml +54 -0
- data/features/step_definitions/common_steps.rb +8 -9
- data/lib/github_api.rb +3 -4
- data/lib/github_api/activity.rb +8 -13
- data/lib/github_api/activity/events.rb +0 -5
- data/lib/github_api/activity/notifications.rb +0 -5
- data/lib/github_api/api.rb +27 -22
- data/lib/github_api/api_factory.rb +13 -12
- data/lib/github_api/authorizations.rb +0 -5
- data/lib/github_api/client.rb +33 -33
- data/lib/github_api/configuration.rb +10 -2
- data/lib/github_api/connection.rb +2 -3
- data/lib/github_api/constants.rb +0 -3
- data/lib/github_api/gists.rb +2 -7
- data/lib/github_api/git_data.rb +10 -15
- data/lib/github_api/git_data/blobs.rb +0 -5
- data/lib/github_api/git_data/commits.rb +0 -5
- data/lib/github_api/git_data/references.rb +3 -7
- data/lib/github_api/git_data/tags.rb +0 -5
- data/lib/github_api/git_data/trees.rb +0 -5
- data/lib/github_api/gitignore.rb +0 -5
- data/lib/github_api/issues.rb +10 -15
- data/lib/github_api/issues/comments.rb +0 -5
- data/lib/github_api/issues/events.rb +0 -5
- data/lib/github_api/issues/labels.rb +0 -5
- data/lib/github_api/issues/milestones.rb +0 -5
- data/lib/github_api/markdown.rb +0 -5
- data/lib/github_api/meta.rb +0 -5
- data/lib/github_api/orgs.rb +4 -9
- data/lib/github_api/page_iterator.rb +44 -29
- data/lib/github_api/paged_request.rb +12 -12
- data/lib/github_api/{result.rb → pagination.rb} +19 -86
- data/lib/github_api/params_hash.rb +1 -1
- data/lib/github_api/pull_requests.rb +2 -7
- data/lib/github_api/repos.rb +22 -27
- data/lib/github_api/request.rb +7 -4
- data/lib/github_api/response/header.rb +76 -0
- data/lib/github_api/response_wrapper.rb +126 -0
- data/lib/github_api/scopes.rb +1 -1
- data/lib/github_api/search.rb +0 -5
- data/lib/github_api/users.rb +6 -11
- data/lib/github_api/version.rb +2 -2
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/starring/starred_spec.rb +1 -1
- data/spec/github/activity/watching/watched_spec.rb +1 -1
- data/spec/github/api_factory_spec.rb +7 -8
- data/spec/github/api_spec.rb +0 -7
- data/spec/github/authorization_spec.rb +22 -32
- data/spec/github/authorizations/create_spec.rb +49 -0
- data/spec/github/authorizations/delete_spec.rb +39 -0
- data/spec/github/authorizations/get_spec.rb +49 -0
- data/spec/github/authorizations/list_spec.rb +55 -0
- data/spec/github/authorizations/update_spec.rb +50 -0
- data/spec/github/authorizations_spec.rb +2 -236
- data/spec/github/gists/comments/create_spec.rb +1 -1
- data/spec/github/gists/comments/edit_spec.rb +1 -1
- data/spec/github/gists/comments/get_spec.rb +1 -1
- data/spec/github/gists/create_spec.rb +1 -1
- data/spec/github/gists/edit_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +1 -1
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +1 -1
- data/spec/github/git_data/commits/get_spec.rb +1 -1
- data/spec/github/git_data/references/create_spec.rb +2 -2
- data/spec/github/git_data/references/get_spec.rb +1 -1
- data/spec/github/git_data/references/list_spec.rb +16 -6
- data/spec/github/git_data/tags/create_spec.rb +1 -1
- data/spec/github/git_data/tags/get_spec.rb +1 -1
- data/spec/github/git_data/trees/create_spec.rb +1 -1
- data/spec/github/git_data/trees/get_spec.rb +4 -4
- data/spec/github/issues/comments/create_spec.rb +1 -1
- data/spec/github/issues/comments/edit_spec.rb +1 -1
- data/spec/github/issues/comments/get_spec.rb +1 -1
- data/spec/github/issues/create_spec.rb +1 -1
- data/spec/github/issues/edit_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +1 -1
- data/spec/github/issues/get_spec.rb +1 -1
- data/spec/github/issues/labels/create_spec.rb +1 -1
- data/spec/github/issues/labels/get_spec.rb +1 -1
- data/spec/github/issues/labels/update_spec.rb +1 -1
- data/spec/github/issues/milestones/create_spec.rb +1 -1
- data/spec/github/issues/milestones/delete_spec.rb +1 -1
- data/spec/github/issues/milestones/get_spec.rb +1 -1
- data/spec/github/issues/milestones/update_spec.rb +1 -1
- data/spec/github/orgs/edit_spec.rb +1 -1
- data/spec/github/orgs/get_spec.rb +1 -1
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/paged_request_spec.rb +34 -29
- data/spec/github/pagination/iterator/number_spec.rb +118 -0
- data/spec/github/pagination/iterator/sha_spec.rb +67 -0
- data/spec/github/pull_requests/comments/create_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +1 -1
- data/spec/github/pull_requests/comments/get_spec.rb +1 -1
- data/spec/github/pull_requests/create_spec.rb +1 -1
- data/spec/github/pull_requests/get_spec.rb +1 -1
- data/spec/github/pull_requests/update_spec.rb +1 -1
- data/spec/github/repos/branch_spec.rb +1 -1
- data/spec/github/repos/comments/create_spec.rb +1 -1
- data/spec/github/repos/comments/get_spec.rb +1 -1
- data/spec/github/repos/comments/update_spec.rb +1 -1
- data/spec/github/repos/commits/get_spec.rb +1 -1
- data/spec/github/repos/create_spec.rb +1 -1
- data/spec/github/repos/downloads/create_spec.rb +1 -1
- data/spec/github/repos/downloads/get_spec.rb +1 -1
- data/spec/github/repos/edit_spec.rb +1 -1
- data/spec/github/repos/forks/create_spec.rb +1 -1
- data/spec/github/repos/get_spec.rb +1 -1
- data/spec/github/repos/hooks/create_spec.rb +1 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/hooks/get_spec.rb +1 -1
- data/spec/github/repos/languages_spec.rb +1 -1
- data/spec/github/repos/merging/merge_spec.rb +1 -1
- data/spec/github/repos/statuses/create_spec.rb +1 -1
- data/spec/github/repos/tags_spec.rb +1 -1
- data/spec/github/repos/teams_spec.rb +1 -1
- data/spec/github/request/endpoint_spec.rb +24 -0
- data/spec/github/request/request_spec.rb +38 -0
- data/spec/github/{result_spec.rb → response_wrapper_spec.rb} +14 -13
- data/spec/github/users/emails/list_spec.rb +1 -1
- data/spec/github/users/get_spec.rb +2 -7
- data/spec/github/users/keys/create_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/github_spec.rb +1 -6
- data/spec/{github/activity → integration}/activity_spec.rb +0 -0
- data/spec/{github/gists → integration}/gists_spec.rb +2 -0
- data/spec/{github/git_data → integration}/git_data_spec.rb +0 -0
- data/spec/{github/issues → integration}/issues_spec.rb +2 -0
- data/spec/integration/options_spec.rb +103 -23
- data/spec/{github/orgs → integration}/orgs_spec.rb +0 -0
- data/spec/{github/pull_requests → integration}/pull_requests_spec.rb +0 -0
- data/spec/{github → integration}/repos_spec.rb +2 -0
- data/spec/{github/users → integration}/users_spec.rb +0 -0
- data/spec/shared/array_of_resources_behaviour.rb +1 -1
- metadata +55 -46
- data/lib/github_api/page_uri_processor.rb +0 -25
- data/lib/github_api/response/helpers.rb +0 -21
- data/spec/github/page_iterator_spec.rb +0 -260
- data/spec/github/response/helpers_spec.rb +0 -16
|
@@ -41,7 +41,7 @@ describe Github::PullRequests::Comments, '#create' do
|
|
|
41
41
|
|
|
42
42
|
it "should return the resource" do
|
|
43
43
|
pull_request = subject.create user, repo, pull_request_id, inputs
|
|
44
|
-
pull_request.should be_a
|
|
44
|
+
pull_request.should be_a Github::ResponseWrapper
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "should get the request information" do
|
|
@@ -33,7 +33,7 @@ describe Github::PullRequests::Comments, '#edit' do
|
|
|
33
33
|
|
|
34
34
|
it "should return the resource" do
|
|
35
35
|
comment = subject.edit user, repo, comment_id, inputs
|
|
36
|
-
comment.should be_a
|
|
36
|
+
comment.should be_a Github::ResponseWrapper
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should get the comment information" do
|
|
@@ -36,7 +36,7 @@ describe Github::PullRequests, '#create' do
|
|
|
36
36
|
|
|
37
37
|
it "should return the resource" do
|
|
38
38
|
pull_request = subject.create user, repo, inputs
|
|
39
|
-
pull_request.should be_a
|
|
39
|
+
pull_request.should be_a Github::ResponseWrapper
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should get the request information" do
|
|
@@ -35,7 +35,7 @@ describe Github::PullRequests, '#update' do
|
|
|
35
35
|
|
|
36
36
|
it "should return the resource" do
|
|
37
37
|
pull_request = subject.update user, repo, number, inputs
|
|
38
|
-
pull_request.should be_a
|
|
38
|
+
pull_request.should be_a Github::ResponseWrapper
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should get the pull_request information" do
|
|
@@ -26,7 +26,7 @@ describe Github::Repos, '#branch' do
|
|
|
26
26
|
|
|
27
27
|
it "should return repository mash" do
|
|
28
28
|
repo_branch = subject.branch user, repo, branch
|
|
29
|
-
repo_branch.should be_a
|
|
29
|
+
repo_branch.should be_a Github::ResponseWrapper
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "should get repository branch information" do
|
|
@@ -40,7 +40,7 @@ describe Github::Repos::Comments, '#create' do
|
|
|
40
40
|
|
|
41
41
|
it "should return the resource" do
|
|
42
42
|
comment = subject.create user, repo, sha, inputs
|
|
43
|
-
comment.should be_a
|
|
43
|
+
comment.should be_a Github::ResponseWrapper
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should get the commit comment information" do
|
|
@@ -32,7 +32,7 @@ describe Github::Repos::Comments, '#update' do
|
|
|
32
32
|
|
|
33
33
|
it "should return the resource" do
|
|
34
34
|
comment = subject.update user, repo, comment_id, inputs
|
|
35
|
-
comment.should be_a
|
|
35
|
+
comment.should be_a Github::ResponseWrapper
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "should get the commit comment information" do
|
|
@@ -44,7 +44,7 @@ describe Github::Repos::Downloads, '#create' do
|
|
|
44
44
|
|
|
45
45
|
it "should return the resource" do
|
|
46
46
|
download = subject.create user, repo, inputs
|
|
47
|
-
download.should be_a
|
|
47
|
+
download.should be_a Github::ResponseWrapper
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should get the download information" do
|
|
@@ -44,7 +44,7 @@ describe Github::Repos, '#edit' do
|
|
|
44
44
|
|
|
45
45
|
it "should return resource" do
|
|
46
46
|
repository = subject.edit user, repo, inputs
|
|
47
|
-
repository.should be_a
|
|
47
|
+
repository.should be_a Github::ResponseWrapper
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should be able to retrieve information" do
|
|
@@ -35,7 +35,7 @@ describe Github::Repos, '#get' do
|
|
|
35
35
|
|
|
36
36
|
it "should return repository mash" do
|
|
37
37
|
repository = subject.get user, repo
|
|
38
|
-
repository.should be_a
|
|
38
|
+
repository.should be_a Github::ResponseWrapper
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should get repository information" do
|
|
@@ -61,7 +61,7 @@ describe Github::Repos::Hooks, '#list' do
|
|
|
61
61
|
|
|
62
62
|
it "should return resource" do
|
|
63
63
|
hook = subject.edit user, repo, hook_id, inputs
|
|
64
|
-
hook.should be_a
|
|
64
|
+
hook.should be_a Github::ResponseWrapper
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should be able to retrieve information" do
|
|
@@ -42,7 +42,7 @@ describe Github::Repos::Merging, '#merge' do
|
|
|
42
42
|
|
|
43
43
|
it "should return the resource" do
|
|
44
44
|
merge = subject.merge user, repo, inputs
|
|
45
|
-
merge.should be_a
|
|
45
|
+
merge.should be_a Github::ResponseWrapper
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "should get the commit comment information" do
|
|
@@ -38,7 +38,7 @@ describe Github::Repos::Statuses, '#create' do
|
|
|
38
38
|
|
|
39
39
|
it "should return the resource" do
|
|
40
40
|
status = subject.create user, repo, sha, inputs
|
|
41
|
-
status.should be_a
|
|
41
|
+
status.should be_a Github::ResponseWrapper
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "should get the status information" do
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::API, 'endpoint' do
|
|
6
|
+
let(:endpoint) { "https://my-company/api/v3/" }
|
|
7
|
+
let(:options) { {:endpoint => endpoint } }
|
|
8
|
+
let(:path) { "/repos/GitHub/issues-dev/issues" }
|
|
9
|
+
|
|
10
|
+
subject(:api) { described_class.new(options) }
|
|
11
|
+
|
|
12
|
+
before {
|
|
13
|
+
stub_get(path, 'https://my-company/api/v3').
|
|
14
|
+
to_return(:body => "[]", :status => 200, :headers =>{})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
its(:endpoint) { should == endpoint }
|
|
18
|
+
|
|
19
|
+
it "doesn't truncate endpoint" do
|
|
20
|
+
expect {
|
|
21
|
+
api.get_request(path)
|
|
22
|
+
}.not_to raise_error(WebMock::NetConnectNotAllowedError)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Github::API, '#request' do
|
|
6
|
+
let(:token) { "2fdsfdo23fsdf3omkhen34n2jh" }
|
|
7
|
+
let(:per_page) { 100 }
|
|
8
|
+
let(:path) { "/api/v3/repos/GitHub/issues-dev/issues" }
|
|
9
|
+
|
|
10
|
+
let(:url_prefix) { "https://my-company/api/v3/repos/GitHub/issues-dev/issues?access_token=#{token}&page=2&per_page=#{per_page}" }
|
|
11
|
+
|
|
12
|
+
let(:conn) { Faraday::Connection.new }
|
|
13
|
+
|
|
14
|
+
before {
|
|
15
|
+
conn.url_prefix = url_prefix
|
|
16
|
+
stub_get(path, 'https://my-company').
|
|
17
|
+
with(:query => {'access_token' => token, :page => 2, :per_page => per_page}).
|
|
18
|
+
to_return(:body => "", :status => 200, :headers =>{})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
subject { described_class.new() }
|
|
22
|
+
|
|
23
|
+
it 'sets connection path correctly' do
|
|
24
|
+
expect(conn.path_prefix).to eql(path)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'responds to get request' do
|
|
28
|
+
expect(subject).to respond_to(:get_request)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'handles enterprise uri correctly' do
|
|
32
|
+
subject.stub(:connection).and_return conn
|
|
33
|
+
|
|
34
|
+
expect {
|
|
35
|
+
subject.get_request(path)
|
|
36
|
+
}.not_to raise_error(WebMock::NetConnectNotAllowedError)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
describe Github::
|
|
5
|
+
describe Github::ResponseWrapper do
|
|
6
6
|
let(:github) { Github.new }
|
|
7
7
|
let(:user) { 'wycats' }
|
|
8
8
|
let(:res) { github.activity.events.public({ 'per_page' => 20 }) }
|
|
@@ -45,35 +45,35 @@ describe Github::Result do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "should read response content_type " do
|
|
48
|
-
res.content_type.should match 'application/json'
|
|
48
|
+
res.headers.content_type.should match 'application/json'
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should read response content_length " do
|
|
52
|
-
res.content_length.should match '344'
|
|
52
|
+
res.headers.content_length.should match '344'
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should read response ratelimit limit" do
|
|
56
|
-
res.ratelimit_limit.should == '5000'
|
|
56
|
+
res.headers.ratelimit_limit.should == '5000'
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "should read response ratelimit remaining" do
|
|
60
|
-
res.ratelimit_remaining.should == '4999'
|
|
60
|
+
res.headers.ratelimit_remaining.should == '4999'
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "should read response status" do
|
|
64
|
-
res.status.should be 200
|
|
64
|
+
res.headers.status.should be 200
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it 'should read response etag' do
|
|
68
|
-
res.etag.should eql "\"d9a88f20567726e29d35c6fae87cef2f\""
|
|
68
|
+
res.headers.etag.should eql "\"d9a88f20567726e29d35c6fae87cef2f\""
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it 'should read response date' do
|
|
72
|
-
res.date.should eql "Sun, 05 Feb 2012 15:02:34 GMT"
|
|
72
|
+
res.headers.date.should eql "Sun, 05 Feb 2012 15:02:34 GMT"
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
it 'should read response server' do
|
|
76
|
-
res.server.should eql "nginx/1.0.4"
|
|
76
|
+
res.headers.server.should eql "nginx/1.0.4"
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it "should assess successful" do
|
|
@@ -85,8 +85,9 @@ describe Github::Result do
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context "pagination methods" do
|
|
88
|
-
let(:
|
|
89
|
-
let(:
|
|
88
|
+
let(:links) { Github::PageLinks.new({}) }
|
|
89
|
+
let(:current_api) { stub(:api).as_null_object }
|
|
90
|
+
let(:iterator) { Github::PageIterator.new(links, current_api) }
|
|
90
91
|
|
|
91
92
|
before do
|
|
92
93
|
described_class.stub(:page_iterator).and_return iterator
|
|
@@ -98,8 +99,8 @@ describe Github::Result do
|
|
|
98
99
|
|
|
99
100
|
%w[ next prev ].each do |link|
|
|
100
101
|
context "#{link}_page" do
|
|
101
|
-
it "
|
|
102
|
-
res.send(:"#{link}_page").should
|
|
102
|
+
it "responds to #{link}_page request" do
|
|
103
|
+
res.send(:"#{link}_page").should be_nil
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
it 'should have no link information' do
|
|
@@ -24,14 +24,9 @@ describe Github::Users, '#get' do
|
|
|
24
24
|
a_get(request_path).should have_been_made
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
it "should
|
|
27
|
+
it "should be a response wrapper" do
|
|
28
28
|
user_resource = subject.get :user => user
|
|
29
|
-
user_resource.should be_a
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should be a mash type" do
|
|
33
|
-
user_resource = subject.get :user => user
|
|
34
|
-
user_resource.should be_a Hashie::Mash
|
|
29
|
+
user_resource.should be_a Github::ResponseWrapper
|
|
35
30
|
end
|
|
36
31
|
|
|
37
32
|
it "should get org information" do
|
|
@@ -40,7 +40,7 @@ describe Github::Users, '#update' do
|
|
|
40
40
|
|
|
41
41
|
it "should return the resource" do
|
|
42
42
|
user_resource = subject.update inputs
|
|
43
|
-
user_resource.should be_a
|
|
43
|
+
user_resource.should be_a Github::ResponseWrapper
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should get the resource information" do
|