From c0aea2395413034533dd742ec075c49754daca2f Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Thu, 1 Aug 2024 19:11:36 +0200 Subject: [PATCH] Include additional test case --- .../tables/discomfort_calculator_spec.rb | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/spec/services/tables/discomfort_calculator_spec.rb b/spec/services/tables/discomfort_calculator_spec.rb index 939ebb4..7560661 100644 --- a/spec/services/tables/discomfort_calculator_spec.rb +++ b/spec/services/tables/discomfort_calculator_spec.rb @@ -100,20 +100,31 @@ module Tables end end - context 'when the table contains four guests of two split groups' do + context 'when the table contains four guests of two evenly split groups' do let(:table) do [ - create(:guest, affinity_group_list: ['family']), - create(:guest, affinity_group_list: ['family']), - create(:guest, affinity_group_list: ['friends']), - create(:guest, affinity_group_list: ['friends']) - ] + create_list(:guest, 2, affinity_group_list: ['family']), + create_list(:guest, 2, affinity_group_list: ['friends']) + ].flatten end it 'returns the sum of the penalties for each pair of guests' do expect(calculator.send(:cohesion_penalty)).to eq(4) end end + + context 'when the table contains six guests of two unevenly split groups' do + let(:table) do + [ + create_list(:guest, 2, affinity_group_list: ['family']), + create_list(:guest, 4, affinity_group_list: ['friends']) + ].flatten + end + + it 'returns the sum of the penalties for each pair of guests' do + expect(calculator.send(:cohesion_penalty)).to eq(8) + end + end end end end