From ebc75866704a62606b5ad80c26c4f60a36c1417e Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Thu, 1 Aug 2024 20:50:26 +0200 Subject: [PATCH] Include examples with three tables --- spec/services/tables/swap_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/services/tables/swap_spec.rb b/spec/services/tables/swap_spec.rb index 4087ec4..3663d6c 100644 --- a/spec/services/tables/swap_spec.rb +++ b/spec/services/tables/swap_spec.rb @@ -51,6 +51,33 @@ module Tables ) end end + + context 'when there are three tables with two people each' do + let(:initial_solution) do + Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution| + distribution.tables << %i[a b] + distribution.tables << %i[c d] + distribution.tables << %i[e f] + end + end + + it 'yields all possible swaps between the tables' do + expect(swaps).to contain_exactly( + [%i[b c], %i[d a], %i[e f]], + [%i[b d], %i[c a], %i[e f]], + [%i[a c], %i[d b], %i[e f]], + [%i[a d], %i[c b], %i[e f]], + [%i[b e], %i[c d], %i[f a]], + [%i[b f], %i[c d], %i[e a]], + [%i[a e], %i[c d], %i[f b]], + [%i[a f], %i[c d], %i[e b]], + [%i[a b], %i[d e], %i[f c]], + [%i[a b], %i[d f], %i[e c]], + [%i[a b], %i[c e], %i[f d]], + [%i[a b], %i[c f], %i[e d]] + ) + end + end end end end