summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-04-29 16:19:36 -0600
committermo khan <mo@mokhan.ca>2013-04-29 16:19:36 -0600
commit9587dd0f2ae8629aa127766523ea58b1586d9233 (patch)
tree1c82a286fa2400a6ab71ac7204e8827608c5277d
parentdcfe406f1a844a46f831858c66ac721e06850c8a (diff)
create customer
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/unit/customer_spec.rb28
2 files changed, 30 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..3112ee0
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,2 @@
+require 'rspec'
+require 'rspec-fakes'
diff --git a/spec/unit/customer_spec.rb b/spec/unit/customer_spec.rb
new file mode 100644
index 0000000..03a567e
--- /dev/null
+++ b/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