Implement remaining_budget? method in discount budget
This commit is contained in:
parent
c4528b1c92
commit
65dd309569
@ -19,6 +19,10 @@ module PlanetExpress
|
|||||||
budget - spent_budget
|
budget - spent_budget
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remaining_budget?
|
||||||
|
!available_budget.zero?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :applied_discounts
|
attr_reader :applied_discounts
|
||||||
|
@ -9,6 +9,7 @@ RSpec.describe PlanetExpress::DiscountBudget do
|
|||||||
it 'returns the full discount' do
|
it 'returns the full discount' do
|
||||||
expect(subject.apply_discount(120)).to eq(120)
|
expect(subject.apply_discount(120)).to eq(120)
|
||||||
expect(subject.available_budget).to eq(380)
|
expect(subject.available_budget).to eq(380)
|
||||||
|
expect(subject.remaining_budget?).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ RSpec.describe PlanetExpress::DiscountBudget do
|
|||||||
it 'returns only the remaining budget' do
|
it 'returns only the remaining budget' do
|
||||||
expect(subject.apply_discount(650)).to eq(500)
|
expect(subject.apply_discount(650)).to eq(500)
|
||||||
expect(subject.available_budget).to eq(0)
|
expect(subject.available_budget).to eq(0)
|
||||||
|
expect(subject.remaining_budget?).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user