Last active
February 7, 2024 00:31
-
-
Save theRealNG/a646ca30141c7172e794641e92aaef1d to your computer and use it in GitHub Desktop.
Shopping Cart test cases using RSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rspec" | |
describe "ShoppingCart" do | |
before { @cart = ShoppingCart.new } | |
describe "#total_price_with_taxes" do | |
it "calculates the total price with taxes" do | |
# Mocking external calls | |
allow(TaxCalculator).to receive(:calculate_tax).and_return(1.50) | |
allow(InventoryService).to receive(:check_stock).and_return(true) | |
@cart.add_item(Item.new("Apple", 10.00)) | |
expect(@cart.total_price_with_taxes).to eq(11.50) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment