Skip to content

Instantly share code, notes, and snippets.

@theRealNG
Created February 1, 2024 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theRealNG/59d51b0d3a921a347bdc57da97178a2d to your computer and use it in GitHub Desktop.
Save theRealNG/59d51b0d3a921a347bdc57da97178a2d to your computer and use it in GitHub Desktop.
Shopping Cart Test case using MiniTests
class ShoppingCartTest < MiniTest::Test
def setup
@cart = ShoppingCart.new
end
def test_calculates_total_price_with_taxes
item = Item.new("Apple", 10.00)
# Stubbing the add_item method
@cart.stub(:add_item, nil) do
@cart.add_item(item)
assert_equal 11.50, @cart.total_price_with_taxes
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment