Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Added more tests to team selection
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed May 27, 2015
1 parent f235e48 commit 62c5e2a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/spaceship/ui/select_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def select_team

raise "Your account is in no teams" if teams.count == 0

user_team = ENV['FASTLANE_TEAM_ID'].strip
user_team = (ENV['FASTLANE_TEAM_ID'] || '').strip
if user_team
# User provided a value, let's see if it's valid
puts "Looking for team with ID '#{user_team}'"
Expand Down
34 changes: 29 additions & 5 deletions spec/UI/select_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,36 @@
expect(subject.select_team).to eq("XXXXXXXXXX")
end

it "lets the user select the team if in multiple teams" do
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/listTeams.action').
describe "Multiple Teams" do
before do
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/listTeams.action').
to_return(:status => 200, :body => read_fixture_file('listTeams_multiple.action.json'), :headers => {'Content-Type' => 'application/json'})

allow($stdin).to receive(:gets).and_return("2")
expect(subject.select_team).to eq("SecondTeam") # a different team
end

it "lets the user select the team if in multiple teams" do
allow($stdin).to receive(:gets).and_return("2")
expect(subject.select_team).to eq("SecondTeam") # a different team
end

it "fallsback to user selection if team wasn't found" do
ENV["FASTLANE_TEAM_ID"] = "Not Here"
allow($stdin).to receive(:gets).and_return("2")
expect(subject.select_team).to eq("SecondTeam") # a different team
end

it "Uses the specific team (1/2)" do
ENV["FASTLANE_TEAM_ID"] = "SecondTeam"
expect(subject.select_team).to eq("SecondTeam") # a different team
end

it "Uses the specific team (2/2)" do
ENV["FASTLANE_TEAM_ID"] = "XXXXXXXXXX"
expect(subject.select_team).to eq("XXXXXXXXXX") # a different team
end

after do
ENV.delete("FASTLANE_TEAM_ID")
end
end
end
end
Expand Down

0 comments on commit 62c5e2a

Please sign in to comment.