tinybucket 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/Gemfile +8 -7
- data/README.md +28 -5
- data/Rakefile +1 -0
- data/lib/faraday_middleware/follow_oauth_redirects.rb +5 -2
- data/lib/tinybucket.rb +2 -0
- data/lib/tinybucket/api.rb +3 -0
- data/lib/tinybucket/api/base_api.rb +2 -0
- data/lib/tinybucket/api/branch_restrictions_api.rb +6 -5
- data/lib/tinybucket/api/branches_api.rb +48 -0
- data/lib/tinybucket/api/build_status_api.rb +15 -1
- data/lib/tinybucket/api/comments_api.rb +7 -6
- data/lib/tinybucket/api/commits_api.rb +25 -4
- data/lib/tinybucket/api/diff_api.rb +4 -3
- data/lib/tinybucket/api/helper.rb +3 -0
- data/lib/tinybucket/api/helper/api_helper.rb +2 -0
- data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +2 -0
- data/lib/tinybucket/api/helper/branches_helper.rb +29 -0
- data/lib/tinybucket/api/helper/build_status_helper.rb +11 -0
- data/lib/tinybucket/api/helper/comments_helper.rb +2 -0
- data/lib/tinybucket/api/helper/commits_helper.rb +8 -0
- data/lib/tinybucket/api/helper/diff_helper.rb +2 -0
- data/lib/tinybucket/api/helper/pull_requests_helper.rb +2 -0
- data/lib/tinybucket/api/helper/repo_helper.rb +2 -0
- data/lib/tinybucket/api/helper/repos_helper.rb +2 -0
- data/lib/tinybucket/api/helper/team_helper.rb +2 -0
- data/lib/tinybucket/api/helper/user_helper.rb +2 -0
- data/lib/tinybucket/api/pull_requests_api.rb +4 -3
- data/lib/tinybucket/api/repo_api.rb +4 -3
- data/lib/tinybucket/api/repos_api.rb +3 -1
- data/lib/tinybucket/api/team_api.rb +4 -2
- data/lib/tinybucket/api/user_api.rb +3 -1
- data/lib/tinybucket/api_factory.rb +2 -0
- data/lib/tinybucket/client.rb +3 -2
- data/lib/tinybucket/config.rb +5 -1
- data/lib/tinybucket/connection.rb +21 -8
- data/lib/tinybucket/constants.rb +2 -0
- data/lib/tinybucket/enumerator.rb +2 -0
- data/lib/tinybucket/error.rb +2 -0
- data/lib/tinybucket/error/base_error.rb +2 -0
- data/lib/tinybucket/error/conflict.rb +2 -0
- data/lib/tinybucket/error/not_found.rb +2 -0
- data/lib/tinybucket/error/service_error.rb +2 -0
- data/lib/tinybucket/iterator.rb +4 -2
- data/lib/tinybucket/model.rb +3 -0
- data/lib/tinybucket/model/base.rb +2 -2
- data/lib/tinybucket/model/branch.rb +48 -0
- data/lib/tinybucket/model/branch_restriction.rb +4 -2
- data/lib/tinybucket/model/build_status.rb +3 -1
- data/lib/tinybucket/model/comment.rb +4 -2
- data/lib/tinybucket/model/commit.rb +6 -2
- data/lib/tinybucket/model/concerns.rb +2 -0
- data/lib/tinybucket/model/concerns/acceptable_attributes.rb +2 -0
- data/lib/tinybucket/model/concerns/api_callable.rb +2 -0
- data/lib/tinybucket/model/concerns/enumerable.rb +2 -0
- data/lib/tinybucket/model/concerns/reloadable.rb +2 -0
- data/lib/tinybucket/model/concerns/repository_keys.rb +2 -0
- data/lib/tinybucket/model/error_response.rb +4 -2
- data/lib/tinybucket/model/page.rb +4 -2
- data/lib/tinybucket/model/profile.rb +4 -2
- data/lib/tinybucket/model/pull_request.rb +4 -2
- data/lib/tinybucket/model/repository.rb +31 -5
- data/lib/tinybucket/model/team.rb +4 -2
- data/lib/tinybucket/null_logger.rb +2 -0
- data/lib/tinybucket/parser.rb +5 -0
- data/lib/tinybucket/parser/base_parser.rb +3 -2
- data/lib/tinybucket/parser/branch_parser.rb +13 -0
- data/lib/tinybucket/parser/branch_restriction_parser.rb +2 -0
- data/lib/tinybucket/parser/branch_restrictions_parser.rb +2 -0
- data/lib/tinybucket/parser/branches_parser.rb +11 -0
- data/lib/tinybucket/parser/build_status_parser.rb +2 -0
- data/lib/tinybucket/parser/builds_parser.rb +11 -0
- data/lib/tinybucket/parser/comment_parser.rb +2 -0
- data/lib/tinybucket/parser/comments_parser.rb +2 -0
- data/lib/tinybucket/parser/commit_parser.rb +2 -0
- data/lib/tinybucket/parser/commits_parser.rb +2 -0
- data/lib/tinybucket/parser/profile_parser.rb +2 -0
- data/lib/tinybucket/parser/profiles_parser.rb +2 -0
- data/lib/tinybucket/parser/pull_request_parser.rb +2 -0
- data/lib/tinybucket/parser/pull_requests_parser.rb +2 -0
- data/lib/tinybucket/parser/repo_parser.rb +2 -0
- data/lib/tinybucket/parser/repos_parser.rb +2 -0
- data/lib/tinybucket/parser/team_parser.rb +2 -0
- data/lib/tinybucket/parser/teams_parser.rb +2 -0
- data/lib/tinybucket/request.rb +2 -0
- data/lib/tinybucket/resource.rb +3 -0
- data/lib/tinybucket/resource/base.rb +6 -0
- data/lib/tinybucket/resource/branch_restrictions.rb +2 -0
- data/lib/tinybucket/resource/branches.rb +35 -0
- data/lib/tinybucket/resource/commit/base.rb +2 -0
- data/lib/tinybucket/resource/commit/build_statuses.rb +6 -3
- data/lib/tinybucket/resource/commit/comments.rb +2 -0
- data/lib/tinybucket/resource/commits.rb +13 -0
- data/lib/tinybucket/resource/forks.rb +2 -0
- data/lib/tinybucket/resource/pull_request/base.rb +2 -0
- data/lib/tinybucket/resource/pull_request/comments.rb +2 -0
- data/lib/tinybucket/resource/pull_request/commits.rb +2 -0
- data/lib/tinybucket/resource/pull_requests.rb +2 -0
- data/lib/tinybucket/resource/repos.rb +2 -0
- data/lib/tinybucket/resource/team/base.rb +2 -0
- data/lib/tinybucket/resource/team/followers.rb +2 -0
- data/lib/tinybucket/resource/team/following.rb +2 -0
- data/lib/tinybucket/resource/team/members.rb +2 -0
- data/lib/tinybucket/resource/team/repos.rb +2 -0
- data/lib/tinybucket/resource/user/base.rb +2 -0
- data/lib/tinybucket/resource/user/followers.rb +2 -0
- data/lib/tinybucket/resource/user/following.rb +2 -0
- data/lib/tinybucket/resource/user/repos.rb +2 -0
- data/lib/tinybucket/resource/watchers.rb +2 -0
- data/lib/tinybucket/response.rb +2 -0
- data/lib/tinybucket/response/handler.rb +2 -0
- data/lib/tinybucket/version.rb +3 -1
- data/tinybucket.gemspec +1 -1
- metadata +11 -193
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -33
- data/.rspec +0 -1
- data/.travis.yml +0 -13
- data/Guardfile +0 -13
- data/spec/fixtures/branch_restriction.json +0 -17
- data/spec/fixtures/build_status.json +0 -16
- data/spec/fixtures/comment.json +0 -30
- data/spec/fixtures/commit.json +0 -83
- data/spec/fixtures/profile.json +0 -29
- data/spec/fixtures/pull_request.json +0 -106
- data/spec/fixtures/repositories/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/1/get.json +0 -17
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/get.json +0 -101
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/approve/post.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/1/get.json +0 -38
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/get.json +0 -40
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/get.json +0 -83
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/post.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json +0 -16
- data/spec/fixtures/repositories/test_owner/test_repo/commits/get.json +0 -73
- data/spec/fixtures/repositories/test_owner/test_repo/diff/1/get.json +0 -21
- data/spec/fixtures/repositories/test_owner/test_repo/forks/get.json +0 -78
- data/spec/fixtures/repositories/test_owner/test_repo/get.json +0 -71
- data/spec/fixtures/repositories/test_owner/test_repo/patch/1/get.json +0 -29
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/delete.json +0 -3
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/post.json +0 -3
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/1/get.json +0 -30
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +0 -44
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +0 -66
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/decline/post.json +0 -116
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/diff/get.txt +0 -13
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/get.json +0 -164
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/merge/post.json +0 -123
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_declined.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_merged.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_open.json +0 -112
- data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +0 -32
- data/spec/fixtures/repository.json +0 -72
- data/spec/fixtures/team.json +0 -32
- data/spec/fixtures/teams/test_team/followers/get.json +0 -36
- data/spec/fixtures/teams/test_team/following/get.json +0 -39
- data/spec/fixtures/teams/test_team/get.json +0 -32
- data/spec/fixtures/teams/test_team/members/get.json +0 -36
- data/spec/fixtures/teams/test_team/repositories/get.json +0 -125
- data/spec/fixtures/users/test_owner/followers/get.json +0 -65
- data/spec/fixtures/users/test_owner/following/get.json +0 -100
- data/spec/fixtures/users/test_owner/get.json +0 -29
- data/spec/lib/tinybucket/api/branch_restrictions_api_spec.rb +0 -77
- data/spec/lib/tinybucket/api/build_status_api_spec.rb +0 -65
- data/spec/lib/tinybucket/api/comments_api_spec.rb +0 -132
- data/spec/lib/tinybucket/api/commits_api_spec.rb +0 -152
- data/spec/lib/tinybucket/api/diff_api_spec.rb +0 -5
- data/spec/lib/tinybucket/api/pull_requests_api_spec.rb +0 -259
- data/spec/lib/tinybucket/api/repo_api_spec.rb +0 -99
- data/spec/lib/tinybucket/api/repos_api_spec.rb +0 -27
- data/spec/lib/tinybucket/api/team_api_spec.rb +0 -82
- data/spec/lib/tinybucket/api/user_api_spec.rb +0 -73
- data/spec/lib/tinybucket/api_factory_spec.rb +0 -18
- data/spec/lib/tinybucket/client_spec.rb +0 -100
- data/spec/lib/tinybucket/connection_spec.rb +0 -30
- data/spec/lib/tinybucket/error/service_error_spec.rb +0 -23
- data/spec/lib/tinybucket/model/branch_restriction_spec.rb +0 -35
- data/spec/lib/tinybucket/model/build_status_spec.rb +0 -66
- data/spec/lib/tinybucket/model/comment_spec.rb +0 -37
- data/spec/lib/tinybucket/model/commit_spec.rb +0 -108
- data/spec/lib/tinybucket/model/page_spec.rb +0 -28
- data/spec/lib/tinybucket/model/profile_spec.rb +0 -52
- data/spec/lib/tinybucket/model/pull_request_spec.rb +0 -141
- data/spec/lib/tinybucket/model/repository_spec.rb +0 -131
- data/spec/lib/tinybucket/model/team_spec.rb +0 -70
- data/spec/lib/tinybucket/null_logger_spec.rb +0 -53
- data/spec/lib/tinybucket/resource/branch_restrictions_spec.rb +0 -60
- data/spec/lib/tinybucket/resource/commit/build_statuses_spec.rb +0 -50
- data/spec/lib/tinybucket/resource/commit/comments_spec.rb +0 -49
- data/spec/lib/tinybucket/resource/commits_spec.rb +0 -43
- data/spec/lib/tinybucket/resource/forks_spec.rb +0 -36
- data/spec/lib/tinybucket/resource/pull_request/comments_spec.rb +0 -41
- data/spec/lib/tinybucket/resource/pull_request/commits_spec.rb +0 -41
- data/spec/lib/tinybucket/resource/pull_requests_spec.rb +0 -59
- data/spec/lib/tinybucket/resource/repos_spec.rb +0 -76
- data/spec/lib/tinybucket/resource/team/followers_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/following_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/members_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/team/repos_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/followers_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/following_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/user/repos_spec.rb +0 -27
- data/spec/lib/tinybucket/resource/watchers_spec.rb +0 -38
- data/spec/lib/tinybucket_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -45
- data/spec/support/api_response_macros.rb +0 -74
- data/spec/support/fixture_macros.rb +0 -5
- data/spec/support/model_macros.rb +0 -103
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::RepoApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:repo_owner) { 'test_owner' }
|
7
|
-
let(:repo_slug) { 'test_repo' }
|
8
|
-
let(:request_path) { nil }
|
9
|
-
|
10
|
-
let(:api) do
|
11
|
-
api = Tinybucket::Api::RepoApi.new
|
12
|
-
api.repo_owner = repo_owner
|
13
|
-
api.repo_slug = repo_slug
|
14
|
-
api
|
15
|
-
end
|
16
|
-
|
17
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
18
|
-
|
19
|
-
before { stub_apiresponse(:get, request_path) if request_path }
|
20
|
-
|
21
|
-
describe 'find' do
|
22
|
-
subject { api.find }
|
23
|
-
|
24
|
-
context 'when without repo_owner and repo_slug' do
|
25
|
-
let(:repo_owner) { nil }
|
26
|
-
let(:repo_slug) { nil }
|
27
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when without repo_owner' do
|
31
|
-
let(:repo_owner) { nil }
|
32
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when without repo_slug' do
|
36
|
-
let(:repo_slug) { nil }
|
37
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when with repo_owner and repo_slug' do
|
41
|
-
let(:request_path) { "/repositories/#{repo_owner}/#{repo_slug}" }
|
42
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Repository) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'watchers' do
|
47
|
-
subject { api.watchers }
|
48
|
-
|
49
|
-
context 'when without repo_owner and repo_slug' do
|
50
|
-
let(:repo_owner) { nil }
|
51
|
-
let(:repo_slug) { nil }
|
52
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when without repo_owner' do
|
56
|
-
let(:repo_owner) { nil }
|
57
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when without repo_slug' do
|
61
|
-
let(:repo_slug) { nil }
|
62
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when with repo_owner and repo_slug' do
|
66
|
-
let(:request_path) do
|
67
|
-
"/repositories/#{repo_owner}/#{repo_slug}/watchers"
|
68
|
-
end
|
69
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'forks' do
|
74
|
-
subject { api.forks }
|
75
|
-
|
76
|
-
context 'when without repo_owner and repo_slug' do
|
77
|
-
let(:repo_owner) { nil }
|
78
|
-
let(:repo_slug) { nil }
|
79
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when without repo_owner' do
|
83
|
-
let(:repo_owner) { nil }
|
84
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'when without repo_slug' do
|
88
|
-
let(:repo_slug) { nil }
|
89
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'when with repo_owner and repo_slug' do
|
93
|
-
let(:request_path) do
|
94
|
-
"/repositories/#{repo_owner}/#{repo_slug}/forks"
|
95
|
-
end
|
96
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::ReposApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:api) { Tinybucket::Api::ReposApi.new }
|
7
|
-
|
8
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
9
|
-
|
10
|
-
describe 'list' do
|
11
|
-
subject { api.list(options) }
|
12
|
-
|
13
|
-
before { stub_apiresponse(:get, request_path) }
|
14
|
-
|
15
|
-
context 'without owner' do
|
16
|
-
let(:options) { {} }
|
17
|
-
let(:request_path) { '/repositories' }
|
18
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'with owner' do
|
22
|
-
let(:options) { { owner: 'test_owner' } }
|
23
|
-
let(:request_path) { '/repositories/test_owner' }
|
24
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::TeamApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:api) { Tinybucket::Api::TeamApi.new }
|
7
|
-
let(:teamname) { 'test_team' }
|
8
|
-
let(:request_path) { nil }
|
9
|
-
before { stub_apiresponse(:get, request_path) if request_path }
|
10
|
-
|
11
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
12
|
-
|
13
|
-
describe 'profile' do
|
14
|
-
subject { api.find(teamname) }
|
15
|
-
|
16
|
-
context 'when without teamname' do
|
17
|
-
let(:teamname) { nil }
|
18
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'when with teamname' do
|
22
|
-
let(:request_path) { "/teams/#{teamname}" }
|
23
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Team) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'members' do
|
28
|
-
subject { api.members(teamname) }
|
29
|
-
|
30
|
-
context 'when without teamname' do
|
31
|
-
let(:teamname) { nil }
|
32
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when with teamname' do
|
36
|
-
let(:request_path) { "/teams/#{teamname}/members" }
|
37
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'followers' do
|
42
|
-
subject { api.followers(teamname) }
|
43
|
-
|
44
|
-
context 'when without teamname' do
|
45
|
-
let(:teamname) { nil }
|
46
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when with teamname' do
|
50
|
-
let(:request_path) { "/teams/#{teamname}/followers" }
|
51
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'following' do
|
56
|
-
subject { api.following(teamname) }
|
57
|
-
|
58
|
-
context 'when without teamname' do
|
59
|
-
let(:teamname) { nil }
|
60
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when with teamname' do
|
64
|
-
let(:request_path) { "/teams/#{teamname}/following" }
|
65
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'repos' do
|
70
|
-
subject { api.repos(teamname) }
|
71
|
-
|
72
|
-
context 'when without teamname' do
|
73
|
-
let(:teamname) { nil }
|
74
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when with teamname' do
|
78
|
-
let(:request_path) { "/teams/#{teamname}/repositories" }
|
79
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Api::UserApi do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:api) do
|
7
|
-
api = Tinybucket::Api::UserApi.new
|
8
|
-
api.username = user
|
9
|
-
api
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:user) { 'test_owner' }
|
13
|
-
let(:request_path) { nil }
|
14
|
-
before { stub_apiresponse(:get, request_path) if request_path }
|
15
|
-
|
16
|
-
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
17
|
-
|
18
|
-
describe 'profile' do
|
19
|
-
subject { api.profile }
|
20
|
-
|
21
|
-
context 'when without username' do
|
22
|
-
let(:user) { nil }
|
23
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when with username' do
|
27
|
-
let(:request_path) { "/users/#{user}" }
|
28
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Profile) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'followers' do
|
33
|
-
subject { api.followers }
|
34
|
-
|
35
|
-
context 'when without username' do
|
36
|
-
let(:user) { nil }
|
37
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when with username' do
|
41
|
-
let(:request_path) { "/users/#{user}/followers" }
|
42
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'following' do
|
47
|
-
subject { api.following }
|
48
|
-
|
49
|
-
context 'when without username' do
|
50
|
-
let(:user) { nil }
|
51
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when with username' do
|
55
|
-
let(:request_path) { "/users/#{user}/following" }
|
56
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'repos' do
|
61
|
-
subject { api.repos }
|
62
|
-
|
63
|
-
context 'when without username' do
|
64
|
-
let(:user) { nil }
|
65
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when with username' do
|
69
|
-
let(:request_path) { "/repositories/#{user}" }
|
70
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::ApiFactory do
|
4
|
-
|
5
|
-
describe 'create_instance' do
|
6
|
-
subject { Tinybucket::ApiFactory.create_instance(klass_name) }
|
7
|
-
|
8
|
-
context 'with valid klass_name' do
|
9
|
-
let(:klass_name) { 'PullRequests' }
|
10
|
-
it { expect(subject).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'with invalid klass_name' do
|
14
|
-
let(:klass_name) { 'Invalid Klass Name' }
|
15
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Client do
|
4
|
-
include ApiResponseMacros
|
5
|
-
|
6
|
-
let(:client) { Tinybucket::Client.new }
|
7
|
-
|
8
|
-
describe 'new' do
|
9
|
-
subject { Tinybucket::Client.new }
|
10
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Client) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'repos' do
|
14
|
-
context 'when get public repositories' do
|
15
|
-
before { stub_apiresponse(:get, '/repositories') }
|
16
|
-
|
17
|
-
context 'without options' do
|
18
|
-
subject { client.repos }
|
19
|
-
it { expect(subject).to be_instance_of(Tinybucket::Resource::Repos) }
|
20
|
-
it { expect(subject.instance_variable_get(:@owner)).to be_nil }
|
21
|
-
end
|
22
|
-
context 'with options' do
|
23
|
-
subject { client.repos(options) }
|
24
|
-
let(:options) { {} }
|
25
|
-
it { expect(subject).to be_instance_of(Tinybucket::Resource::Repos) }
|
26
|
-
it { expect(subject.instance_variable_get(:@owner)).to be_nil }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when get repositories of the owner' do
|
31
|
-
let(:owner) { 'test_owner' }
|
32
|
-
let(:request_path) { "/repositories/#{owner}" }
|
33
|
-
before { stub_apiresponse(:get, request_path) }
|
34
|
-
|
35
|
-
context 'without options' do
|
36
|
-
subject { client.repos(owner) }
|
37
|
-
it { expect(subject).to be_instance_of(Tinybucket::Resource::Repos) }
|
38
|
-
it { expect(subject.instance_variable_get(:@owner)).to eq(owner) }
|
39
|
-
end
|
40
|
-
context 'with options' do
|
41
|
-
let(:options) { { page: 1 } }
|
42
|
-
subject { client.repos(owner, options) }
|
43
|
-
it { expect(subject).to be_instance_of(Tinybucket::Resource::Repos) }
|
44
|
-
it { expect(subject.instance_variable_get(:@owner)).to eq(owner) }
|
45
|
-
end
|
46
|
-
context 'with invalid options' do
|
47
|
-
subject { client.repos(owner, 'invalid options') }
|
48
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
49
|
-
end
|
50
|
-
context 'with invalid owner and options' do
|
51
|
-
let(:invalid_owner) { 200 }
|
52
|
-
let(:options) { { page: 1 } }
|
53
|
-
subject { client.repos(invalid_owner, options) }
|
54
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when invalid argument passed' do
|
59
|
-
context 'with a integer' do
|
60
|
-
subject { client.repos(20) }
|
61
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'with a string and string' do
|
65
|
-
subject { client.repos('test_owner', 'test_repository') }
|
66
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'with three arguments' do
|
70
|
-
subject { client.repos('a', 'b', 'c') }
|
71
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'repo' do
|
77
|
-
let(:repo_owner) { 'test_owner' }
|
78
|
-
let(:repo_slug) { 'test_repo' }
|
79
|
-
|
80
|
-
subject { client.repo(repo_owner, repo_slug) }
|
81
|
-
|
82
|
-
it 'return RepoApi instance' do
|
83
|
-
expect(subject).to be_instance_of(Tinybucket::Model::Repository)
|
84
|
-
expect(subject.repo_owner).to eq(repo_owner)
|
85
|
-
expect(subject.repo_slug).to eq(repo_slug)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'team' do
|
90
|
-
let(:team) { 'test_team' }
|
91
|
-
subject { client.team(team) }
|
92
|
-
it { expect(subject).to be_instance_of(Tinybucket::Model::Team) }
|
93
|
-
end
|
94
|
-
|
95
|
-
describe 'user' do
|
96
|
-
let(:user) { 'test_owner' }
|
97
|
-
subject { client.user(user) }
|
98
|
-
it { expect(subject).to be_instance_of(Tinybucket::Model::Profile) }
|
99
|
-
end
|
100
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Connection do
|
4
|
-
|
5
|
-
class MockApi
|
6
|
-
include Tinybucket::Connection
|
7
|
-
|
8
|
-
def config(key)
|
9
|
-
nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:mock_api){ MockApi.new }
|
14
|
-
|
15
|
-
describe 'clear_cache' do
|
16
|
-
pending 'TODO: this method is required ?'
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'caching?' do
|
20
|
-
pending 'TODO: this method is required ?'
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'connection(options, parser)' do
|
24
|
-
subject{ mock_api.connection }
|
25
|
-
|
26
|
-
context 'when no params are given ' do
|
27
|
-
it { expect(subject).to be_instance_of(Faraday::Connection) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Tinybucket::Error::ServiceError do
|
4
|
-
context 'initialize' do
|
5
|
-
let(:env) do
|
6
|
-
{
|
7
|
-
response_headers: [],
|
8
|
-
method: 'POST',
|
9
|
-
url: 'https://api.example.org/path/to',
|
10
|
-
status: 500,
|
11
|
-
body: 'Internal Server Error'
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
subject { Tinybucket::Error::ServiceError.new(env) }
|
16
|
-
|
17
|
-
it { expect(subject).to be_an_instance_of(Tinybucket::Error::ServiceError) }
|
18
|
-
it { expect(subject.http_method).to eq(env[:method]) }
|
19
|
-
it { expect(subject.request_url).to eq(env[:url]) }
|
20
|
-
it { expect(subject.status_code).to eq(env[:status]) }
|
21
|
-
it { expect(subject.response_body).to eq(env[:body]) }
|
22
|
-
end
|
23
|
-
end
|