tinybucket 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +35 -0
- data/.rspec +1 -0
- data/.rubocop.yml +44 -0
- data/.travis.yml +10 -0
- data/Gemfile +22 -0
- data/Guardfile +13 -0
- data/LICENSE +21 -0
- data/README.md +237 -0
- data/Rakefile +39 -0
- data/lib/faraday_middleware/follow_oauth_redirects.rb +67 -0
- data/lib/tinybucket.rb +61 -0
- data/lib/tinybucket/api.rb +20 -0
- data/lib/tinybucket/api/base_api.rb +31 -0
- data/lib/tinybucket/api/branch_restrictions_api.rb +26 -0
- data/lib/tinybucket/api/comments_api.rb +46 -0
- data/lib/tinybucket/api/commits_api.rb +26 -0
- data/lib/tinybucket/api/diff_api.rb +17 -0
- data/lib/tinybucket/api/helper.rb +22 -0
- data/lib/tinybucket/api/helper/api_helper.rb +48 -0
- data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +27 -0
- data/lib/tinybucket/api/helper/comments_helper.rb +49 -0
- data/lib/tinybucket/api/helper/commits_helper.rb +27 -0
- data/lib/tinybucket/api/helper/diff_helper.rb +29 -0
- data/lib/tinybucket/api/helper/pull_requests_helper.rb +44 -0
- data/lib/tinybucket/api/helper/repo_helper.rb +29 -0
- data/lib/tinybucket/api/helper/repos_helper.rb +21 -0
- data/lib/tinybucket/api/helper/team_helper.rb +35 -0
- data/lib/tinybucket/api/helper/user_helper.rb +31 -0
- data/lib/tinybucket/api/pull_requests_api.rb +49 -0
- data/lib/tinybucket/api/repo_api.rb +35 -0
- data/lib/tinybucket/api/repos_api.rb +19 -0
- data/lib/tinybucket/api/team_api.rb +51 -0
- data/lib/tinybucket/api/user_api.rb +44 -0
- data/lib/tinybucket/api_factory.rb +21 -0
- data/lib/tinybucket/client.rb +95 -0
- data/lib/tinybucket/connection.rb +62 -0
- data/lib/tinybucket/constants.rb +4 -0
- data/lib/tinybucket/error.rb +8 -0
- data/lib/tinybucket/error/base_error.rb +12 -0
- data/lib/tinybucket/error/service_error.rb +20 -0
- data/lib/tinybucket/model.rb +20 -0
- data/lib/tinybucket/model/base.rb +54 -0
- data/lib/tinybucket/model/branch_restriction.rb +17 -0
- data/lib/tinybucket/model/comment.rb +39 -0
- data/lib/tinybucket/model/commit.rb +39 -0
- data/lib/tinybucket/model/concerns.rb +14 -0
- data/lib/tinybucket/model/concerns/reloadable.rb +45 -0
- data/lib/tinybucket/model/concerns/repository_keys.rb +43 -0
- data/lib/tinybucket/model/error_response.rb +7 -0
- data/lib/tinybucket/model/page.rb +65 -0
- data/lib/tinybucket/model/profile.rb +37 -0
- data/lib/tinybucket/model/pull_request.rb +64 -0
- data/lib/tinybucket/model/repository.rb +96 -0
- data/lib/tinybucket/model/team.rb +39 -0
- data/lib/tinybucket/parser.rb +25 -0
- data/lib/tinybucket/parser/base_parser.rb +17 -0
- data/lib/tinybucket/parser/branch_restriction_parser.rb +9 -0
- data/lib/tinybucket/parser/branch_restrictions_parser.rb +10 -0
- data/lib/tinybucket/parser/comment_parser.rb +9 -0
- data/lib/tinybucket/parser/comments_parser.rb +10 -0
- data/lib/tinybucket/parser/commit_parser.rb +9 -0
- data/lib/tinybucket/parser/commits_parser.rb +9 -0
- data/lib/tinybucket/parser/profile_parser.rb +9 -0
- data/lib/tinybucket/parser/profiles_parser.rb +9 -0
- data/lib/tinybucket/parser/pull_request_parser.rb +9 -0
- data/lib/tinybucket/parser/pull_requests_parser.rb +10 -0
- data/lib/tinybucket/parser/repo_parser.rb +9 -0
- data/lib/tinybucket/parser/repos_parser.rb +10 -0
- data/lib/tinybucket/parser/team_parser.rb +9 -0
- data/lib/tinybucket/parser/teams_parser.rb +9 -0
- data/lib/tinybucket/request.rb +55 -0
- data/lib/tinybucket/response.rb +7 -0
- data/lib/tinybucket/response/error_handler.rb +14 -0
- data/lib/tinybucket/version.rb +3 -0
- data/spec/fixtures/commit.json +83 -0
- data/spec/fixtures/profile.json +29 -0
- data/spec/fixtures/pull_request.json +106 -0
- data/spec/fixtures/repositories/get.json +78 -0
- data/spec/fixtures/repositories/test_owner/get.json +78 -0
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/1/get.json +17 -0
- data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/get.json +101 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/1/get.json +38 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/get.json +40 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commit/1/get.json +83 -0
- data/spec/fixtures/repositories/test_owner/test_repo/commits/get.json +73 -0
- data/spec/fixtures/repositories/test_owner/test_repo/diff/1/get.json +21 -0
- data/spec/fixtures/repositories/test_owner/test_repo/forks/get.json +78 -0
- data/spec/fixtures/repositories/test_owner/test_repo/get.json +71 -0
- data/spec/fixtures/repositories/test_owner/test_repo/patch/1/get.json +29 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/delete.json +3 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/post.json +3 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/1/get.json +30 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +44 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +66 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/diff/get.txt +13 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/get.json +164 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +112 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_declined.json +112 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_merged.json +112 -0
- data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_open.json +112 -0
- data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +32 -0
- data/spec/fixtures/repository.json +71 -0
- data/spec/fixtures/teams/test_team/followers/get.json +36 -0
- data/spec/fixtures/teams/test_team/following/get.json +39 -0
- data/spec/fixtures/teams/test_team/get.json +32 -0
- data/spec/fixtures/teams/test_team/members/get.json +36 -0
- data/spec/fixtures/teams/test_team/repositories/get.json +125 -0
- data/spec/fixtures/users/test_owner/followers/get.json +65 -0
- data/spec/fixtures/users/test_owner/following/get.json +100 -0
- data/spec/fixtures/users/test_owner/get.json +29 -0
- data/spec/lib/tinybucket/api/branch_restrictions_api_spec.rb +78 -0
- data/spec/lib/tinybucket/api/comments_api_spec.rb +133 -0
- data/spec/lib/tinybucket/api/commits_api_spec.rb +63 -0
- data/spec/lib/tinybucket/api/diff_api_spec.rb +5 -0
- data/spec/lib/tinybucket/api/pull_requests_api_spec.rb +229 -0
- data/spec/lib/tinybucket/api/repo_api_spec.rb +100 -0
- data/spec/lib/tinybucket/api/repos_api_spec.rb +28 -0
- data/spec/lib/tinybucket/api/team_api_spec.rb +87 -0
- data/spec/lib/tinybucket/api/user_api_spec.rb +60 -0
- data/spec/lib/tinybucket/api_factory_spec.rb +23 -0
- data/spec/lib/tinybucket/client_spec.rb +102 -0
- data/spec/lib/tinybucket/connection_spec.rb +30 -0
- data/spec/lib/tinybucket/model/branch_restriction_spec.rb +29 -0
- data/spec/lib/tinybucket/model/comment_spec.rb +31 -0
- data/spec/lib/tinybucket/model/commit_spec.rb +62 -0
- data/spec/lib/tinybucket/model/page_spec.rb +58 -0
- data/spec/lib/tinybucket/model/profile_spec.rb +47 -0
- data/spec/lib/tinybucket/model/pull_request_spec.rb +122 -0
- data/spec/lib/tinybucket/model/repository_spec.rb +131 -0
- data/spec/lib/tinybucket/model/team_spec.rb +53 -0
- data/spec/lib/tinybucket_spec.rb +32 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/api_response_macros.rb +30 -0
- data/spec/support/model_macros.rb +61 -0
- data/tinybucket.gemspec +36 -0
- metadata +437 -0
@@ -0,0 +1,100 @@
|
|
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_config) { {} }
|
11
|
+
let(:api) do
|
12
|
+
api = Tinybucket::Api::RepoApi.new(api_config)
|
13
|
+
api.repo_owner = repo_owner
|
14
|
+
api.repo_slug = repo_slug
|
15
|
+
api
|
16
|
+
end
|
17
|
+
|
18
|
+
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
19
|
+
|
20
|
+
before { stub_apiresponse(:get, request_path) if request_path }
|
21
|
+
|
22
|
+
describe 'find' do
|
23
|
+
subject { api.find }
|
24
|
+
|
25
|
+
context 'when without repo_owner and repo_slug' do
|
26
|
+
let(:repo_owner) { nil }
|
27
|
+
let(:repo_slug) { nil }
|
28
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when without repo_owner' do
|
32
|
+
let(:repo_owner) { nil }
|
33
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when without repo_slug' do
|
37
|
+
let(:repo_slug) { nil }
|
38
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when with repo_owner and repo_slug' do
|
42
|
+
let(:request_path) { "/repositories/#{repo_owner}/#{repo_slug}" }
|
43
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Repository) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'watchers' do
|
48
|
+
subject { api.watchers }
|
49
|
+
|
50
|
+
context 'when without repo_owner and repo_slug' do
|
51
|
+
let(:repo_owner) { nil }
|
52
|
+
let(:repo_slug) { nil }
|
53
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when without repo_owner' do
|
57
|
+
let(:repo_owner) { nil }
|
58
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when without repo_slug' do
|
62
|
+
let(:repo_slug) { nil }
|
63
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when with repo_owner and repo_slug' do
|
67
|
+
let(:request_path) do
|
68
|
+
"/repositories/#{repo_owner}/#{repo_slug}/watchers"
|
69
|
+
end
|
70
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'forks' do
|
75
|
+
subject { api.forks }
|
76
|
+
|
77
|
+
context 'when without repo_owner and repo_slug' do
|
78
|
+
let(:repo_owner) { nil }
|
79
|
+
let(:repo_slug) { nil }
|
80
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when without repo_owner' do
|
84
|
+
let(:repo_owner) { nil }
|
85
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when without repo_slug' do
|
89
|
+
let(:repo_slug) { nil }
|
90
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when with repo_owner and repo_slug' do
|
94
|
+
let(:request_path) do
|
95
|
+
"/repositories/#{repo_owner}/#{repo_slug}/forks"
|
96
|
+
end
|
97
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::Api::ReposApi do
|
4
|
+
include ApiResponseMacros
|
5
|
+
|
6
|
+
let(:api_config) { {} }
|
7
|
+
let(:api) { Tinybucket::Api::ReposApi.new(api_config) }
|
8
|
+
|
9
|
+
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
10
|
+
|
11
|
+
describe 'list' do
|
12
|
+
subject { api.list(options) }
|
13
|
+
|
14
|
+
before { stub_apiresponse(:get, request_path) }
|
15
|
+
|
16
|
+
context 'without owner' do
|
17
|
+
let(:options) { {} }
|
18
|
+
let(:request_path) { '/repositories' }
|
19
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with owner' do
|
23
|
+
let(:options) { { owner: 'test_owner' } }
|
24
|
+
let(:request_path) { '/repositories/test_owner' }
|
25
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::Api::TeamApi do
|
4
|
+
include ApiResponseMacros
|
5
|
+
|
6
|
+
let(:api_config) { {} }
|
7
|
+
let(:api) do
|
8
|
+
Tinybucket::Api::TeamApi.new(api_config)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:teamname) { 'test_team' }
|
12
|
+
let(:request_path) { nil }
|
13
|
+
before { stub_apiresponse(:get, request_path) if request_path }
|
14
|
+
|
15
|
+
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
16
|
+
|
17
|
+
describe 'profile' do
|
18
|
+
subject { api.find(teamname) }
|
19
|
+
|
20
|
+
context 'when without teamname' do
|
21
|
+
let(:teamname) { nil }
|
22
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when with teamname' do
|
26
|
+
let(:request_path) { "/teams/#{teamname}" }
|
27
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Team) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'members' do
|
32
|
+
subject { api.members(teamname) }
|
33
|
+
|
34
|
+
context 'when without teamname' do
|
35
|
+
let(:teamname) { nil }
|
36
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when with teamname' do
|
40
|
+
let(:request_path) { "/teams/#{teamname}/members" }
|
41
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'followers' do
|
46
|
+
subject { api.followers(teamname) }
|
47
|
+
|
48
|
+
context 'when without teamname' do
|
49
|
+
let(:teamname) { nil }
|
50
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when with teamname' do
|
54
|
+
let(:request_path) { "/teams/#{teamname}/followers" }
|
55
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'following' do
|
60
|
+
subject { api.following(teamname) }
|
61
|
+
|
62
|
+
context 'when without teamname' do
|
63
|
+
let(:teamname) { nil }
|
64
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when with teamname' do
|
68
|
+
let(:request_path) { "/teams/#{teamname}/following" }
|
69
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'repos' do
|
74
|
+
subject { api.repos(teamname) }
|
75
|
+
|
76
|
+
context 'when without teamname' do
|
77
|
+
let(:teamname) { nil }
|
78
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when with teamname' do
|
82
|
+
let(:request_path) { "/teams/#{teamname}/repositories" }
|
83
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::Api::UserApi do
|
4
|
+
include ApiResponseMacros
|
5
|
+
|
6
|
+
let(:api_config) { {} }
|
7
|
+
let(:api) do
|
8
|
+
api = Tinybucket::Api::UserApi.new(api_config)
|
9
|
+
api.username = user
|
10
|
+
api
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:user) { 'test_owner' }
|
14
|
+
let(:request_path) { nil }
|
15
|
+
before { stub_apiresponse(:get, request_path) if request_path }
|
16
|
+
|
17
|
+
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
18
|
+
|
19
|
+
describe 'profile' do
|
20
|
+
subject { api.profile }
|
21
|
+
|
22
|
+
context 'when without username' do
|
23
|
+
let(:user) { nil }
|
24
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when with username' do
|
28
|
+
let(:request_path) { "/users/#{user}" }
|
29
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Profile) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'followers' do
|
34
|
+
subject { api.followers }
|
35
|
+
|
36
|
+
context 'when without username' do
|
37
|
+
let(:user) { nil }
|
38
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when with username' do
|
42
|
+
let(:request_path) { "/users/#{user}/followers" }
|
43
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'following' do
|
48
|
+
subject { api.following }
|
49
|
+
|
50
|
+
context 'when without username' do
|
51
|
+
let(:user) { nil }
|
52
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when with username' do
|
56
|
+
let(:request_path) { "/users/#{user}/following" }
|
57
|
+
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::ApiFactory do
|
4
|
+
|
5
|
+
describe 'create_instance' do
|
6
|
+
let(:klass_name) { 'PullRequests' }
|
7
|
+
let(:config) { {} }
|
8
|
+
let(:options) { {} }
|
9
|
+
|
10
|
+
subject do
|
11
|
+
Tinybucket::ApiFactory.create_instance(klass_name, config, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with valid klass_name' do
|
15
|
+
it { expect(subject).to be_a_kind_of(Tinybucket::Api::BaseApi) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with invalid klass_name' do
|
19
|
+
let(:klass_name) { 'Invalid Klass Name' }
|
20
|
+
it { expect { subject }.to raise_error(ArgumentError) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,102 @@
|
|
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
|
+
let(:options) { {} }
|
10
|
+
|
11
|
+
context 'without block' do
|
12
|
+
subject { Tinybucket::Client.new(options) }
|
13
|
+
it { expect(subject.config).to eq(options) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with block' do
|
17
|
+
subject do
|
18
|
+
Tinybucket::Client.new do |config|
|
19
|
+
options.each_pair do |key, value|
|
20
|
+
config.send("#{key}=", value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
it { expect(subject.config).to eq(options) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'repos' do
|
29
|
+
context 'when get public repositories' do
|
30
|
+
before { stub_apiresponse(:get, '/repositories') }
|
31
|
+
|
32
|
+
context 'without options' do
|
33
|
+
subject { client.repos }
|
34
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Page) }
|
35
|
+
end
|
36
|
+
context 'with options' do
|
37
|
+
subject { client.repos(options) }
|
38
|
+
let(:options) { {} }
|
39
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Page) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when get repositories of the owner' do
|
44
|
+
let(:owner) { 'test_owner' }
|
45
|
+
before { stub_apiresponse(:get, request_path) }
|
46
|
+
|
47
|
+
context 'without options' do
|
48
|
+
let(:request_path) { "/repositories/#{owner}" }
|
49
|
+
subject { client.repos(owner) }
|
50
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Page) }
|
51
|
+
end
|
52
|
+
context 'with options' do
|
53
|
+
let(:request_path) { "/repositories/#{owner}" }
|
54
|
+
subject { client.repos(owner, options) }
|
55
|
+
let(:options) { {} }
|
56
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Page) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when invalid argument passed' do
|
61
|
+
context 'with a integer' do
|
62
|
+
subject { client.repos(20) }
|
63
|
+
it { expect { subject }.to raise_error }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with a string and string' do
|
67
|
+
subject { client.repos('test_owner', 'test_repository') }
|
68
|
+
it { expect { subject }.to raise_error }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with three arguments' do
|
72
|
+
subject { client.repos('a', 'b', 'c') }
|
73
|
+
it { expect { subject }.to raise_error }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'repo' do
|
79
|
+
let(:repo_owner) { 'test_owner' }
|
80
|
+
let(:repo_slug) { 'test_repo' }
|
81
|
+
|
82
|
+
subject { client.repo(repo_owner, repo_slug) }
|
83
|
+
|
84
|
+
it 'return RepoApi instance' do
|
85
|
+
expect(subject).to be_instance_of(Tinybucket::Model::Repository)
|
86
|
+
expect(subject.repo_owner).to eq(repo_owner)
|
87
|
+
expect(subject.repo_slug).to eq(repo_slug)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'team' do
|
92
|
+
let(:team) { 'test_team' }
|
93
|
+
subject { client.team(team) }
|
94
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Team) }
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'user' do
|
98
|
+
let(:user) { 'test_owner' }
|
99
|
+
subject { client.user(user) }
|
100
|
+
it { expect(subject).to be_instance_of(Tinybucket::Model::Profile) }
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Tinybucket::Model::BranchRestriction do
|
4
|
+
include ApiResponseMacros
|
5
|
+
|
6
|
+
let(:owner) { 'test_owner' }
|
7
|
+
let(:slug) { 'test_repo' }
|
8
|
+
|
9
|
+
# TODO: fix model_json
|
10
|
+
let(:model_json) { nil }
|
11
|
+
|
12
|
+
let(:model) do
|
13
|
+
m = Tinybucket::Model::BranchRestriction.new(model_json)
|
14
|
+
m.repo_owner = owner
|
15
|
+
m.repo_slug = slug
|
16
|
+
|
17
|
+
m
|
18
|
+
end
|
19
|
+
|
20
|
+
before { stub_apiresponse(:get, request_path, stub_options) if request_path }
|
21
|
+
|
22
|
+
describe '#update' do
|
23
|
+
pending 'TODO implement method'
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#destroy' do
|
27
|
+
pending 'TODO implement method'
|
28
|
+
end
|
29
|
+
end
|