# frozen_string_literal: true RSpec.describe PlanetExpress::DiscountBudget do let(:budget) { 500 } subject { described_class.new(budget: budget) } describe '#register_applied_discount' do context 'with sufficient remaining budget' do it 'returns the full discount' do expect(subject.register_applied_discount(120)).to eq(120) expect(subject.available_budget).to eq(380) expect(subject.remaining_budget?).to eq(true) end end context 'with insufficient remaining budget' do it 'returns only the remaining budget' do expect(subject.register_applied_discount(650)).to eq(500) expect(subject.available_budget).to eq(0) expect(subject.remaining_budget?).to eq(false) end end end describe '#maximum_possible_discount' do context 'with sufficient budget' do it 'returns the full discount amount' do expect(subject.maximum_possible_discount(300)).to eq(300) end end context 'with insufficient budget' do it 'returns the maximum possible amount' do expect(subject.maximum_possible_discount(600)).to eq(500) end end end end