summaryrefslogtreecommitdiff
path: root/spec/unit/cart_spec.rb
blob: 048c813dcbeaeb35ce429a80a4b96bcf74a1bcac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "spec_helper"

describe Cart do
  let(:sut) { Cart.new }

  context "when there are no items in the cart"  do
    let(:product) { fake }
    let(:result) { sut.includes?(product) }

    it "should return false" do
      result.should be_false
    end
  end

  context "when adding a product" do
    let(:product) { fake }

    let(:result) do
      sut.add(product)
      sut.quantity_of(product)
    end

    it "should increase the quanity of that product" do
      result.should == 1
    end
  end

  context "when adding more then one of the same product" do
    let(:product) { fake }

    let(:result) do
      sut.add(product)
      sut.add(product)
      sut.quantity_of(product)
    end
    it "should indicate the total quanity of that product" do
      result.should == 2
    end
  end
end