Change return for 0 teams to exception
This commit is contained in:
parent
a449e0193a
commit
d3d572ea1b
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue