WIP specs
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m25s
Add copyright notice / copyright_notice (pull_request) Successful in 2m34s
Run unit tests / unit_tests (pull_request) Failing after 5m8s

This commit is contained in:
Manuel Bustillo 2024-11-10 13:56:54 +01:00
parent 4193cc4d6d
commit e3ce152496

View File

@ -2,5 +2,32 @@ require 'rails_helper'
module Tables module Tables
RSpec.describe Shift do 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
end end