tinybucket 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -5
  3. data/README.md +100 -24
  4. data/lib/tinybucket.rb +1 -0
  5. data/lib/tinybucket/api.rb +1 -0
  6. data/lib/tinybucket/api/build_status_api.rb +55 -0
  7. data/lib/tinybucket/api/helper.rb +1 -0
  8. data/lib/tinybucket/api/helper/build_status_helper.rb +35 -0
  9. data/lib/tinybucket/client.rb +28 -45
  10. data/lib/tinybucket/enumerator.rb +4 -3
  11. data/lib/tinybucket/model.rb +2 -1
  12. data/lib/tinybucket/model/base.rb +1 -17
  13. data/lib/tinybucket/model/build_status.rb +55 -0
  14. data/lib/tinybucket/model/commit.rb +32 -15
  15. data/lib/tinybucket/model/concerns.rb +1 -0
  16. data/lib/tinybucket/model/concerns/api_callable.rb +19 -0
  17. data/lib/tinybucket/model/profile.rb +9 -26
  18. data/lib/tinybucket/model/pull_request.rb +18 -28
  19. data/lib/tinybucket/model/repository.rb +29 -76
  20. data/lib/tinybucket/model/team.rb +9 -34
  21. data/lib/tinybucket/parser.rb +1 -0
  22. data/lib/tinybucket/parser/build_status_parser.rb +9 -0
  23. data/lib/tinybucket/resource.rb +70 -0
  24. data/lib/tinybucket/resource/base.rb +29 -0
  25. data/lib/tinybucket/resource/branch_restrictions.rb +45 -0
  26. data/lib/tinybucket/resource/commit/base.rb +12 -0
  27. data/lib/tinybucket/resource/commit/build_statuses.rb +47 -0
  28. data/lib/tinybucket/resource/commit/comments.rb +32 -0
  29. data/lib/tinybucket/resource/commits.rb +33 -0
  30. data/lib/tinybucket/resource/forks.rb +22 -0
  31. data/lib/tinybucket/resource/pull_request/base.rb +18 -0
  32. data/lib/tinybucket/resource/pull_request/comments.rb +30 -0
  33. data/lib/tinybucket/resource/pull_request/commits.rb +17 -0
  34. data/lib/tinybucket/resource/pull_requests.rb +48 -0
  35. data/lib/tinybucket/resource/repos.rb +38 -0
  36. data/lib/tinybucket/resource/team/base.rb +22 -0
  37. data/lib/tinybucket/resource/team/followers.rb +13 -0
  38. data/lib/tinybucket/resource/team/following.rb +13 -0
  39. data/lib/tinybucket/resource/team/members.rb +13 -0
  40. data/lib/tinybucket/resource/team/repos.rb +13 -0
  41. data/lib/tinybucket/resource/user/base.rb +24 -0
  42. data/lib/tinybucket/resource/user/followers.rb +13 -0
  43. data/lib/tinybucket/resource/user/following.rb +13 -0
  44. data/lib/tinybucket/resource/user/repos.rb +13 -0
  45. data/lib/tinybucket/resource/watchers.rb +22 -0
  46. data/lib/tinybucket/version.rb +1 -1
  47. data/spec/fixtures/build_status.json +16 -0
  48. data/spec/fixtures/repositories/test_owner/get.json +1 -1
  49. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/post.json +16 -0
  50. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/get.json +16 -0
  51. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/statuses/build/test_status/put.json +16 -0
  52. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +1 -1
  53. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +1 -1
  54. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +1 -1
  55. data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +1 -1
  56. data/spec/lib/tinybucket/api/build_status_api_spec.rb +65 -0
  57. data/spec/lib/tinybucket/client_spec.rb +8 -4
  58. data/spec/lib/tinybucket/model/build_status_spec.rb +66 -0
  59. data/spec/lib/tinybucket/model/commit_spec.rb +19 -1
  60. data/spec/lib/tinybucket/model/profile_spec.rb +3 -3
  61. data/spec/lib/tinybucket/model/pull_request_spec.rb +3 -15
  62. data/spec/lib/tinybucket/model/repository_spec.rb +14 -20
  63. data/spec/lib/tinybucket/model/team_spec.rb +16 -4
  64. data/spec/lib/tinybucket/resource/branch_restrictions_spec.rb +60 -0
  65. data/spec/lib/tinybucket/resource/commit/build_statuses_spec.rb +50 -0
  66. data/spec/lib/tinybucket/resource/commit/comments_spec.rb +49 -0
  67. data/spec/lib/tinybucket/resource/commits_spec.rb +43 -0
  68. data/spec/lib/tinybucket/resource/forks_spec.rb +36 -0
  69. data/spec/lib/tinybucket/resource/pull_request/comments_spec.rb +41 -0
  70. data/spec/lib/tinybucket/resource/pull_request/commits_spec.rb +41 -0
  71. data/spec/lib/tinybucket/resource/pull_requests_spec.rb +59 -0
  72. data/spec/lib/tinybucket/resource/repos_spec.rb +76 -0
  73. data/spec/lib/tinybucket/resource/team/followers_spec.rb +27 -0
  74. data/spec/lib/tinybucket/resource/team/following_spec.rb +27 -0
  75. data/spec/lib/tinybucket/resource/team/members_spec.rb +27 -0
  76. data/spec/lib/tinybucket/resource/team/repos_spec.rb +27 -0
  77. data/spec/lib/tinybucket/resource/user/followers_spec.rb +27 -0
  78. data/spec/lib/tinybucket/resource/user/following_spec.rb +27 -0
  79. data/spec/lib/tinybucket/resource/user/repos_spec.rb +27 -0
  80. data/spec/lib/tinybucket/resource/watchers_spec.rb +38 -0
  81. data/spec/support/api_response_macros.rb +45 -1
  82. metadata +77 -3
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Commits do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:slug) { 'test_repo' }
8
+ let(:repo) do
9
+ Tinybucket::Model::Repository.new({}).tap do |m|
10
+ m.repo_owner = owner
11
+ m.repo_slug = slug
12
+ end
13
+ end
14
+
15
+ let(:options) { {} }
16
+ let(:resource) { Tinybucket::Resource::Commits.new(repo, options) }
17
+
18
+ describe '#find' do
19
+ let(:revision) { '1' }
20
+ let(:request_path) { "/repositories/#{owner}/#{slug}/commit/#{revision}" }
21
+ before { stub_apiresponse(:get, request_path) }
22
+ subject { resource.find(revision) }
23
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Commit) }
24
+ end
25
+
26
+ describe 'Enumerable Methods' do
27
+ let(:request_path) { "/repositories/#{owner}/#{slug}/commits" }
28
+ before { stub_enum_response(:get, request_path) }
29
+
30
+ describe '#take(1)' do
31
+ subject { resource.take(1) }
32
+ it { expect(subject).to be_an_instance_of(Array) }
33
+ end
34
+
35
+ describe '#each' do
36
+ it 'iterate models' do
37
+ resource.each do |m|
38
+ expect(m).to be_an_instance_of(Tinybucket::Model::Commit)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Forks do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:slug) { 'test_repo' }
8
+
9
+ let(:options) { {} }
10
+ let(:repo) do
11
+ Tinybucket::Model::Repository.new({}).tap do |m|
12
+ m.repo_owner = owner
13
+ m.repo_slug = slug
14
+ end
15
+ end
16
+
17
+ let(:resource) { Tinybucket::Resource::Forks.new(repo, options) }
18
+
19
+ describe 'Enumerable Methods' do
20
+ let(:request_path) { "/repositories/#{owner}/#{slug}/forks" }
21
+ before { stub_enum_response(:get, request_path) }
22
+
23
+ describe '#take(1)' do
24
+ subject { resource.take(1) }
25
+ it { expect(subject).to be_an_instance_of(Array) }
26
+ end
27
+
28
+ describe '#each' do
29
+ it 'iterate models' do
30
+ resource.each do |m|
31
+ expect(m).to be_an_instance_of(Tinybucket::Model::Repository)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::PullRequest::Comments do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:slug) { 'test_repo' }
8
+ let(:pullrequest_id) { '1' }
9
+ let(:pull_request) do
10
+ Tinybucket::Model::PullRequest.new({}).tap do |m|
11
+ m.id = pullrequest_id
12
+ m.repo_owner = owner
13
+ m.repo_slug = slug
14
+ end
15
+ end
16
+
17
+ let(:options) { {} }
18
+ let(:resource) do
19
+ Tinybucket::Resource::PullRequest::Comments.new(pull_request, options)
20
+ end
21
+
22
+ describe 'Enumerable Methods' do
23
+ let(:request_path) do
24
+ "/repositories/#{owner}/#{slug}/pullrequests/#{pullrequest_id}/comments"
25
+ end
26
+ before { stub_enum_response(:get, request_path) }
27
+
28
+ describe '#take(1)' do
29
+ subject { resource.take(1) }
30
+ it { expect(subject).to be_an_instance_of(Array) }
31
+ end
32
+
33
+ describe '#each' do
34
+ it 'iterate models' do
35
+ resource.each do |m|
36
+ expect(m).to be_an_instance_of(Tinybucket::Model::Comment)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::PullRequest::Commits do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:slug) { 'test_repo' }
8
+ let(:pullrequest_id) { '1' }
9
+ let(:pull_request) do
10
+ Tinybucket::Model::PullRequest.new({}).tap do |m|
11
+ m.id = pullrequest_id
12
+ m.repo_owner = owner
13
+ m.repo_slug = slug
14
+ end
15
+ end
16
+
17
+ let(:options) { {} }
18
+ let(:resource) do
19
+ Tinybucket::Resource::PullRequest::Commits.new(pull_request, options)
20
+ end
21
+
22
+ describe 'Enumerable Methods' do
23
+ let(:request_path) do
24
+ "/repositories/#{owner}/#{slug}/pullrequests/#{pullrequest_id}/commits"
25
+ end
26
+ before { stub_enum_response(:get, request_path) }
27
+
28
+ describe '#take(1)' do
29
+ subject { resource.take(1) }
30
+ it { expect(subject).to be_an_instance_of(Array) }
31
+ end
32
+
33
+ describe '#each' do
34
+ it 'iterate models' do
35
+ resource.each do |m|
36
+ expect(m).to be_an_instance_of(Tinybucket::Model::Commit)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::PullRequests do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:slug) { 'test_repo' }
8
+ let(:repo) do
9
+ Tinybucket::Model::Repository.new({}).tap do |m|
10
+ m.repo_owner = owner
11
+ m.repo_slug = slug
12
+ end
13
+ end
14
+
15
+ let(:options) { {} }
16
+ let(:resource) { Tinybucket::Resource::PullRequests.new(repo, options) }
17
+
18
+ describe '#create' do
19
+ let(:params) { {} }
20
+ subject { resource.create(params) }
21
+ it { expect { subject }.to raise_error(NotImplementedError) }
22
+ end
23
+
24
+ describe '#find' do
25
+ let(:pullrequest_id) { '1' }
26
+ let(:request_path) do
27
+ "/repositories/#{owner}/#{slug}/pullrequests/#{pullrequest_id}"
28
+ end
29
+ before { stub_apiresponse(:get, request_path) }
30
+ subject { resource.find(pullrequest_id) }
31
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::PullRequest) }
32
+ end
33
+
34
+ describe '#activities' do
35
+ let(:params) { {} }
36
+ subject { resource.activities(params) }
37
+ it { expect { subject }.to raise_error(NotImplementedError) }
38
+ end
39
+
40
+ describe 'Enumerable Methods' do
41
+ let(:request_path) do
42
+ "/repositories/#{owner}/#{slug}/pullrequests"
43
+ end
44
+ before { stub_enum_response(:get, request_path) }
45
+
46
+ describe '#take(1)' do
47
+ subject { resource.take(1) }
48
+ it { expect(subject).to be_an_instance_of(Array) }
49
+ end
50
+
51
+ describe '#each' do
52
+ it 'iterate models' do
53
+ resource.each do |m|
54
+ expect(m).to be_an_instance_of(Tinybucket::Model::PullRequest)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Repos do
4
+ include ApiResponseMacros
5
+
6
+ let(:options) { {} }
7
+ let(:resource) { Tinybucket::Resource::Repos.new(owner, options) }
8
+
9
+ describe 'Public Repos Resource' do
10
+ let(:owner) { nil }
11
+
12
+ describe '#create' do
13
+ let(:params) { {} }
14
+ subject { resource.create(params) }
15
+ it { expect { subject }.to raise_error(NotImplementedError) }
16
+ end
17
+
18
+ describe '#find' do
19
+ let(:params) { {} }
20
+ subject { resource.find(params) }
21
+ it { expect { subject }.to raise_error(NotImplementedError) }
22
+ end
23
+
24
+ describe 'Enumerable Methods' do
25
+ let(:request_path) { '/repositories' }
26
+ before { stub_enum_response(:get, request_path) }
27
+
28
+ describe '#take(1)' do
29
+ subject { resource.take(1) }
30
+ it { expect(subject).to be_an_instance_of(Array) }
31
+ end
32
+
33
+ describe '#each' do
34
+ it 'iterate models' do
35
+ resource.each do |m|
36
+ expect(m).to be_an_instance_of(Tinybucket::Model::Repository)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ describe 'Owner\'s Repos Resource' do
44
+ let(:owner) { 'test_owner' }
45
+
46
+ describe '#create' do
47
+ let(:params) { {} }
48
+ subject { resource.create(params) }
49
+ it { expect { subject }.to raise_error(NotImplementedError) }
50
+ end
51
+
52
+ describe '#find' do
53
+ let(:params) { {} }
54
+ subject { resource.find(params) }
55
+ it { expect { subject }.to raise_error(NotImplementedError) }
56
+ end
57
+
58
+ describe 'Enumerable Methods' do
59
+ let(:request_path) { "/repositories/#{owner}" }
60
+ before { stub_enum_response(:get, request_path) }
61
+
62
+ describe '#take(1)' do
63
+ subject { resource.take(1) }
64
+ it { expect(subject).to be_an_instance_of(Array) }
65
+ end
66
+
67
+ describe '#each' do
68
+ it 'iterate models' do
69
+ resource.each do |m|
70
+ expect(m).to be_an_instance_of(Tinybucket::Model::Repository)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Team::Followers do
4
+ include ApiResponseMacros
5
+
6
+ let(:team) { 'test_team' }
7
+ let(:options) { {} }
8
+ let(:resource) { Tinybucket::Resource::Team::Followers.new(team, options) }
9
+
10
+ describe 'Enumerable Methods' do
11
+ let(:request_path) { "/teams/#{team}/followers" }
12
+ before { stub_enum_response(:get, request_path) }
13
+
14
+ describe '#take(1)' do
15
+ subject { resource.take(1) }
16
+ it { expect(subject).to be_an_instance_of(Array) }
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'iterate models' do
21
+ resource.each do |m|
22
+ expect(m).to be_an_instance_of(Tinybucket::Model::Team)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Team::Following do
4
+ include ApiResponseMacros
5
+
6
+ let(:team) { 'test_team' }
7
+ let(:options) { {} }
8
+ let(:resource) { Tinybucket::Resource::Team::Following.new(team, options) }
9
+
10
+ describe 'Enumerable Methods' do
11
+ let(:request_path) { "/teams/#{team}/following" }
12
+ before { stub_enum_response(:get, request_path) }
13
+
14
+ describe '#take(1)' do
15
+ subject { resource.take(1) }
16
+ it { expect(subject).to be_an_instance_of(Array) }
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'iterate models' do
21
+ resource.each do |m|
22
+ expect(m).to be_an_instance_of(Tinybucket::Model::Team)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::Team::Members do
4
+ include ApiResponseMacros
5
+
6
+ let(:team) { 'test_team' }
7
+ let(:options) { {} }
8
+ let(:resource) { Tinybucket::Resource::Team::Members.new(team, options) }
9
+
10
+ describe 'Enumerable Methods' do
11
+ let(:request_path) { "/teams/#{team}/members" }
12
+ before { stub_enum_response(:get, request_path) }
13
+
14
+ describe '#take(1)' do
15
+ subject { resource.take(1) }
16
+ it { expect(subject).to be_an_instance_of(Array) }
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'iterate models' do
21
+ resource.each do |m|
22
+ expect(m).to be_an_instance_of(Tinybucket::Model::Team)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::User::Repos do
4
+ include ApiResponseMacros
5
+
6
+ let(:team) { 'test_team' }
7
+ let(:options) { {} }
8
+ let(:resource) { Tinybucket::Resource::Team::Repos.new(team, options) }
9
+
10
+ describe 'Enumerable Methods' do
11
+ let(:request_path) { "/teams/#{team}/repositories" }
12
+ before { stub_enum_response(:get, request_path) }
13
+
14
+ describe '#take(1)' do
15
+ subject { resource.take(1) }
16
+ it { expect(subject).to be_an_instance_of(Array) }
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'iterate models' do
21
+ resource.each do |m|
22
+ expect(m).to be_an_instance_of(Tinybucket::Model::Repository)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Resource::User::Followers do
4
+ include ApiResponseMacros
5
+
6
+ let(:owner) { 'test_owner' }
7
+ let(:options) { {} }
8
+ let(:resource) { Tinybucket::Resource::User::Followers.new(owner, options) }
9
+
10
+ describe 'Enumerable Methods' do
11
+ let(:request_path) { "/users/#{owner}/followers" }
12
+ before { stub_enum_response(:get, request_path) }
13
+
14
+ describe '#take(1)' do
15
+ subject { resource.take(1) }
16
+ it { expect(subject).to be_an_instance_of(Array) }
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'iterate models' do
21
+ resource.each do |m|
22
+ expect(m).to be_an_instance_of(Tinybucket::Model::Profile)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end