Change return for 0 teams to exception

This commit is contained in:
Daniel Schädler 2019-04-23 14:18:34 +02:00
parent a449e0193a
commit d3d572ea1b
2 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class MatchService
def self.generate_matches(teams) def self.generate_matches(teams)
if teams.empty? if teams.empty?
# should be prevented by controller # should be prevented by controller
return raise 'Cannot generate Matches without teams'
end end
if teams.size == 1 if teams.size == 1

View File

@ -114,8 +114,8 @@ RSpec.describe MatchService do
end end
end end
it 'generates no matches for 0 teams' do it 'raises an exception for for 0 teams' do
expect(MatchService.generate_matches([])). to eq(nil) expect { MatchService.generate_matches([]) }. to raise_error 'Cannot generate Matches without teams'
end end
end end
end end