From 257f154897f4fbd7804c6d400558247a6a04dcdb Mon Sep 17 00:00:00 2001 From: David Underwood Date: Wed, 15 Jul 2026 11:20:21 -0400 Subject: [PATCH] Ability to clear checkout --- checkout.rb | 4 ++++ tests.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/checkout.rb b/checkout.rb index 9b74fab..9b12081 100644 --- a/checkout.rb +++ b/checkout.rb @@ -24,6 +24,10 @@ class Checkout pre_discount_total - current_discount end + def clear + @items = [] + end + private def valid_item?(item) diff --git a/tests.rb b/tests.rb index 3f5b8d5..db7e68f 100644 --- a/tests.rb +++ b/tests.rb @@ -35,6 +35,19 @@ class TestCheckout < Minitest::Test assert_equal 0.00, @checkout.total 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 def test_that_bogof_applied