zz_bitbucket_rest_api 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +7 -0
  3. data/README.md +169 -0
  4. data/lib/bitbucket_rest_api.rb +91 -0
  5. data/lib/bitbucket_rest_api/api.rb +106 -0
  6. data/lib/bitbucket_rest_api/api/actions.rb +35 -0
  7. data/lib/bitbucket_rest_api/api_factory.rb +30 -0
  8. data/lib/bitbucket_rest_api/authorization.rb +34 -0
  9. data/lib/bitbucket_rest_api/client.rb +55 -0
  10. data/lib/bitbucket_rest_api/configuration.rb +106 -0
  11. data/lib/bitbucket_rest_api/connection.rb +98 -0
  12. data/lib/bitbucket_rest_api/constants.rb +58 -0
  13. data/lib/bitbucket_rest_api/core_ext/array.rb +7 -0
  14. data/lib/bitbucket_rest_api/core_ext/hash.rb +46 -0
  15. data/lib/bitbucket_rest_api/deprecation.rb +39 -0
  16. data/lib/bitbucket_rest_api/error.rb +38 -0
  17. data/lib/bitbucket_rest_api/error/bad_events.rb +9 -0
  18. data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
  19. data/lib/bitbucket_rest_api/error/blank_value.rb +9 -0
  20. data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
  21. data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
  22. data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
  23. data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
  24. data/lib/bitbucket_rest_api/error/no_events.rb +9 -0
  25. data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
  26. data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
  27. data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
  28. data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
  29. data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
  30. data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
  31. data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
  32. data/lib/bitbucket_rest_api/error/validations.rb +18 -0
  33. data/lib/bitbucket_rest_api/invitations.rb +15 -0
  34. data/lib/bitbucket_rest_api/issues.rb +230 -0
  35. data/lib/bitbucket_rest_api/issues/comments.rb +118 -0
  36. data/lib/bitbucket_rest_api/issues/components.rb +106 -0
  37. data/lib/bitbucket_rest_api/issues/milestones.rb +107 -0
  38. data/lib/bitbucket_rest_api/normalizer.rb +27 -0
  39. data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
  40. data/lib/bitbucket_rest_api/repos.rb +272 -0
  41. data/lib/bitbucket_rest_api/repos/changesets.rb +54 -0
  42. data/lib/bitbucket_rest_api/repos/commits.rb +40 -0
  43. data/lib/bitbucket_rest_api/repos/components.rb +36 -0
  44. data/lib/bitbucket_rest_api/repos/default_reviewers.rb +59 -0
  45. data/lib/bitbucket_rest_api/repos/download.rb +21 -0
  46. data/lib/bitbucket_rest_api/repos/following.rb +39 -0
  47. data/lib/bitbucket_rest_api/repos/forks.rb +69 -0
  48. data/lib/bitbucket_rest_api/repos/keys.rb +88 -0
  49. data/lib/bitbucket_rest_api/repos/pull_request.rb +160 -0
  50. data/lib/bitbucket_rest_api/repos/services.rb +103 -0
  51. data/lib/bitbucket_rest_api/repos/sources.rb +39 -0
  52. data/lib/bitbucket_rest_api/repos/webhooks.rb +99 -0
  53. data/lib/bitbucket_rest_api/request.rb +76 -0
  54. data/lib/bitbucket_rest_api/request/basic_auth.rb +31 -0
  55. data/lib/bitbucket_rest_api/request/jsonize.rb +46 -0
  56. data/lib/bitbucket_rest_api/request/oauth.rb +53 -0
  57. data/lib/bitbucket_rest_api/response.rb +28 -0
  58. data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
  59. data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
  60. data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
  61. data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
  62. data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
  63. data/lib/bitbucket_rest_api/result.rb +140 -0
  64. data/lib/bitbucket_rest_api/teams.rb +88 -0
  65. data/lib/bitbucket_rest_api/user.rb +101 -0
  66. data/lib/bitbucket_rest_api/users.rb +24 -0
  67. data/lib/bitbucket_rest_api/users/account.rb +53 -0
  68. data/lib/bitbucket_rest_api/utils/url.rb +56 -0
  69. data/lib/bitbucket_rest_api/validations.rb +25 -0
  70. data/lib/bitbucket_rest_api/validations/format.rb +24 -0
  71. data/lib/bitbucket_rest_api/validations/presence.rb +25 -0
  72. data/lib/bitbucket_rest_api/validations/required.rb +44 -0
  73. data/lib/bitbucket_rest_api/validations/token.rb +43 -0
  74. data/lib/bitbucket_rest_api/version.rb +11 -0
  75. data/spec/bitbucket_rest_api/api/actions_spec.rb +17 -0
  76. data/spec/bitbucket_rest_api/api_factory_spec.rb +30 -0
  77. data/spec/bitbucket_rest_api/api_spec.rb +86 -0
  78. data/spec/bitbucket_rest_api/authorization_spec.rb +72 -0
  79. data/spec/bitbucket_rest_api/client_spec.rb +16 -0
  80. data/spec/bitbucket_rest_api/core_ext/array_spec.rb +12 -0
  81. data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +49 -0
  82. data/spec/bitbucket_rest_api/deprecation_spec.rb +30 -0
  83. data/spec/bitbucket_rest_api/error/bad_events_spec.rb +10 -0
  84. data/spec/bitbucket_rest_api/error/blank_value_spec.rb +13 -0
  85. data/spec/bitbucket_rest_api/error/no_events_spec.rb +10 -0
  86. data/spec/bitbucket_rest_api/invitations_spec.rb +21 -0
  87. data/spec/bitbucket_rest_api/issues/comments_spec.rb +89 -0
  88. data/spec/bitbucket_rest_api/issues/components_spec.rb +88 -0
  89. data/spec/bitbucket_rest_api/issues/milestones_spec.rb +88 -0
  90. data/spec/bitbucket_rest_api/issues_spec.rb +90 -0
  91. data/spec/bitbucket_rest_api/normalizer_spec.rb +30 -0
  92. data/spec/bitbucket_rest_api/parameter_filter_spec.rb +41 -0
  93. data/spec/bitbucket_rest_api/repos/changesets_spec.rb +43 -0
  94. data/spec/bitbucket_rest_api/repos/commits_spec.rb +20 -0
  95. data/spec/bitbucket_rest_api/repos/components_spec.rb +42 -0
  96. data/spec/bitbucket_rest_api/repos/default_reviewers_spec.rb +64 -0
  97. data/spec/bitbucket_rest_api/repos/download_spec.rb +9 -0
  98. data/spec/bitbucket_rest_api/repos/following_spec.rb +52 -0
  99. data/spec/bitbucket_rest_api/repos/forks_spec.rb +45 -0
  100. data/spec/bitbucket_rest_api/repos/keys_spec.rb +72 -0
  101. data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +288 -0
  102. data/spec/bitbucket_rest_api/repos/sources_spec.rb +77 -0
  103. data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +245 -0
  104. data/spec/bitbucket_rest_api/repos_spec.rb +157 -0
  105. data/spec/bitbucket_rest_api/request/jsonize_spec.rb +18 -0
  106. data/spec/bitbucket_rest_api/request/oauth_spec.rb +27 -0
  107. data/spec/bitbucket_rest_api/request_spec.rb +81 -0
  108. data/spec/bitbucket_rest_api/response/jsonize_spec.rb +12 -0
  109. data/spec/bitbucket_rest_api/response/mashify_spec.rb +32 -0
  110. data/spec/bitbucket_rest_api/response/raise_error_spec.rb +41 -0
  111. data/spec/bitbucket_rest_api/teams_spec.rb +135 -0
  112. data/spec/bitbucket_rest_api/user_spec.rb +77 -0
  113. data/spec/bitbucket_rest_api/utils/url_spec.rb +33 -0
  114. data/spec/bitbucket_rest_api/validations/format_spec.rb +29 -0
  115. data/spec/bitbucket_rest_api/validations/presence_spec.rb +12 -0
  116. data/spec/bitbucket_rest_api/validations/required_spec.rb +43 -0
  117. data/spec/bitbucket_rest_api/validations/token_spec.rb +16 -0
  118. data/spec/bitbucket_rest_api_spec.rb +17 -0
  119. data/spec/spec_helper.rb +24 -0
  120. metadata +378 -0
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Authorization do
4
+ let(:oauth_api) { BitBucket::API.new(oauth_token: 'example_oauth_token') }
5
+ let(:basic_auth_api) { BitBucket::API.new(basic_auth: 'example_login:example_password') }
6
+ let(:basic_auth_api_hash) do
7
+ BitBucket::API.new(
8
+ basic_auth: { login: 'example_login', password: 'example_password' })
9
+ end
10
+ let(:login_and_password_api) do
11
+ BitBucket::API.new(
12
+ login: 'example_login',
13
+ password: 'example_password',
14
+ basic_auth: nil
15
+ )
16
+ end
17
+
18
+ describe '#authenticated?' do
19
+ context 'oauth authentication' do
20
+ it 'should return true if oauth is used' do
21
+ expect(oauth_api.authenticated?).to eq(true)
22
+ end
23
+ end
24
+
25
+ context 'basic authentication' do
26
+ it 'should return true if basic authentication is used' do
27
+ expect(basic_auth_api.authenticated?).to eq(true)
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '#basic_authed?' do
33
+ context 'with basic_auth' do
34
+ it 'should return true if basic_auth is set' do
35
+ expect(basic_auth_api.basic_authed?).to eq(true)
36
+ expect(basic_auth_api_hash.basic_authed?).to eq(true)
37
+ end
38
+ end
39
+
40
+ context 'with login and password' do
41
+ it 'should return true if a login and password are set' do
42
+ expect(login_and_password_api.basic_authed?).to eq(true)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#authentication' do
48
+ context 'with basic_auth as a string' do
49
+ it 'should return a hash containing the value for :basic_auth' do
50
+ expectation = { basic_auth: 'example_login:example_password' }
51
+
52
+ expect(basic_auth_api.authentication).to eq(expectation)
53
+ end
54
+ end
55
+
56
+ context 'with basic_auth as a hash' do
57
+ it 'should return a hash containing the value for :basic_auth' do
58
+ expectation = { basic_auth: { login: 'example_login', password: 'example_password'} }
59
+
60
+ expect(basic_auth_api_hash.authentication).to eq(expectation)
61
+ end
62
+ end
63
+
64
+ context 'with login and password' do
65
+ it 'should return a hash containing values for :login and :password' do
66
+ expectation = { login: 'example_login', password: 'example_password' }
67
+
68
+ expect(login_and_password_api.authentication).to eq(expectation)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Client do
4
+ let(:client) { described_class.new }
5
+
6
+ it "returns the a new object of the correct class" do
7
+ expect(client.issues).to be_a BitBucket::Issues
8
+ expect(client.repos).to be_a BitBucket::Repos
9
+ expect(client.users).to be_a BitBucket::Users
10
+ expect(client.user_api).to be_a BitBucket::User
11
+ expect(client.invitations).to be_a BitBucket::Invitations
12
+ expect(client.teams).to be_a BitBucket::Teams
13
+ expect(client.pull_requests).to be_a BitBucket::Repos::PullRequest
14
+ expect(client.oauth).to be_a BitBucket::Request::OAuth
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'bitbucket_rest_api/core_ext/array'
3
+
4
+ describe Array do
5
+ let(:array) { [:a, :b, :c, :d, { key: :value }] }
6
+
7
+ describe '#extract_options!' do
8
+ it 'selects a hash from the arguments list' do
9
+ expect(array.extract_options!).to eq({ key: :value })
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Hash do
6
+
7
+ before do
8
+ BitBucket.new
9
+ @hash = { :a => 1, :b => 2, :c => 'e'}
10
+ @serialized = "a=1&b=2&c=e"
11
+ @nested_hash = { 'a' => { 'b' => {'c' => 1 } } }
12
+ @symbols = { :a => { :b => { :c => 1 } } }
13
+ end
14
+
15
+ context '#symbolize_keys' do
16
+ it 'should respond to symbolize_keys' do
17
+ expect(@nested_hash).to respond_to :symbolize_keys
18
+ end
19
+ end
20
+
21
+ context '#symbolize_keys!' do
22
+ it 'should respond to symbolize_keys!' do
23
+ expect(@nested_hash).to respond_to :symbolize_keys!
24
+ end
25
+
26
+ it 'should convert nested keys to symbols' do
27
+ expect(@nested_hash.symbolize_keys!).to eq @symbols
28
+
29
+ @nested_hash_with_array = { 'a' => { 'b' => [{'c' => 1}] } }
30
+ expect(@nested_hash_with_array.symbolize_keys!).to eq({:a=>{:b=>[{:c=>1}]}})
31
+ end
32
+ end
33
+
34
+ context '#serialize' do
35
+ it 'should respond to serialize' do
36
+ expect(@nested_hash).to respond_to :serialize
37
+ end
38
+
39
+ it 'should serialize hash' do
40
+ expect(@hash.serialize).to eq @serialized
41
+ end
42
+ end
43
+
44
+ context '#deep_key?' do
45
+ it 'should find key inside nested hash' do
46
+ expect(@nested_hash.has_deep_key?('c')).to be_truthy
47
+ end
48
+ end
49
+ end # Hash
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket do
4
+ let(:method) { 'create_repos'}
5
+ let(:alt_method) { 'repos.create'}
6
+
7
+ it { expect(described_class.constants).to include :DEPRECATION_PREFIX }
8
+
9
+ context '.deprecate' do
10
+ before do
11
+ BitBucket.deprecation_tracker = []
12
+ end
13
+
14
+ it 'tracks messages' do
15
+ expect(BitBucket).to receive(:warn).once()
16
+ BitBucket.deprecate(method)
17
+ BitBucket.deprecate(method)
18
+ end
19
+
20
+ it 'prints the message through Kernel' do
21
+ expect(BitBucket).to receive(:warn).once()
22
+ BitBucket.deprecate method
23
+ end
24
+ end
25
+
26
+ it 'prints the message through Kernel' do
27
+ expect(BitBucket).to receive(:warn)
28
+ BitBucket.warn_deprecation method
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Error::BadEvents do
4
+ context 'an event that does not exist is passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
5
+ it 'should raise an error with a message' do
6
+ expect { raise described_class.new('bad:event') }.
7
+ to raise_error(BitBucket::Error::BadEvents, "The event: 'bad:event', does not exist :(")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Error::BlankValue do
4
+ context 'an event that does not exist is passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
5
+ it 'should raise an error with a message' do
6
+ expect { raise described_class.new('required_key') }.
7
+ to raise_error(
8
+ BitBucket::Error::BlankValue,
9
+ "The value for: 'required_key', cannot be blank :("
10
+ )
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Error::NoEvents do
4
+ context 'no events are passed in BitBucket::Repos::Webhooks#create or BitBucket::Repos::Webhooks#edit' do
5
+ it 'should raise an error with a message' do
6
+ expect { raise described_class.new }.
7
+ to raise_error(BitBucket::Error::NoEvents, "At least one event is required, none given :(")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Invitations do
4
+ subject { described_class.new }
5
+
6
+ describe '#invitations' do
7
+ before do
8
+ expect(subject).to receive(:request).with(
9
+ :post,
10
+ "/1.0/invitations/mock_username/mock_repo/mock_email_address",
11
+ { :permission => 'read' },
12
+ {}
13
+ )
14
+ end
15
+
16
+ it 'sends a POST request for an invitation belonging to the given repo' do
17
+ subject.invite('mock_username', 'mock_repo', 'mock_email_address', 'read')
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Issues::Comments do
4
+ let(:comments) { described_class.new }
5
+
6
+ describe '.list' do
7
+ before do
8
+ expect(comments).to receive(:request).with(
9
+ :get,
10
+ '/1.0/repositories/mock_username/mock_repo/issues/mock_issue_id/comments/',
11
+ {},
12
+ {}
13
+ ).and_return(['comment1', 'comment2', 'comment3'])
14
+ end
15
+
16
+ context 'without a block' do
17
+ it 'should make a GET request for the given issue' do
18
+ comments.list('mock_username', 'mock_repo', 'mock_issue_id')
19
+ end
20
+ end
21
+
22
+ context 'with a block' do
23
+ it 'should make a GET request for the given issue' do
24
+ comments.list('mock_username', 'mock_repo', 'mock_issue_id') { |comment| comment }
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '.get' do
30
+ before do
31
+ expect(comments).to receive(:request).with(
32
+ :get,
33
+ '/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
34
+ {},
35
+ {}
36
+ )
37
+ end
38
+
39
+ it 'should make a GET request for the given comment' do
40
+ comments.get('mock_username', 'mock_repo', 'mock_comment_id')
41
+ end
42
+ end
43
+
44
+ describe '.create' do
45
+ before do
46
+ expect(comments).to receive(:request).with(
47
+ :post,
48
+ '/1.0/repositories/mock_username/mock_repo/issues/mock_issue_id/comments/',
49
+ {'content' => 'mock_comment'},
50
+ {}
51
+ )
52
+ end
53
+
54
+ it 'should send a POST request for the given issue' do
55
+ comments.create('mock_username', 'mock_repo', 'mock_issue_id', 'content' => 'mock_comment')
56
+ end
57
+ end
58
+
59
+ describe '.edit' do
60
+ before do
61
+ expect(comments).to receive(:request).with(
62
+ :put,
63
+ '/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
64
+ {'content' => 'new_mock_comment'},
65
+ {}
66
+ )
67
+ end
68
+
69
+ it 'should send a PUT request for the given comment' do
70
+ comments.edit('mock_username', 'mock_repo', 'mock_comment_id', 'content' => 'new_mock_comment')
71
+ end
72
+ end
73
+
74
+ describe '.delete' do
75
+ before do
76
+ expect(comments).to receive(:request).with(
77
+ :delete,
78
+ '/1.0/repositories/mock_username/mock_repo/issues/comments/mock_comment_id',
79
+ {},
80
+ {}
81
+ )
82
+ end
83
+
84
+ it 'should make a DELETE request for the given comment' do
85
+ comments.delete('mock_username', 'mock_repo', 'mock_comment_id')
86
+ end
87
+ end
88
+ end
89
+
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Issues::Components do
4
+ subject { described_class.new }
5
+
6
+ describe '#list' do
7
+ before do
8
+ expect(subject).to receive(:request).with(
9
+ :get,
10
+ '/1.0/repositories/mock_username/mock_repo/issues/components',
11
+ {},
12
+ {}
13
+ ).and_return(['component1', 'component2', 'component3'])
14
+ end
15
+
16
+ context 'without a block' do
17
+ it 'makes a GET request for the components belonging to the given repo' do
18
+ subject.list('mock_username', 'mock_repo')
19
+ end
20
+ end
21
+
22
+ context 'with a block' do
23
+ it 'makes a GET request for the components belonging to the given repo' do
24
+ subject.list('mock_username', 'mock_repo') { |component| component }
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#get' do
30
+ before do
31
+ expect(subject).to receive(:request).with(
32
+ :get,
33
+ '/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
34
+ {},
35
+ {}
36
+ )
37
+ end
38
+
39
+ it 'makes a GET request for the given component belonging to the given repo' do
40
+ subject.get('mock_username', 'mock_repo', 'mock_component_id')
41
+ end
42
+ end
43
+
44
+ describe '#create' do
45
+ before do
46
+ expect(subject).to receive(:request).with(
47
+ :post,
48
+ '/1.0/repositories/mock_username/mock_repo/issues/components',
49
+ { 'name' => 'mock_name' },
50
+ {}
51
+ )
52
+ end
53
+
54
+ it 'makes a POST request for a new component that will belong to the given repo' do
55
+ subject.create('mock_username', 'mock_repo', name: 'mock_name')
56
+ end
57
+ end
58
+
59
+ describe '#update' do
60
+ before do
61
+ expect(subject).to receive(:request).with(
62
+ :put,
63
+ '/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
64
+ { 'name' => 'mock_name' },
65
+ {}
66
+ )
67
+ end
68
+
69
+ it 'makes a PUT request for the given component belonging to the given repo' do
70
+ subject.update('mock_username', 'mock_repo', 'mock_component_id', name: 'mock_name')
71
+ end
72
+ end
73
+
74
+ describe '#delete' do
75
+ before do
76
+ expect(subject).to receive(:request).with(
77
+ :delete,
78
+ '/1.0/repositories/mock_username/mock_repo/issues/components/mock_component_id',
79
+ {},
80
+ {}
81
+ )
82
+ end
83
+
84
+ it 'makes a PUT request for the given component belonging to the given repo' do
85
+ subject.delete('mock_username', 'mock_repo', 'mock_component_id')
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Issues::Milestones do
4
+ subject { described_class.new }
5
+
6
+ describe '#list' do
7
+ before do
8
+ expect(subject).to receive(:request).with(
9
+ :get,
10
+ '/1.0/repositories/mock_username/mock_repo/issues/milestones',
11
+ {},
12
+ {}
13
+ ).and_return(['milsetone1', 'milestone2', 'milestone3'])
14
+ end
15
+
16
+ context 'without a block' do
17
+ it 'makes a GET request for the milestones belonging to the given repo' do
18
+ subject.list('mock_username', 'mock_repo')
19
+ end
20
+ end
21
+
22
+ context 'with a block' do
23
+ it 'makes a GET request for the milestones belonging to the given repo' do
24
+ subject.list('mock_username', 'mock_repo') { |milestone| milestone }
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#get' do
30
+ before do
31
+ expect(subject).to receive(:request).with(
32
+ :get,
33
+ '/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
34
+ {},
35
+ {}
36
+ )
37
+ end
38
+
39
+ it 'makes a GET request for the given milestone belonging to the given repo' do
40
+ subject.get('mock_username', 'mock_repo', 'mock_milestone_id')
41
+ end
42
+ end
43
+
44
+ describe '#create' do
45
+ before do
46
+ expect(subject).to receive(:request).with(
47
+ :post,
48
+ '/1.0/repositories/mock_username/mock_repo/issues/milestones',
49
+ { 'name' => 'mock_name' },
50
+ {}
51
+ )
52
+ end
53
+
54
+ it 'makes a POST request for a new milestone that will belong to the given repo' do
55
+ subject.create('mock_username', 'mock_repo', name: 'mock_name')
56
+ end
57
+ end
58
+
59
+ describe '#update' do
60
+ before do
61
+ expect(subject).to receive(:request).with(
62
+ :put,
63
+ '/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
64
+ { 'name' => 'mock_name' },
65
+ {}
66
+ )
67
+ end
68
+
69
+ it 'makes a PUT request for the given milestone belonging to the given repo' do
70
+ subject.update('mock_username', 'mock_repo', 'mock_milestone_id', name: 'mock_name')
71
+ end
72
+ end
73
+
74
+ describe '#delete' do
75
+ before do
76
+ expect(subject).to receive(:request).with(
77
+ :delete,
78
+ '/1.0/repositories/mock_username/mock_repo/issues/milestones/mock_milestone_id',
79
+ {},
80
+ {}
81
+ )
82
+ end
83
+
84
+ it 'makes a PUT request for the given milestone belonging to the given repo' do
85
+ subject.delete('mock_username', 'mock_repo', 'mock_milestone_id')
86
+ end
87
+ end
88
+ end