Commit f0f0a26

mo khan <mo@mokhan.ca>
2013-04-29 22:42:13
move cart to a separate file
1 parent a20e73a
Changed files (3)
lib/cart.rb
@@ -0,0 +1,19 @@
+class Cart
+  def initialize(items = [])
+    @items = items
+  end
+
+  def add(product)
+    @items.push(product)
+  end
+
+  def includes?(product)
+    @items.include?(product)
+  end
+
+  def quantity_of(product)
+    @items.find_all do |item|
+      item == product
+    end.count
+  end
+end
spec/unit/cart_spec.rb
@@ -1,25 +1,5 @@
 require "spec_helper"
 
-class Cart
-  def initialize(items = [])
-    @items = items
-  end
-
-  def add(product)
-    @items.push(product)
-  end
-
-  def includes?(product)
-    @items.include?(product)
-  end
-
-  def quantity_of(product)
-    @items.find_all do |item|
-      item == product
-    end.count
-  end
-end
-
 describe Cart do
   let(:sut) { Cart.new }
 
spec/spec_helper.rb
@@ -1,4 +1,5 @@
 require 'rspec'
 require 'rspec-fakes'
 
+require_relative '../lib/cart.rb'
 require_relative '../lib/customer.rb'