summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-04-29 16:42:13 -0600
committermo khan <mo@mokhan.ca>2013-04-29 16:42:13 -0600
commitf0f0a26ed30a4fcb8f469720f88975c3b817521b (patch)
treea116285a26b7ea758519faac9fc8031f710a250b
parenta20e73ab895f3ea7aef2e19671dbc85a546cb2ed (diff)
move cart to a separate file
-rw-r--r--lib/cart.rb19
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/unit/cart_spec.rb20
3 files changed, 20 insertions, 20 deletions
diff --git a/lib/cart.rb b/lib/cart.rb
new file mode 100644
index 0000000..a855e23
--- /dev/null
+++ b/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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fe6867d..7742723 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,5 @@
require 'rspec'
require 'rspec-fakes'
+require_relative '../lib/cart.rb'
require_relative '../lib/customer.rb'
diff --git a/spec/unit/cart_spec.rb b/spec/unit/cart_spec.rb
index 80809f6..048c813 100644
--- a/spec/unit/cart_spec.rb
+++ b/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 }