tinybucket 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +35 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +44 -0
  6. data/.travis.yml +10 -0
  7. data/Gemfile +22 -0
  8. data/Guardfile +13 -0
  9. data/LICENSE +21 -0
  10. data/README.md +237 -0
  11. data/Rakefile +39 -0
  12. data/lib/faraday_middleware/follow_oauth_redirects.rb +67 -0
  13. data/lib/tinybucket.rb +61 -0
  14. data/lib/tinybucket/api.rb +20 -0
  15. data/lib/tinybucket/api/base_api.rb +31 -0
  16. data/lib/tinybucket/api/branch_restrictions_api.rb +26 -0
  17. data/lib/tinybucket/api/comments_api.rb +46 -0
  18. data/lib/tinybucket/api/commits_api.rb +26 -0
  19. data/lib/tinybucket/api/diff_api.rb +17 -0
  20. data/lib/tinybucket/api/helper.rb +22 -0
  21. data/lib/tinybucket/api/helper/api_helper.rb +48 -0
  22. data/lib/tinybucket/api/helper/branch_restrictions_helper.rb +27 -0
  23. data/lib/tinybucket/api/helper/comments_helper.rb +49 -0
  24. data/lib/tinybucket/api/helper/commits_helper.rb +27 -0
  25. data/lib/tinybucket/api/helper/diff_helper.rb +29 -0
  26. data/lib/tinybucket/api/helper/pull_requests_helper.rb +44 -0
  27. data/lib/tinybucket/api/helper/repo_helper.rb +29 -0
  28. data/lib/tinybucket/api/helper/repos_helper.rb +21 -0
  29. data/lib/tinybucket/api/helper/team_helper.rb +35 -0
  30. data/lib/tinybucket/api/helper/user_helper.rb +31 -0
  31. data/lib/tinybucket/api/pull_requests_api.rb +49 -0
  32. data/lib/tinybucket/api/repo_api.rb +35 -0
  33. data/lib/tinybucket/api/repos_api.rb +19 -0
  34. data/lib/tinybucket/api/team_api.rb +51 -0
  35. data/lib/tinybucket/api/user_api.rb +44 -0
  36. data/lib/tinybucket/api_factory.rb +21 -0
  37. data/lib/tinybucket/client.rb +95 -0
  38. data/lib/tinybucket/connection.rb +62 -0
  39. data/lib/tinybucket/constants.rb +4 -0
  40. data/lib/tinybucket/error.rb +8 -0
  41. data/lib/tinybucket/error/base_error.rb +12 -0
  42. data/lib/tinybucket/error/service_error.rb +20 -0
  43. data/lib/tinybucket/model.rb +20 -0
  44. data/lib/tinybucket/model/base.rb +54 -0
  45. data/lib/tinybucket/model/branch_restriction.rb +17 -0
  46. data/lib/tinybucket/model/comment.rb +39 -0
  47. data/lib/tinybucket/model/commit.rb +39 -0
  48. data/lib/tinybucket/model/concerns.rb +14 -0
  49. data/lib/tinybucket/model/concerns/reloadable.rb +45 -0
  50. data/lib/tinybucket/model/concerns/repository_keys.rb +43 -0
  51. data/lib/tinybucket/model/error_response.rb +7 -0
  52. data/lib/tinybucket/model/page.rb +65 -0
  53. data/lib/tinybucket/model/profile.rb +37 -0
  54. data/lib/tinybucket/model/pull_request.rb +64 -0
  55. data/lib/tinybucket/model/repository.rb +96 -0
  56. data/lib/tinybucket/model/team.rb +39 -0
  57. data/lib/tinybucket/parser.rb +25 -0
  58. data/lib/tinybucket/parser/base_parser.rb +17 -0
  59. data/lib/tinybucket/parser/branch_restriction_parser.rb +9 -0
  60. data/lib/tinybucket/parser/branch_restrictions_parser.rb +10 -0
  61. data/lib/tinybucket/parser/comment_parser.rb +9 -0
  62. data/lib/tinybucket/parser/comments_parser.rb +10 -0
  63. data/lib/tinybucket/parser/commit_parser.rb +9 -0
  64. data/lib/tinybucket/parser/commits_parser.rb +9 -0
  65. data/lib/tinybucket/parser/profile_parser.rb +9 -0
  66. data/lib/tinybucket/parser/profiles_parser.rb +9 -0
  67. data/lib/tinybucket/parser/pull_request_parser.rb +9 -0
  68. data/lib/tinybucket/parser/pull_requests_parser.rb +10 -0
  69. data/lib/tinybucket/parser/repo_parser.rb +9 -0
  70. data/lib/tinybucket/parser/repos_parser.rb +10 -0
  71. data/lib/tinybucket/parser/team_parser.rb +9 -0
  72. data/lib/tinybucket/parser/teams_parser.rb +9 -0
  73. data/lib/tinybucket/request.rb +55 -0
  74. data/lib/tinybucket/response.rb +7 -0
  75. data/lib/tinybucket/response/error_handler.rb +14 -0
  76. data/lib/tinybucket/version.rb +3 -0
  77. data/spec/fixtures/commit.json +83 -0
  78. data/spec/fixtures/profile.json +29 -0
  79. data/spec/fixtures/pull_request.json +106 -0
  80. data/spec/fixtures/repositories/get.json +78 -0
  81. data/spec/fixtures/repositories/test_owner/get.json +78 -0
  82. data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/1/get.json +17 -0
  83. data/spec/fixtures/repositories/test_owner/test_repo/branch-restrictions/get.json +101 -0
  84. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/1/get.json +38 -0
  85. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/comments/get.json +40 -0
  86. data/spec/fixtures/repositories/test_owner/test_repo/commit/1/get.json +83 -0
  87. data/spec/fixtures/repositories/test_owner/test_repo/commits/get.json +73 -0
  88. data/spec/fixtures/repositories/test_owner/test_repo/diff/1/get.json +21 -0
  89. data/spec/fixtures/repositories/test_owner/test_repo/forks/get.json +78 -0
  90. data/spec/fixtures/repositories/test_owner/test_repo/get.json +71 -0
  91. data/spec/fixtures/repositories/test_owner/test_repo/patch/1/get.json +29 -0
  92. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/delete.json +3 -0
  93. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/approve/post.json +3 -0
  94. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/1/get.json +30 -0
  95. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/comments/get.json +44 -0
  96. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/commits/get.json +66 -0
  97. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/diff/get.txt +13 -0
  98. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/1/get.json +164 -0
  99. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get.json +112 -0
  100. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_declined.json +112 -0
  101. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_merged.json +112 -0
  102. data/spec/fixtures/repositories/test_owner/test_repo/pullrequests/get_state_open.json +112 -0
  103. data/spec/fixtures/repositories/test_owner/test_repo/watchers/get.json +32 -0
  104. data/spec/fixtures/repository.json +71 -0
  105. data/spec/fixtures/teams/test_team/followers/get.json +36 -0
  106. data/spec/fixtures/teams/test_team/following/get.json +39 -0
  107. data/spec/fixtures/teams/test_team/get.json +32 -0
  108. data/spec/fixtures/teams/test_team/members/get.json +36 -0
  109. data/spec/fixtures/teams/test_team/repositories/get.json +125 -0
  110. data/spec/fixtures/users/test_owner/followers/get.json +65 -0
  111. data/spec/fixtures/users/test_owner/following/get.json +100 -0
  112. data/spec/fixtures/users/test_owner/get.json +29 -0
  113. data/spec/lib/tinybucket/api/branch_restrictions_api_spec.rb +78 -0
  114. data/spec/lib/tinybucket/api/comments_api_spec.rb +133 -0
  115. data/spec/lib/tinybucket/api/commits_api_spec.rb +63 -0
  116. data/spec/lib/tinybucket/api/diff_api_spec.rb +5 -0
  117. data/spec/lib/tinybucket/api/pull_requests_api_spec.rb +229 -0
  118. data/spec/lib/tinybucket/api/repo_api_spec.rb +100 -0
  119. data/spec/lib/tinybucket/api/repos_api_spec.rb +28 -0
  120. data/spec/lib/tinybucket/api/team_api_spec.rb +87 -0
  121. data/spec/lib/tinybucket/api/user_api_spec.rb +60 -0
  122. data/spec/lib/tinybucket/api_factory_spec.rb +23 -0
  123. data/spec/lib/tinybucket/client_spec.rb +102 -0
  124. data/spec/lib/tinybucket/connection_spec.rb +30 -0
  125. data/spec/lib/tinybucket/model/branch_restriction_spec.rb +29 -0
  126. data/spec/lib/tinybucket/model/comment_spec.rb +31 -0
  127. data/spec/lib/tinybucket/model/commit_spec.rb +62 -0
  128. data/spec/lib/tinybucket/model/page_spec.rb +58 -0
  129. data/spec/lib/tinybucket/model/profile_spec.rb +47 -0
  130. data/spec/lib/tinybucket/model/pull_request_spec.rb +122 -0
  131. data/spec/lib/tinybucket/model/repository_spec.rb +131 -0
  132. data/spec/lib/tinybucket/model/team_spec.rb +53 -0
  133. data/spec/lib/tinybucket_spec.rb +32 -0
  134. data/spec/spec_helper.rb +42 -0
  135. data/spec/support/api_response_macros.rb +30 -0
  136. data/spec/support/model_macros.rb +61 -0
  137. data/tinybucket.gemspec +36 -0
  138. metadata +437 -0
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::Comment do
4
+ include ApiResponseMacros
5
+ include ModelMacros
6
+
7
+ let(:owner) { 'test_owner' }
8
+ let(:slug) { 'test_repo' }
9
+
10
+ let(:commit) do
11
+ m = Tinybucket::Model::Commit.new({})
12
+ m.repo_owner = owner
13
+ m.repo_slug = slug
14
+ m.hash = '1'
15
+ m
16
+ end
17
+
18
+ describe 'model can reloadable' do
19
+ let(:comment) do
20
+ m = Tinybucket::Model::Comment.new({})
21
+ m.repo_owner = owner
22
+ m.repo_slug = slug
23
+ m.commented_to = commit
24
+ m.id = '1'
25
+ m
26
+ end
27
+
28
+ before { @model = commit }
29
+ it_behaves_like 'the model is reloadable'
30
+ end
31
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::Commit do
4
+ include ApiResponseMacros
5
+ include ModelMacros
6
+
7
+ let(:owner) { 'test_owner' }
8
+ let(:slug) { 'test_repo' }
9
+
10
+ let(:model) do
11
+ json = JSON.load(File.read('spec/fixtures/commit.json'))
12
+ m = Tinybucket::Model::Commit.new(json)
13
+ m.repo_owner = owner
14
+ m.repo_slug = slug
15
+ m.hash = '1'
16
+
17
+ m
18
+ end
19
+
20
+ let(:request_path) { nil }
21
+
22
+ before { stub_apiresponse(:get, request_path) if request_path }
23
+
24
+ describe 'model can reloadable' do
25
+ let(:commit) do
26
+ m = Tinybucket::Model::Commit.new({})
27
+ m.repo_owner = owner
28
+ m.repo_slug = slug
29
+ m.hash = '1'
30
+ m
31
+ end
32
+ before { @model = commit }
33
+ it_behaves_like 'the model is reloadable'
34
+ end
35
+
36
+ describe '#comments' do
37
+ let(:request_path) do
38
+ "/repositories/#{owner}/#{slug}/commit/1/comments"
39
+ end
40
+ subject { model.comments }
41
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
42
+ end
43
+
44
+ describe '#comment' do
45
+ let(:comment_id) { '1' }
46
+ let(:request_path) do
47
+ "/repositories/#{owner}/#{slug}/commit/1/comments/#{comment_id}"
48
+ end
49
+ subject { model.comment(comment_id) }
50
+ it 'return Comment' do
51
+ expect(subject).to be_an_instance_of(Tinybucket::Model::Comment)
52
+ end
53
+ end
54
+
55
+ describe '#approve' do
56
+ pending 'TODO implement method'
57
+ end
58
+
59
+ describe '#unapprove' do
60
+ pending 'TODO implement method'
61
+ end
62
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::Page do
4
+
5
+ let(:json) do
6
+ text = File.read('spec/fixtures/repositories/get.json')
7
+ JSON.parse(text)
8
+ end
9
+
10
+ let(:klass) { Tinybucket::Model::Repository }
11
+ let(:model) { Tinybucket::Model::Page.new(json, klass) }
12
+
13
+ describe 'initialize' do
14
+ subject { model }
15
+
16
+ it 'create instance' do
17
+ expect(subject).to be_an_instance_of(Tinybucket::Model::Page)
18
+
19
+ expect(subject.attrs[:size]).to eq(json['size'])
20
+ expect(subject.attrs[:page]).to eq(json['page'])
21
+ expect(subject.attrs[:pagelen]).to eq(json['pagelen'])
22
+ expect(subject.attrs[:next]).to eq(json['next'])
23
+ expect(subject.attrs[:previous]).to eq(json['previous'])
24
+
25
+ expect(subject.items.size).to eq(json['values'].size)
26
+ end
27
+ end
28
+
29
+ describe 'size' do
30
+ subject { model.size }
31
+
32
+ let(:base_json) do
33
+ text = File.read('spec/fixtures/repositories/get.json')
34
+ JSON.parse(text)
35
+ end
36
+
37
+ context 'when json contains size = nil' do
38
+ let(:json) do
39
+ base_json['size'] = nil
40
+ base_json
41
+ end
42
+ it { expect(subject).to be_nil }
43
+ end
44
+
45
+ context 'when json contains size' do
46
+ let(:size) { 1000 }
47
+ let(:json) do
48
+ base_json['size'] = size
49
+ base_json
50
+ end
51
+ it { expect(subject).to eq(size) }
52
+ end
53
+ end
54
+
55
+ describe 'each' do
56
+ pending 'TODO add specs'
57
+ end
58
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::Profile do
4
+ include ApiResponseMacros
5
+ include ModelMacros
6
+
7
+ let(:username) { 'test_owner' }
8
+
9
+ let(:model_json) { JSON.load(File.read('spec/fixtures/profile.json')) }
10
+ let(:model) do
11
+ m = Tinybucket::Model::Profile.new(model_json)
12
+ m.username = username
13
+ m
14
+ end
15
+
16
+ let(:request_path) { nil }
17
+
18
+ before { stub_apiresponse(:get, request_path) if request_path }
19
+
20
+ describe 'model can reloadable' do
21
+ let(:profile) do
22
+ m = Tinybucket::Model::Profile.new({})
23
+ m.username = username
24
+ m
25
+ end
26
+ before { @model = profile }
27
+ it_behaves_like 'the model is reloadable'
28
+ end
29
+
30
+ describe 'followers' do
31
+ let(:request_path) { "/users/#{username}/followers" }
32
+ subject { model.followers() }
33
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
34
+ end
35
+
36
+ describe 'following' do
37
+ let(:request_path) { "/users/#{username}/following" }
38
+ subject { model.following }
39
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
40
+ end
41
+
42
+ describe 'repos' do
43
+ let(:request_path) { "/repositories/#{username}" }
44
+ subject { model.repos }
45
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
46
+ end
47
+ end
@@ -0,0 +1,122 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::PullRequest do
4
+ include ApiResponseMacros
5
+ include ModelMacros
6
+
7
+ let(:model_json) { JSON.load(File.read('spec/fixtures/pull_request.json')) }
8
+
9
+ let(:request_method) { :get }
10
+ let(:request_path) { nil }
11
+
12
+ let(:owner) { 'test_owner' }
13
+ let(:slug) { 'test_repo' }
14
+
15
+ let(:model) do
16
+ pr = Tinybucket::Model::PullRequest.new(model_json)
17
+ pr.repo_owner = owner
18
+ pr.repo_slug = slug
19
+ pr.id = 1
20
+
21
+ pr
22
+ end
23
+
24
+ let(:stub_options) { nil }
25
+
26
+ before do
27
+ if request_path
28
+ opts = stub_options.present? ? stub_options : {}
29
+ stub_apiresponse(request_method, request_path, opts)
30
+ end
31
+ end
32
+
33
+ describe 'model can reloadable' do
34
+ let(:pr) do
35
+ m = Tinybucket::Model::PullRequest.new({})
36
+ m.repo_owner = owner
37
+ m.repo_slug = slug
38
+ m.id = 1
39
+ m
40
+ end
41
+ before { @model = pr }
42
+ it_behaves_like 'the model is reloadable'
43
+ end
44
+
45
+ describe '#create' do
46
+ pending 'TODO implement method'
47
+ end
48
+
49
+ describe '#update' do
50
+ pending 'TODO implement method'
51
+ end
52
+
53
+ describe 'approve' do
54
+ let(:request_method) { :post }
55
+ let(:request_path) do
56
+ "/repositories/#{owner}/#{slug}/pullrequests/1/approve"
57
+ end
58
+
59
+ subject { model.approve }
60
+
61
+ it { expect(subject).to be_truthy }
62
+ end
63
+
64
+ describe 'unapprove' do
65
+ let(:request_method) { :delete }
66
+ let(:request_path) do
67
+ "/repositories/#{owner}/#{slug}/pullrequests/1/approve"
68
+ end
69
+
70
+ subject { model.unapprove }
71
+
72
+ it { expect(subject).to be_truthy }
73
+ end
74
+
75
+ describe 'commits' do
76
+ let(:request_path) do
77
+ "/repositories/#{owner}/#{slug}/pullrequests/1/commits"
78
+ end
79
+
80
+ subject { model.commits() }
81
+
82
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
83
+ end
84
+
85
+ describe 'comments' do
86
+ let(:request_path) do
87
+ "/repositories/#{owner}/#{slug}/pullrequests/1/comments"
88
+ end
89
+
90
+ subject { model.comments }
91
+
92
+ it 'return comment list' do
93
+ expect(subject).to be_an_instance_of(Tinybucket::Model::Page)
94
+ subject.items.each do |comment|
95
+ expect(comment.commented_to).to eq(model)
96
+ end
97
+ end
98
+ end
99
+
100
+ describe 'comment' do
101
+ let(:comment_id) { '1' }
102
+ let(:request_path) do
103
+ "/repositories/#{owner}/#{slug}/pullrequests/1/comments/#{comment_id}"
104
+ end
105
+ subject { model.comment(comment_id) }
106
+
107
+ it 'return the comment' do
108
+ expect(subject).to be_an_instance_of(Tinybucket::Model::Comment)
109
+ expect(subject.commented_to).to eq(model)
110
+ end
111
+ end
112
+
113
+ describe 'diff' do
114
+ let(:stub_options) { { content_type: 'plain/text' } }
115
+ subject { model.diff }
116
+ let(:request_path) do
117
+ "/repositories/#{owner}/#{slug}/pullrequests/1/diff"
118
+ end
119
+ it { expect(subject).to be_instance_of(String) }
120
+
121
+ end
122
+ end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Tinybucket::Model::Repository do
4
+ include ApiResponseMacros
5
+ include ModelMacros
6
+
7
+ let(:owner) { 'test_owner' }
8
+ let(:slug) { 'test_repo' }
9
+
10
+ let(:model_json) { JSON.load(File.read('spec/fixtures/repository.json')) }
11
+ let(:model) do
12
+ m = Tinybucket::Model::Repository.new(model_json)
13
+ m.repo_owner = owner
14
+ m.repo_slug = slug
15
+
16
+ m
17
+ end
18
+ let(:request_path) { nil }
19
+ let(:stub_options) { {} }
20
+
21
+ before { stub_apiresponse(:get, request_path, stub_options) if request_path }
22
+
23
+ describe 'model can reloadable' do
24
+ let(:repo) do
25
+ m = Tinybucket::Model::Repository.new({})
26
+ m.repo_owner = owner
27
+ m.repo_slug = slug
28
+ m
29
+ end
30
+ before { @model = repo }
31
+ it_behaves_like 'the model is reloadable'
32
+ end
33
+
34
+ describe '#create' do
35
+ pending 'TODO implement method'
36
+ end
37
+
38
+ describe '#destroy' do
39
+ pending 'TODO implement method'
40
+ end
41
+
42
+ describe '#pull_requests' do
43
+ let(:request_path) do
44
+ "/repositories/#{owner}/#{slug}/pullrequests"
45
+ end
46
+
47
+ subject { model.pull_requests() }
48
+
49
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
50
+ end
51
+
52
+ describe '#pull_request' do
53
+ let(:prid) { 1 }
54
+
55
+ describe 'with pull_request_id' do
56
+ subject { model.pull_request(prid) }
57
+ let(:request_path) do
58
+ "/repositories/#{owner}/#{slug}/pullrequests/#{prid}"
59
+ end
60
+ it 'return the specific pull_request model' do
61
+ expect(subject).to be_an_instance_of(Tinybucket::Model::PullRequest)
62
+ expect(subject.id).to eq(prid)
63
+ end
64
+ end
65
+ describe 'without pull_request_id' do
66
+ subject { model.pull_request }
67
+ it 'return new pull_request model' do
68
+ expect(subject).to be_an_instance_of(Tinybucket::Model::PullRequest)
69
+ expect(subject.id).to be_nil
70
+ end
71
+ end
72
+ end
73
+
74
+ describe '#watchers' do
75
+ let(:request_path) { "/repositories/#{owner}/#{slug}/watchers" }
76
+ subject { model.watchers }
77
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
78
+ end
79
+
80
+ describe '#forks' do
81
+ let(:request_path) { "/repositories/#{owner}/#{slug}/forks" }
82
+ subject { model.forks }
83
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
84
+ end
85
+
86
+ describe '#commits' do
87
+ let(:request_path) { "/repositories/#{owner}/#{slug}/commits" }
88
+ subject { model.commits }
89
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
90
+ end
91
+
92
+ describe '#commit' do
93
+ let(:revision) { '1' }
94
+ let(:request_path) { "/repositories/#{owner}/#{slug}/commit/#{revision}" }
95
+ subject { model.commit(revision) }
96
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Commit) }
97
+ end
98
+
99
+ describe '#branch_restrictions' do
100
+ let(:request_path) { "/repositories/#{owner}/#{slug}/branch-restrictions" }
101
+ subject { model.branch_restrictions }
102
+ it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) }
103
+ end
104
+
105
+ describe '#branch_restriction' do
106
+ let(:restriction_id) { '1' }
107
+ let(:request_path) do
108
+ "/repositories/#{owner}/#{slug}/branch-restrictions/#{restriction_id}"
109
+ end
110
+ subject { model.branch_restriction(restriction_id) }
111
+ it 'return BranchRestriction model' do
112
+ expect(subject).to be_an_instance_of(Tinybucket::Model::BranchRestriction)
113
+ end
114
+ end
115
+
116
+ describe '#diff' do
117
+ let(:diff_spec) { '1' }
118
+ let(:request_path) { "/repositories/#{owner}/#{slug}/diff/#{diff_spec}" }
119
+ let(:stub_options) { { content_type: 'text/plain' } }
120
+ subject { model.diff(diff_spec) }
121
+ it { expect(subject).to be_an_instance_of(String) }
122
+ end
123
+
124
+ describe '#patch' do
125
+ let(:patch_spec) { '1' }
126
+ let(:request_path) { "/repositories/#{owner}/#{slug}/patch/#{patch_spec}" }
127
+ let(:stub_options) { { content_type: 'text/plain' } }
128
+ subject { model.patch(patch_spec) }
129
+ it { expect(subject).to be_an_instance_of(String) }
130
+ end
131
+ end