|
| 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 |
0 commit comments