Sha256: fa9499cc02ab5ea16cbc6197aebddb5c86478682a1e009db54e5d8cbcfc9f259

Contents?: true

Size: 948 Bytes

Versions: 11

Compression:

Stored size: 948 Bytes

Contents

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

describe ActiveRecord::Acts::ShoppingCartItem::InstanceMethods do
  let(:klass) do
    klass = Class.new
    klass.send :include, ActiveRecord::Acts::ShoppingCartItem::InstanceMethods
    klass
  end

  let(:subject) do
    subject = klass.new
    subject.stub(:save => true)
    subject
  end

  describe :subtotal do
    it "returns the quantity * price" do
      subject.stub(:quantity => 2, :price => 33.99)
      subject.subtotal.should eq(67.98)
    end
  end

  describe :update_quantity do
    it "updates the item quantity" do
      subject.should_receive(:quantity=).with(5)
      subject.should_receive(:save)
      subject.update_quantity(5)
    end
  end

  describe :update_price do
    it "updates the item price" do
      subject.should_receive(:price=).with(55.99)
      subject.should_receive(:save)
      subject.update_price(55.99)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
acts_as_shopping_cart-0.3.0 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.2.2 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.2.1 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.2.0 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.6 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.5 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.4 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.3 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.2 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.1 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb
acts_as_shopping_cart-0.1.0 spec/active_record/acts/shopping_cart_item/instance_methods_spec.rb