Skip to content

Commit f87aa39

Browse files
committed
Implement .members and also test with a block
1 parent b020377 commit f87aa39

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/bitbucket_rest_api/team.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ def profile(team_name)
1818
get_request("/2.0/teams/#{team_name.to_s}")
1919
end
2020

21+
def members(team_name)
22+
response = get_request("/2.0/teams/#{team_name.to_s}/members")
23+
return response unless block_given?
24+
response["values"].each { |el| yield el }
25+
end
26+
2127
end # Users
2228
end # BitBucket

spec/bitbucket_rest_api/team_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,19 @@
4848
'/2.0/teams/team_name/members',
4949
{},
5050
{}
51-
)
51+
).and_return({"values" => ['member1', 'member2', 'member3']})
5252
end
5353

54-
it 'sends a GET request for the members of the team' do
55-
team.members('team_name')
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
5664
end
5765
end
5866
end

0 commit comments

Comments
 (0)