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,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Repos do
4
+ let(:repo) { BitBucket::Repos.new }
5
+
6
+ # class_eval is setting global variables in api.rb, this is creating
7
+ # failed expectations when these variables are not reset to nil before
8
+ # the next test is run. Therefore we must clear them manually as
9
+ # for the user attribute below...
10
+ after do
11
+ repo.clear_user
12
+ end
13
+
14
+ describe '.create' do
15
+ before do
16
+ expect(repo).to receive(:request).with(
17
+ :post,
18
+ '/1.0/repositories/',
19
+ BitBucket::Repos::DEFAULT_REPO_OPTIONS.merge({ 'owner' => 'mock_owner', 'name' => 'mock_repo' }),
20
+ {}
21
+ )
22
+ end
23
+
24
+ it 'should send a POST request to create the repo' do
25
+ repo.create({ 'owner' => 'mock_owner', 'name' => 'mock_repo' })
26
+ end
27
+ end
28
+
29
+ describe '.delete' do
30
+ before do
31
+ expect(repo).to receive(:request).with(
32
+ :delete,
33
+ '/1.0/repositories/mock_username/mock_repo',
34
+ {},
35
+ {}
36
+ )
37
+ end
38
+
39
+ it 'should send a DELETE request for the given repo' do
40
+ repo.delete('mock_username', 'mock_repo')
41
+ end
42
+ end
43
+
44
+ # TODO: fix case where block_given? returns true
45
+ describe '.branches' do
46
+ before do
47
+ expect(repo).to receive(:request).with(
48
+ :get,
49
+ '/1.0/repositories/mock_username/mock_repo/branches/',
50
+ {},
51
+ {}
52
+ ).and_return(['branch1', 'branch2', 'branch3'])
53
+ end
54
+
55
+ context 'without a block' do
56
+ it 'invokes the .request method' do
57
+ repo.branches('mock_username', 'mock_repo')
58
+ end
59
+ end
60
+
61
+ context 'with a block' do
62
+ it 'invokes the .request method' do
63
+ repo.branches('mock_username', 'mock_repo') { |branch| branch }
64
+ end
65
+ end
66
+ end
67
+
68
+ describe '.edit' do
69
+ before do
70
+ expect(repo).to receive(:request).with(
71
+ :put,
72
+ '/1.0/repositories/mock_username/mock_repo/',
73
+ BitBucket::Repos::DEFAULT_REPO_OPTIONS.merge({ 'owner' => 'mock_owner' }),
74
+ {}
75
+ )
76
+ end
77
+
78
+ it 'should send a PUT request for the given repo' do
79
+ repo.edit('mock_username', 'mock_repo', { 'owner' => 'mock_owner' })
80
+ end
81
+ end
82
+
83
+ # TODO: make sure this gets documented in gem since it is not in official docs
84
+ describe '.get' do
85
+ before do
86
+ expect(repo).to receive(:request).with(
87
+ :get,
88
+ '/1.0/repositories/mock_username/mock_repo',
89
+ {},
90
+ {}
91
+ )
92
+ end
93
+
94
+ it 'should send a GET request for the given repo' do
95
+ repo.get('mock_username', 'mock_repo', {})
96
+ end
97
+ end
98
+
99
+ describe '.list' do
100
+ before do
101
+ expect(repo).to receive(:request).with(
102
+ :get,
103
+ '/2.0/repositories',
104
+ {"pagelen" => 100},
105
+ {}
106
+ ).and_return(values: ['repo1', 'repo2' ,'repo3'])
107
+ end
108
+
109
+ # FIXME: this method belongs in the User class!
110
+ context 'without a block' do
111
+ it 'should send a GET request for the authenticated users repos' do
112
+ repo.list
113
+ end
114
+ end
115
+
116
+ context 'with a block' do
117
+ it 'should send a GET request for the authenticated users repos' do
118
+ repo.list { |repo| repo }
119
+ end
120
+ end
121
+ end
122
+
123
+ describe '.tags' do
124
+ before do
125
+ expect(repo).to receive(:request).with(
126
+ :get,
127
+ '/1.0/repositories/mock_username/mock_repo/tags/',
128
+ {},
129
+ {}
130
+ ).and_return(['tag1', 'tag2' ,'tag3'])
131
+ end
132
+
133
+ context 'without a block' do
134
+ it 'should send a GET request for the tags belonging to the given repo' do
135
+ repo.tags('mock_username', 'mock_repo')
136
+ end
137
+ end
138
+
139
+ context 'with a block' do
140
+ it 'should send a GET request for the tags belonging to the given repo' do
141
+ repo.tags('mock_username', 'mock_repo') { |tag| tag }
142
+ end
143
+ end
144
+ end
145
+
146
+ describe "getter methods" do
147
+ it "returns an object of the correct class" do
148
+ expect(repo.changesets).to be_a BitBucket::Repos::Changesets
149
+ expect(repo.keys).to be_a BitBucket::Repos::Keys
150
+ expect(repo.following).to be_a BitBucket::Repos::Following
151
+ expect(repo.commits).to be_a BitBucket::Repos::Commits
152
+ expect(repo.pull_request).to be_a BitBucket::Repos::PullRequest
153
+ expect(repo.forks).to be_a BitBucket::Repos::Forks
154
+ expect(repo.download).to be_a BitBucket::Repos::Download
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Request::Jsonize do
4
+ let(:jsonize) { described_class.new(lambda { |env| env }) }
5
+ before do
6
+ @env = {
7
+ body: {key1: 'val1'},
8
+ request_headers: {
9
+ 'Content-Type' => 'application/json; charset=utf-8'
10
+ }
11
+ }
12
+ end
13
+
14
+ it "converts the body to json" do
15
+ expected = {body: "{\"key1\":\"val1\"}", request_headers: {"Content-Type"=>"application/json; charset=utf-8"}}
16
+ expect(jsonize.call(@env)).to eq expected
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+
4
+ describe BitBucket::Request::OAuth do
5
+ include Rack::Test::Methods
6
+
7
+
8
+ let(:app) { ->(env) { [200, env, "app"] } }
9
+
10
+ let (:middleware) { BitBucket::Request::OAuth.new(app) }
11
+
12
+ let(:request) { Rack::MockRequest.new(middleware) }
13
+
14
+ it "add url key to env hash with URI value" do
15
+ query_string = "key1=val1&key2=val2"
16
+ code, env = middleware.call Rack::MockRequest.env_for("/?#{query_string}", {method: :post})
17
+ expect(code).to eq 200
18
+ expect(env[:url].query).to eq query_string
19
+ end
20
+
21
+ it "creates a empty hash if query of URI is empty" do
22
+ code, env = middleware.call Rack::MockRequest.env_for("/", {method: :get})
23
+ expect(code).to eq 200
24
+ expect(middleware.query_params(env[:url])).to eq({})
25
+ end
26
+ end
27
+
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+ require 'bitbucket_rest_api/request'
3
+
4
+ describe BitBucket::Request do
5
+ let(:fake_api) { (Class.new { include BitBucket::Request })}
6
+ let(:faraday_connection) { Faraday.new(:url => 'https://api.bitbucket.org') }
7
+
8
+ describe "request" do
9
+ it "raises an ArgumentError if an unsupported HTTP verb is used" do
10
+ expect { fake_api.new.request(:i_am_a_teapot, {}, '/') }.to raise_error(ArgumentError)
11
+ end
12
+
13
+ context "with a connection" do
14
+ before do
15
+ (fake_api).any_instance.stubs(:connection).returns(faraday_connection)
16
+ (fake_api).any_instance.stubs(:new_access_token).returns("12345")
17
+ end
18
+
19
+ it "supports get" do
20
+ stub_request(:get, "https://api.bitbucket.org/1.0/endpoint").
21
+ with(:headers => {
22
+ 'Accept' => '*/*',
23
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
24
+ 'Authorization' => 'Bearer 12345',
25
+ 'User-Agent' => 'Faraday v0.9.2'
26
+ })
27
+
28
+ fake_api.new.request(:get, '/1.0/endpoint', {}, {})
29
+ end
30
+
31
+ it "supports put" do
32
+ stub_request(:put, "https://api.bitbucket.org/1.0/endpoint").
33
+ with(:body => "{\"data\":{\"key\":\"value\"}}",
34
+ :headers => {
35
+ 'Accept' => '*/*',
36
+ 'Content-Type'=>'application/x-www-form-urlencoded',
37
+ 'Authorization' => 'Bearer 12345',
38
+ 'User-Agent' => 'Faraday v0.9.2'
39
+ })
40
+
41
+ fake_api.new.request(:put, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
42
+ end
43
+
44
+ it "supports patch" do
45
+ stub_request(:patch, "https://api.bitbucket.org/1.0/endpoint").
46
+ with(:body => "{\"data\":{\"key\":\"value\"}}",
47
+ :headers => {
48
+ 'Accept' => '*/*',
49
+ 'Content-Type'=>'application/x-www-form-urlencoded',
50
+ 'Authorization' => 'Bearer 12345',
51
+ 'User-Agent' => 'Faraday v0.9.2'
52
+ })
53
+
54
+ fake_api.new.request(:patch, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
55
+ end
56
+
57
+ it "supports delete" do
58
+ stub_request(:delete, "https://api.bitbucket.org/1.0/endpoint").
59
+ with(:headers => {
60
+ 'Accept' => '*/*',
61
+ 'Authorization' => 'Bearer 12345',
62
+ 'User-Agent' => 'Faraday v0.9.2'
63
+ })
64
+ fake_api.new.request(:delete, '/1.0/endpoint', {}, {})
65
+ end
66
+
67
+ it "supports post" do
68
+ stub_request(:post, "https://api.bitbucket.org/1.0/endpoint").
69
+ with(:body => "{\"data\":{\"key\":\"value\"}}",
70
+ :headers => {
71
+ 'Accept' => '*/*',
72
+ 'Content-Type'=>'application/x-www-form-urlencoded',
73
+ 'Authorization' => 'Bearer 12345',
74
+ 'User-Agent' => 'Faraday v0.9.2'
75
+ })
76
+
77
+ fake_api.new.request(:post, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Response::Jsonize do
4
+ let(:jsonize) { described_class.new }
5
+ before do
6
+ @body = "{\"key1\":\"val1\"}"
7
+ end
8
+
9
+ it "parses the json and returns a hash" do
10
+ expect(jsonize.parse(@body)).to eq({"key1"=>"val1"})
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Response::Mashify do
4
+ # let(:mashify) { described_class.new }
5
+ describe 'parse' do
6
+ before do
7
+ @mashify = BitBucket::Response::Mashify.new
8
+ @string = "Fantastic week!"
9
+ @array = ['Monday', 'Tuesday']
10
+ @hash = {one: 'one', two: 'two', three: 'three'}
11
+ @array_with_hash = ['banana', 'apple', {:third => 'mango'}]
12
+ end
13
+ it 'parses a hash an returns a hashie mash' do
14
+ hashie_mash = @mashify.parse(@hash)
15
+ expect(hashie_mash.one).to eq("one")
16
+ end
17
+
18
+ it 'parses a hash that is within an array' do
19
+ array_hashie_mash = @mashify.parse(@array_with_hash)
20
+ expect(array_hashie_mash[2].third).to eq("mango")
21
+ end
22
+
23
+ it 'returns same object if the object does not contain a hash' do
24
+ string = @mashify.parse(@string)
25
+ array = @mashify.parse(@array)
26
+
27
+ expect(string).to eq(@string)
28
+ expect(array.length).to eq(2)
29
+ expect(array[0]).to eq("Monday")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Response::RaiseError do
4
+ describe '.on_complete' do
5
+ before do
6
+ @raise_error = BitBucket::Response::RaiseError.new
7
+ end
8
+
9
+ it 'raises a BadRequest error on 400 status code' do
10
+ expect{ @raise_error.on_complete({status: 400}) }.to raise_error BitBucket::Error::BadRequest
11
+ end
12
+
13
+ it 'raises an Unauthorized error on 401 status code' do
14
+ expect{ @raise_error.on_complete({status: 401}) }.to raise_error BitBucket::Error::Unauthorized
15
+ end
16
+
17
+ it 'raises a Forbidden error on 403 status code' do
18
+ expect{ @raise_error.on_complete({status: 403}) }.to raise_error BitBucket::Error::Forbidden
19
+ end
20
+
21
+ it 'raises a NotFound error on 404 status code' do
22
+ expect{ @raise_error.on_complete({status: 404}) }.to raise_error BitBucket::Error::NotFound
23
+ end
24
+
25
+ it 'raises an UnprocessableEntity error on 422 status code' do
26
+ expect{ @raise_error.on_complete({status: 422}) }.to raise_error BitBucket::Error::UnprocessableEntity
27
+ end
28
+
29
+ it 'raises an InternalServerError error on 500 status code' do
30
+ expect{ @raise_error.on_complete({status: 500}) }.to raise_error BitBucket::Error::InternalServerError
31
+ end
32
+
33
+ it 'raises a ServiceUnavailable error on 503 status code' do
34
+ expect{ @raise_error.on_complete({status: 503}) }.to raise_error BitBucket::Error::ServiceUnavailable
35
+ end
36
+
37
+ it 'raises a ServiceError when another status code' do
38
+ expect{ @raise_error.on_complete({status: 501}) }.to raise_error BitBucket::Error::ServiceError
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitBucket::Teams do
4
+ let(:team) { described_class.new }
5
+
6
+ describe '.list' do
7
+ before do
8
+ expect(team).to receive(:request).with(
9
+ :get,
10
+ '/2.0/teams/?role=member',
11
+ {},
12
+ {}
13
+ ).and_return({"values" => ['team1', 'team2', 'team3']})
14
+ end
15
+
16
+ context 'without a block' do
17
+ it 'sends a GET request for the teams of which the user is a member' do
18
+ team.list(:member)
19
+ end
20
+ end
21
+
22
+ context 'with a block' do
23
+ it 'sends a GET request for the teams of which the user is a member' do
24
+ team.list(:member) { |team| team }
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '.profile' do
30
+ before do
31
+ expect(team).to receive(:request).with(
32
+ :get,
33
+ '/2.0/teams/team_name',
34
+ {},
35
+ {}
36
+ )
37
+ end
38
+
39
+ it 'sends a GET request for the profile for the team' do
40
+ team.profile('team_name')
41
+ end
42
+ end
43
+
44
+ describe '.members' do
45
+ before do
46
+ expect(team).to receive(:request).with(
47
+ :get,
48
+ '/2.0/teams/team_name/members',
49
+ {},
50
+ {}
51
+ ).and_return({"values" => ['member1', 'member2', 'member3']})
52
+ end
53
+
54
+ context "without a block" do
55
+ it 'sends a GET request for the members of the team' do
56
+ team.members('team_name')
57
+ end
58
+ end
59
+
60
+ context "with a block" do
61
+ it 'sends a GET request for the members of the team' do
62
+ team.members('team_name') { |member| member }
63
+ end
64
+ end
65
+ end
66
+
67
+ describe '.followers' do
68
+ before do
69
+ expect(team).to receive(:request).with(
70
+ :get,
71
+ '/2.0/teams/team_name/followers',
72
+ {},
73
+ {}
74
+ ).and_return({"values" => ['follower1', 'follower2', 'follower3']})
75
+ end
76
+
77
+ context "without a block" do
78
+ it 'sends a GET request for the followers of the team' do
79
+ team.followers('team_name')
80
+ end
81
+ end
82
+
83
+ context "with a block" do
84
+ it 'sends a GET request for the followers of the team' do
85
+ team.followers('team_name') { |follower| follower }
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '.following' do
91
+ before do
92
+ expect(team).to receive(:request).with(
93
+ :get,
94
+ '/2.0/teams/team_name/following',
95
+ {},
96
+ {}
97
+ ).and_return({"values" => ['following1', 'following2', 'following3']})
98
+ end
99
+
100
+ context "without a block" do
101
+ it 'sends a GET request for accounts the team is following' do
102
+ team.following('team_name')
103
+ end
104
+ end
105
+
106
+ context "with a block" do
107
+ it 'sends a GET request for accounts the team is following' do
108
+ team.following('team_name') { |followee| followee }
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '.repos' do
114
+ before do
115
+ expect(team).to receive(:request).with(
116
+ :get,
117
+ '/2.0/repositories/team_name',
118
+ {},
119
+ {}
120
+ ).and_return({"values" => ['repo1', 'repo2', 'repo3']})
121
+ end
122
+
123
+ context "without a block" do
124
+ it 'sends a GET request for the repos for the team' do
125
+ team.repos('team_name')
126
+ end
127
+ end
128
+
129
+ context "with a block" do
130
+ it 'sends a GET request for the repos for the team' do
131
+ team.repos('team_name') { |repo| repo }
132
+ end
133
+ end
134
+ end
135
+ end