Fix tests
This commit is contained in:
parent
4449314cf6
commit
d1cbe8a354
|
|
@ -123,10 +123,18 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'includes advancing teams' do
|
it 'includes advancing teams' do
|
||||||
|
# mock GroupStageService.get_advancing_teams(@group_stage_tournament.group_stage) to include 4 teams
|
||||||
|
expected_advancing_teams = create_list(:team, 4)
|
||||||
|
allow(GroupStageService).to receive(:get_advancing_teams).and_return(expected_advancing_teams)
|
||||||
|
|
||||||
get :show, params: { id: @group_stage_tournament.to_param }
|
get :show, params: { id: @group_stage_tournament.to_param }
|
||||||
body = deserialize_response response
|
body = deserialize_response response
|
||||||
advancing_teams = body[:teams_advancing_from_group_stage]
|
advancing_teams = body[:teams_advancing_from_group_stage]
|
||||||
expected_advancing_teams = GroupStageService.get_advancing_teams(@group_stage_tournament.group_stage)
|
# check array is not empty
|
||||||
|
expect(advancing_teams).not_to be_empty
|
||||||
|
|
||||||
|
# cast json to teams and compare
|
||||||
|
advancing_teams = advancing_teams.map { |team| Team.find(team[:id]) }
|
||||||
expect(advancing_teams).to match_array(expected_advancing_teams)
|
expect(advancing_teams).to match_array(expected_advancing_teams)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ RSpec.describe GroupStageService do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO test get_advancing_teams when test data for running group stage is ready
|
||||||
|
|
||||||
describe '#get_group_object_from' do
|
describe '#get_group_object_from' do
|
||||||
it 'returns a group' do
|
it 'returns a group' do
|
||||||
group = GroupStageService.get_group_object_from(@teams1)
|
group = GroupStageService.get_group_object_from(@teams1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue