Add Shop class to keep track of available products
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
require "minitest/autorun"
|
||||
|
||||
require "shop.rb"
|
||||
require "product.rb"
|
||||
|
||||
class ShopTest < Minitest::Test
|
||||
def setup
|
||||
@shop = Shop.new
|
||||
end
|
||||
|
||||
def test_adding_a_product
|
||||
pico = Product.new(id: 'PICO2', price: 4.00)
|
||||
@shop.add_product(pico)
|
||||
|
||||
assert_equal [pico], @shop.products
|
||||
end
|
||||
|
||||
def test_duplicate_product_id_raises_an_error
|
||||
@shop.add_product(Product.new(id: 'PICO2'))
|
||||
|
||||
assert_raises Shop::DuplicateProductIdError do
|
||||
@shop.add_product(Product.new(id: 'PICO2'))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user