Ability to clear checkout
This commit is contained in:
@@ -24,6 +24,10 @@ class Checkout
|
|||||||
pre_discount_total - current_discount
|
pre_discount_total - current_discount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear
|
||||||
|
@items = []
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def valid_item?(item)
|
def valid_item?(item)
|
||||||
|
|||||||
@@ -35,6 +35,19 @@ class TestCheckout < Minitest::Test
|
|||||||
assert_equal 0.00, @checkout.total
|
assert_equal 0.00, @checkout.total
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_that_we_can_empty_the_checkout
|
||||||
|
@checkout.add(:PI5)
|
||||||
|
@checkout.add(:ZERO2W)
|
||||||
|
@checkout.add(:PICO2)
|
||||||
|
|
||||||
|
refute_empty @checkout.items
|
||||||
|
|
||||||
|
@checkout.clear
|
||||||
|
|
||||||
|
assert_empty @checkout.items
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# Discounts
|
# Discounts
|
||||||
|
|
||||||
def test_that_bogof_applied
|
def test_that_bogof_applied
|
||||||
|
|||||||
Reference in New Issue
Block a user