diff options
| -rw-r--r-- | spec/spec_helper.rb | 2 | ||||
| -rw-r--r-- | spec/unit/customer_spec.rb | 28 |
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 |
