From 8026e66d9b618566c225f52f12d87822b9609902 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Mon, 13 May 2019 11:53:09 +0200 Subject: [PATCH] Add :undecided_group_match and :decided_playoff_match --- spec/factories/matches.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/spec/factories/matches.rb b/spec/factories/matches.rb index 3f0a89c..a069ecf 100644 --- a/spec/factories/matches.rb +++ b/spec/factories/matches.rb @@ -10,7 +10,18 @@ FactoryBot.define do after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count) end - state { 3 } + state { :in_progress } + end + + factory :decided_playoff_match do + transient do + match_scores_count { 2 } + end + after(:create) do |match, evaluator| + match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: rand(10)) + match.match_scores.first.points += 1 + end + state { :team1_won } end end @@ -23,7 +34,17 @@ FactoryBot.define do after(:create) do |match, evaluator| match.match_scores = create_list(:match_score, evaluator.match_scores_count) end - state { 3 } + state { :in_progress } + end + + factory :undecided_group_match do + transient do + match_scores_count { 2 } + end + after(:create) do |match, evaluator| + match.match_scores = create_list(:match_score, evaluator.match_scores_count, points: 3) + end + state { :team1_won } end end end