wedding-planner/spec/services/tables/discomfort_calculator_spec.rb

44 lines
1.3 KiB
Ruby

require 'rails_helper'
module Tables
RSpec.describe DiscomfortCalculator do
describe '#group_merging' do
let(:calculator) { described_class.new(table) }
context 'when there is just one group in the table' do
let(:table) do
create_list(:guest, 3).each do |guest|
guest.affinity_group_list.add('family')
guest.save!
end
end
it { expect(calculator.send(:group_merging)).to eq(0) }
end
context 'when the table contains two groups' do
let(:table) do
guests = create_list(:guest, 3)
guests[0].affinity_group_list.add('family')
guests[1].affinity_group_list.add('friends')
guests[2].affinity_group_list.add('family')
guests.each(&:save!)
end
it { expect(calculator.send(:group_merging)).to eq(10) }
end
context 'when the table contains three groups' do
let(:table) do
guests = create_list(:guest, 3)
guests[0].affinity_group_list.add('family')
guests[1].affinity_group_list.add('friends')
guests[2].affinity_group_list.add('work')
guests.each(&:save!)
end
it { expect(calculator.send(:group_merging)).to eq(20) }
end
end
end
end