Sha256: 5315ca620032f60e4e814cec57e9e84728b5c2700aa054eb37b935ef93fa12ff

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '../../../../spec_helper')

describe "ShoppingCart" do
  before(:each) do
    @cart = SomeCart.create
    @cart.add(SomeClass.create, 100, 3)
    @cart.add(SomeClass.create, 200, 6)
    @cart.add(SomeClass.create, 300, 9)
  end

  describe :subtotal do
    it "returns the quantity times the price for the specicfied object" do
      @cart.cart_items[0].subtotal.should == (100 * 3)
      @cart.cart_items[1].subtotal.should == (200 * 6)
      @cart.cart_items[2].subtotal.should == (300 * 9)
    end
  end

  describe :update_quantity do
    before(:each) do
      @cart.cart_items[0].update_quantity(6)
      @cart.cart_items[1].update_quantity(9)
      @cart.cart_items[2].update_quantity(12)
    end
    
    it "returns the quantity of the specified object" do
      @cart.cart_items[0].quantity.should == (6)
      @cart.cart_items[1].quantity.should == (9)
      @cart.cart_items[2].quantity.should == (12)
    end
  end  
  
  describe :update_price do
    before(:each) do
      @cart.cart_items[0].update_price(50)
      @cart.cart_items[1].update_price(100)
      @cart.cart_items[2].update_price(150)
    end
    
    it "returns the quantity of the specified object" do
      @cart.cart_items[0].price.should == (50)
      @cart.cart_items[1].price.should == (100)
      @cart.cart_items[2].price.should == (150)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_shopping_cart-0.0.3 spec/active_record/acts/shopping_cart/cart_item_instance_methods_spec.rb
acts_as_shopping_cart-0.0.2 spec/active_record/acts/shopping_cart/cart_item_instance_methods_spec.rb
acts_as_shopping_cart-0.0.1 spec/active_record/acts/shopping_cart/cart_item_instance_methods_spec.rb