Commit 9587dd0

mo khan <mo@mokhan.ca>
2013-04-29 22:19:36
create customer
1 parent dcfe406
Changed files (2)
spec/unit/customer_spec.rb
@@ -0,0 +1,28 @@
+require "spec_helper"
+
+class Customer
+  def initialize(cart)
+    @cart = cart
+  end
+
+  def add_to_cart(product)
+    @cart.add(product)
+  end
+end
+
+describe Customer do
+  let(:cart) { fake }
+  let(:sut) { Customer.new(cart) }
+
+  context "when adding an item to the cart" do
+    let(:product) { fake }
+
+    before :each do
+      sut.add_to_cart(product)
+    end
+
+    it "should add it to the cart" do
+      cart.should have_received(:add, product)
+    end
+  end
+end
spec/spec_helper.rb
@@ -0,0 +1,2 @@
+require 'rspec'
+require 'rspec-fakes'