github_api 0.8.11 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -46,7 +46,7 @@ describe Github::GitData::Trees, '#create' do
|
|
46
46
|
|
47
47
|
it "should return the resource" do
|
48
48
|
tree_sha = subject.create user, repo, inputs
|
49
|
-
tree_sha.should be_a
|
49
|
+
tree_sha.should be_a Github::ResponseWrapper
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should get the tree information" do
|
@@ -35,9 +35,9 @@ describe Github::GitData::Trees, '#get' do
|
|
35
35
|
tree.sha.should eql sha
|
36
36
|
end
|
37
37
|
|
38
|
-
it "should return
|
38
|
+
it "should return response wrapper" do
|
39
39
|
tree = subject.get user, repo, sha
|
40
|
-
tree.should be_a
|
40
|
+
tree.should be_a Github::ResponseWrapper
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -56,9 +56,9 @@ describe Github::GitData::Trees, '#get' do
|
|
56
56
|
tree.sha.should eql sha
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should return
|
59
|
+
it "should return response wrapper" do
|
60
60
|
tree = subject.get user, repo, sha, 'recursive' => true
|
61
|
-
tree.should be_a
|
61
|
+
tree.should be_a Github::ResponseWrapper
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -34,7 +34,7 @@ describe Github::Issues::Comments, '#create' do
|
|
34
34
|
|
35
35
|
it "should return the resource" do
|
36
36
|
comment = subject.create user, repo, issue_id, inputs
|
37
|
-
comment.should be_a
|
37
|
+
comment.should be_a Github::ResponseWrapper
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should get the comment information" do
|
@@ -34,7 +34,7 @@ describe Github::Issues::Comments, '#edit' do
|
|
34
34
|
|
35
35
|
it "should return the resource" do
|
36
36
|
comment = subject.edit user, repo, comment_id, inputs
|
37
|
-
comment.should be_a
|
37
|
+
comment.should be_a Github::ResponseWrapper
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should get the comment information" do
|
@@ -45,7 +45,7 @@ describe Github::Issues, '#edit' do
|
|
45
45
|
|
46
46
|
it "should return resource" do
|
47
47
|
issue = subject.edit user, repo, issue_id, inputs
|
48
|
-
issue.should be_a
|
48
|
+
issue.should be_a Github::ResponseWrapper
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should be able to retrieve information" do
|
@@ -44,7 +44,7 @@ describe Github::Issues::Labels, '#create' do
|
|
44
44
|
|
45
45
|
it "should return the resource" do
|
46
46
|
label = subject.create user, repo, inputs
|
47
|
-
label.should be_a
|
47
|
+
label.should be_a Github::ResponseWrapper
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should get the label information" do
|
@@ -45,7 +45,7 @@ describe Github::Issues::Labels, '#update' do
|
|
45
45
|
|
46
46
|
it "should return the resource" do
|
47
47
|
label = subject.update user, repo, label_id, inputs
|
48
|
-
label.should be_a
|
48
|
+
label.should be_a Github::ResponseWrapper
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should get the label information" do
|
@@ -40,7 +40,7 @@ describe Github::Issues::Milestones, '#create' do
|
|
40
40
|
|
41
41
|
it "should return the resource" do
|
42
42
|
milestone = subject.create user, repo, inputs
|
43
|
-
milestone.should be_a
|
43
|
+
milestone.should be_a Github::ResponseWrapper
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should get the milestone information" do
|
@@ -26,7 +26,7 @@ describe Github::Issues::Milestones, '#create' do
|
|
26
26
|
|
27
27
|
it "should return the resource" do
|
28
28
|
milestone = subject.delete user, repo, milestone_id
|
29
|
-
milestone.should be_a
|
29
|
+
milestone.should be_a Github::ResponseWrapper
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should get the milestone information" do
|
@@ -41,7 +41,7 @@ describe Github::Issues::Milestones, '#update' do
|
|
41
41
|
|
42
42
|
it "should return the resource" do
|
43
43
|
milestone = subject.update user, repo, milestone_id, inputs
|
44
|
-
milestone.should be_a
|
44
|
+
milestone.should be_a Github::ResponseWrapper
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should get the milestone information" do
|
@@ -41,7 +41,7 @@ describe Github::Orgs::Teams, '#edit' do
|
|
41
41
|
|
42
42
|
it "should return the resource" do
|
43
43
|
edited_team = subject.edit team, inputs
|
44
|
-
edited_team.should be_a
|
44
|
+
edited_team.should be_a Github::ResponseWrapper
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should get the team information" do
|
@@ -2,39 +2,44 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Github::PagedRequest do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
let(:path) { '/repos' }
|
12
|
-
let(:client) { Github::Client }
|
13
|
-
|
14
|
-
before do
|
15
|
-
Github.stub(:api_client).and_return client
|
16
|
-
client.stub(:get_request)
|
5
|
+
describe Github::PagedRequest, '#page_request' do
|
6
|
+
let(:current_api) { Github::Repos.new }
|
7
|
+
let(:path) { "/repositories/"}
|
8
|
+
let(:klass) {
|
9
|
+
klass = Class.new do
|
10
|
+
include Github::PagedRequest
|
17
11
|
end
|
12
|
+
}
|
18
13
|
|
19
|
-
|
20
|
-
Github.stub_chain(:api_client, :per_page).and_return nil
|
21
|
-
Github::PagedRequest.page_request path, {'page' => 3, 'per_page' => -1}
|
22
|
-
Github::PagedRequest.page.should eq 3
|
23
|
-
Github::PagedRequest.per_page.should eq 30
|
24
|
-
end
|
14
|
+
subject(:instance) { klass.new }
|
25
15
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Github::PagedRequest.page.should eq 1
|
30
|
-
Github::PagedRequest.per_page.should eq 33
|
31
|
-
end
|
16
|
+
before {
|
17
|
+
instance.stub(:current_api).and_return current_api
|
18
|
+
}
|
32
19
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
20
|
+
it { klass.constants.should include :FIRST_PAGE }
|
21
|
+
|
22
|
+
it { klass.constants.should include :PER_PAGE }
|
23
|
+
|
24
|
+
it { klass.constants.should include :NOT_FOUND }
|
25
|
+
|
26
|
+
it { should respond_to(:page_request) }
|
27
|
+
|
28
|
+
it 'calls get_request on api current instance' do
|
29
|
+
current_api.should_receive(:get_request).with(path, {})
|
30
|
+
instance.page_request(path)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'sets default per_page when only custom page passed' do
|
34
|
+
current_api.should_receive(:get_request).
|
35
|
+
with(path, {'page' => 3, 'per_page' => 30})
|
36
|
+
instance.page_request(path, {'page' => 3, 'per_page' => -1})
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'sets default page when only custom per_page passed' do
|
40
|
+
current_api.should_receive(:get_request).
|
41
|
+
with(path, {'page' => 1, 'per_page' => 33})
|
42
|
+
instance.page_request(path, {'page' => -1, 'per_page' => 33})
|
38
43
|
end
|
39
44
|
|
40
45
|
end # Github::PagedRequest
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PageIterator, 'when number' do
|
6
|
+
let(:header) { {"Link" => "<https://api.github.com/users/wycats/repos?page=4&per_page=20>; rel=\"next\", <https://api.github.com/users/wycats/repos?page=6&per_page=20>; rel=\"last\", <https://api.github.com/users/wycats/repos?page=1&per_page=20>; rel=\"first\", <https://api.github.com/users/wycats/repos?page=2&per_page=20>; rel=\"prev\""}
|
7
|
+
}
|
8
|
+
let(:links) { Github::PageLinks.new(header) }
|
9
|
+
|
10
|
+
let(:first_link) { "https://api.github.com/users/wycats/repos?page=1&per_page=20" }
|
11
|
+
let(:next_link) { "https://api.github.com/users/wycats/repos?page=4&per_page=20" }
|
12
|
+
let(:prev_link) { "https://api.github.com/users/wycats/repos?page=2&per_page=20" }
|
13
|
+
let(:last_link) { "https://api.github.com/users/wycats/repos?page=6&per_page=20" }
|
14
|
+
|
15
|
+
let(:current_api) { Github::Repos.new }
|
16
|
+
let(:user) { 'wycats' }
|
17
|
+
let(:response) { stub(:response).as_null_object }
|
18
|
+
|
19
|
+
subject(:instance) { described_class.new(links, current_api) }
|
20
|
+
|
21
|
+
before {
|
22
|
+
instance.stub(:has_next?).and_return true
|
23
|
+
stub_get("/users/#{user}/repos").
|
24
|
+
with(:query => { 'page' => '4', 'per_page' => '20'}).
|
25
|
+
to_return(:body => '', :status => 200, :headers => header)
|
26
|
+
}
|
27
|
+
|
28
|
+
it { described_class::ATTRIBUTES.should_not be_nil }
|
29
|
+
|
30
|
+
its(:first_page) { should eq 1 }
|
31
|
+
|
32
|
+
its(:first_page_uri) { should eq first_link }
|
33
|
+
|
34
|
+
its(:next_page) { should eq 4 }
|
35
|
+
|
36
|
+
its(:next_page_uri) { should eq next_link}
|
37
|
+
|
38
|
+
its(:prev_page) { should eq 2 }
|
39
|
+
|
40
|
+
its(:prev_page_uri) { should eq prev_link }
|
41
|
+
|
42
|
+
its(:last_page) { should eq 6 }
|
43
|
+
|
44
|
+
its(:last_page_uri) { should eq last_link }
|
45
|
+
|
46
|
+
context 'has_next?' do
|
47
|
+
it "return true when next_page_uri is present" do
|
48
|
+
expect(instance.has_next?).to be_true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'first page request' do
|
53
|
+
it 'returns nil if there are no more pages' do
|
54
|
+
instance.stub(:first_page_uri).and_return false
|
55
|
+
expect(instance.first).to be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'performs request' do
|
59
|
+
instance.should_receive(:page_request).
|
60
|
+
with("/users/#{user}/repos", 'per_page' => 20, 'page' => 1).
|
61
|
+
and_return response
|
62
|
+
instance.first
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'next page request' do
|
67
|
+
it 'returns nil if there are no more pages' do
|
68
|
+
instance.stub(:has_next?).and_return false
|
69
|
+
expect(instance.next).to be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'performs request' do
|
73
|
+
instance.should_receive(:page_request).with("/users/#{user}/repos",
|
74
|
+
'page' => 4,'per_page' => 20).and_return response
|
75
|
+
instance.next
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'prev page request' do
|
80
|
+
it 'returns nil if there are no more pages' do
|
81
|
+
instance.stub(:prev_page_uri).and_return false
|
82
|
+
expect(instance.prev).to be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'performs request' do
|
86
|
+
instance.should_receive(:page_request).with("/users/#{user}/repos",
|
87
|
+
'page' => 2,'per_page' => 20).and_return response
|
88
|
+
instance.prev
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'last page request' do
|
93
|
+
it 'returns nil if there are no more pages' do
|
94
|
+
instance.stub(:last_page_uri).and_return false
|
95
|
+
expect(instance.last).to be_nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'performs request' do
|
99
|
+
instance.should_receive(:page_request).with("/users/#{user}/repos",
|
100
|
+
'page' => 6,'per_page' => 20).and_return response
|
101
|
+
instance.last
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'get_page request' do
|
106
|
+
it 'returns nil if there are no more pages' do
|
107
|
+
instance.stub(:first_page_uri).and_return nil
|
108
|
+
instance.stub(:last_page_uri).and_return nil
|
109
|
+
expect(instance.get_page(5)).to be_nil
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'performs request' do
|
113
|
+
instance.should_receive(:page_request).with("/users/#{user}/repos",
|
114
|
+
'page' => 2,'per_page' => 20).and_return response
|
115
|
+
instance.get_page(2)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Github::PageIterator, 'when sha' do
|
6
|
+
let(:header) { {"Link" => "<https://api.github.com/repos/peter-murach/github/commits?last_sha=d1e503c02fa770859895dd0d12aedefa28b95723&per_page=30&sha=801d80dfd59bf1d2cb30a243799953ab683a3abd&top=801d80dfd59bf1d2cb30a243799953ab683a3abd>; rel=\"next\", <https://api.github.com/repos/peter-murach/github/commits?per_page=30&sha=801d80dfd59bf1d2cb30a243799953ab683a3abd>; rel=\"first\"" }
|
7
|
+
}
|
8
|
+
let(:links) { Github::PageLinks.new(header) }
|
9
|
+
|
10
|
+
let(:first_link) { "https://api.github.com/repos/peter-murach/github/commits?per_page=30&sha=801d80dfd59bf1d2cb30a243799953ab683a3abd" }
|
11
|
+
let(:next_link) { "https://api.github.com/repos/peter-murach/github/commits?last_sha=d1e503c02fa770859895dd0d12aedefa28b95723&per_page=30&sha=801d80dfd59bf1d2cb30a243799953ab683a3abd&top=801d80dfd59bf1d2cb30a243799953ab683a3abd" }
|
12
|
+
|
13
|
+
let(:top_sha) { '801d80dfd59bf1d2cb30a243799953ab683a3abd' }
|
14
|
+
let(:sha) { '801d80dfd59bf1d2cb30a243799953ab683a3abd' }
|
15
|
+
let(:last_sha) { "d1e503c02fa770859895dd0d12aedefa28b95723"}
|
16
|
+
|
17
|
+
let(:current_api) { Github::Repos.new }
|
18
|
+
let(:user) { 'wycats' }
|
19
|
+
let(:response) { stub(:response).as_null_object }
|
20
|
+
|
21
|
+
subject(:instance) { described_class.new(links, current_api) }
|
22
|
+
|
23
|
+
before {
|
24
|
+
instance.stub(:has_next?).and_return true
|
25
|
+
instance.stub(:next_page).and_return -1
|
26
|
+
stub_get("/repos/peter-murach/github/commits").
|
27
|
+
to_return(:body => '', :status => 200, :headers => header)
|
28
|
+
}
|
29
|
+
|
30
|
+
it { described_class::ATTRIBUTES.should_not be_nil }
|
31
|
+
|
32
|
+
its(:first_page) { should eq -1 }
|
33
|
+
|
34
|
+
its(:first_page_uri) { should eq first_link }
|
35
|
+
|
36
|
+
its(:next_page) { should eq -1 }
|
37
|
+
|
38
|
+
its(:next_page_uri) { should eq next_link}
|
39
|
+
|
40
|
+
its(:prev_page) { should eq -1 }
|
41
|
+
|
42
|
+
its(:prev_page_uri) { should be_nil }
|
43
|
+
|
44
|
+
its(:last_page) { should eq -1 }
|
45
|
+
|
46
|
+
its(:last_page_uri) { should be_nil }
|
47
|
+
|
48
|
+
context 'first page request' do
|
49
|
+
it 'performs request' do
|
50
|
+
instance.should_receive(:page_request).
|
51
|
+
with("/repos/peter-murach/github/commits",
|
52
|
+
'sha' => 'master', 'per_page' => 30).and_return response
|
53
|
+
instance.first
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'next page request' do
|
58
|
+
it 'performs request' do
|
59
|
+
instance.should_receive(:page_request).
|
60
|
+
with("/repos/peter-murach/github/commits", 'last_sha' => last_sha,
|
61
|
+
'sha' => last_sha, 'per_page' => 30, 'top' => top_sha).
|
62
|
+
and_return response
|
63
|
+
instance.next
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|