HTTP response Test should not fail because of no tournament found

This commit is contained in:
Daniel Schädler 2020-01-14 16:53:23 +01:00
parent 793f750547
commit c93244b005
1 changed files with 42 additions and 32 deletions

View File

@ -219,14 +219,18 @@ RSpec.describe TournamentsController, type: :controller do
context 'with groups of 4' do
before do
post :create, params: create_group_tournament_data_groups_of_4
body = deserialize_response response
@group_stage_tournament = Tournament.find(body[:id])
end
it 'returns HTTP status created' do
expect(response).to have_http_status(:created)
end
context 'looking at the tournament' do
before do
body = deserialize_response response
@group_stage_tournament = Tournament.find(body[:id])
end
it 'generates a group stage with all teams given in parameters' do
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
expect(included_teams).to match_array(@teams16)
@ -246,18 +250,23 @@ RSpec.describe TournamentsController, type: :controller do
expect(@group_stage_tournament.teams).to match_array(@teams16)
end
end
end
context 'groups of 5' do
before do
post :create, params: create_group_tournament_data_groups_of_5
body = deserialize_response response
@group_stage_tournament = Tournament.find(body[:id])
end
it 'returns HTTP status created' do
expect(response).to have_http_status(:created)
end
context 'looking at the tournament' do
before do
body = deserialize_response response
@group_stage_tournament = Tournament.find(body[:id])
end
it 'generates a group stage with all teams given in parameters' do
included_teams = @group_stage_tournament.stages.find_by(level: -1).teams
expect(included_teams).to match_array(@teams20)
@ -277,6 +286,7 @@ RSpec.describe TournamentsController, type: :controller do
expect(@group_stage_tournament.teams).to match_array(@teams20)
end
end
end
context 'playoff_teams_amount unacceptable' do
shared_examples_for 'wrong playoff_teams_amount' do