diff --git a/spec/services/tables/shift_spec.rb b/spec/services/tables/shift_spec.rb index 0526884..e93dfb5 100644 --- a/spec/services/tables/shift_spec.rb +++ b/spec/services/tables/shift_spec.rb @@ -2,5 +2,32 @@ require 'rails_helper' module Tables RSpec.describe Shift do + describe '#each' do + let(:shifts) do + acc = [] + described_class.new(initial_solution).each do |solution| + acc << solution.tables.map(&:dup) + end + acc + end + + context 'when there are two 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].to_table + distribution.tables << %i[c d].to_table + end + end + + it 'yields all possible shifts between the tables' do + expect(shifts).to contain_exactly( + [[:b], %i[c d a]], + [[:a], %i[c d b]], + [%i[b a d], [:c]], + [%i[b a c], [:d]] + ) + end + end + end end end