From 82e4ff90dc902304a957d8efbc3752d864ec0d23 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 26 Oct 2019 01:22:52 +0200 Subject: [PATCH] Test tournament.matches method --- spec/models/tournament_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/models/tournament_spec.rb b/spec/models/tournament_spec.rb index 20e6f6b..c182909 100644 --- a/spec/models/tournament_spec.rb +++ b/spec/models/tournament_spec.rb @@ -30,4 +30,29 @@ RSpec.describe Tournament, type: :model do it { should have_many :teams } it { should have_many :stages } end + + describe '#matches' do + context 'group stage tournament' do + before do + @tournament = create(:group_stage_tournament) + end + + it 'returns only matches' do + @tournament.matches.each do |m| + expect(m).to be_a Match + end + end + end + + context 'stage tournament' do + before do + @tournament = create(:stage_tournament) + end + it 'returns only matches' do + @tournament.matches.each do |m| + expect(m).to be_a Match + end + end + end + end end