# frozen_string_literal: true RSpec.describe PlanetExpress::DiscountBudgetForMonthRepository do subject { described_class.new } let(:march_date_a) { Date.new(2021, 3, 6) } let(:march_date_b) { Date.new(2021, 3, 6) } describe '#for_month' do it 'returns the same discount budget for the same month' do expect(subject.for_month(march_date_a).object_id).to( eq(subject.for_month(march_date_b).object_id) ) end context 'not yet initialized month' do it 'returns a discount budget' do result = subject.for_month(march_date_a) expect(result).to be_an_instance_of(PlanetExpress::DiscountBudget) expect(result.available_budget).to eq(PlanetExpress::DiscountBudgetForMonthRepository::DEFAULT_BUDGET) end end context 'other month' do let(:april_date) { Date.new(2021, 4, 12) } it 'returns a different discount budget' do expect(subject.for_month(march_date_a).object_id).to_not(eq( subject.for_month(april_date).object_id )) end end end end