Sha256: 569361e153c857048ffedfa7d4aa27118f586cfbebb1a06d1eef15276547a30e

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

require 'spec/spec_helper'

describe ShopPacking do
  
  dataset :shop_packages
  
  before(:each) do
    @packing  = shop_packings(:warm_bread)
  end
  
  describe 'attributes' do
    
    it 'should have a quantity' do
      @packing.quantity.should == 1
    end
    
    it 'should have a position' do
      @packing.position.should == 1
    end
    
    it 'should have a package' do
      @packing.package.class.should == ShopPackage
    end
    
    it 'should have a product' do
      @packing.product.class.should == ShopProduct
    end
    
  end
  
  context 'instance methods' do
  
    describe '#value' do
    
      it 'should return the quantity multiplied by the product price' do
        @packing.value.should === @packing.quantity * @packing.product.price.to_f
      end
    
    end
    
  end
  
  context 'Class Methods' do
    
    describe '#set_quantity' do
      it 'should return the highest of 1 or the quantity' do
        @packing.quantity = 0
        @packing.save
        @packing.quantity.should === 1
        
        @packing.quantity = 1
        @packing.save
        @packing.quantity.should === 1
        
        @packing.quantity = -1
        @packing.save
        @packing.quantity.should === 1
        
        @packing.quantity = 2
        @packing.save
        @packing.quantity.should === 2
      end
    end
    
  end
  
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
radiant-shop_packages-extension-0.0.6 spec/models/shop_packing_spec.rb
radiant-shop_packages-extension-0.0.5 spec/models/shop_packing_spec.rb
radiant-shop_packages-extension-0.0.4 spec/models/shop_packing_spec.rb
radiant-shop_packages-extension-0.0.3 spec/models/shop_packing_spec.rb
radiant-shop_packages-extension-0.0.2 spec/models/shop_packing_spec.rb
radiant-shop_packages-extension-0.0.1 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.6 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.5 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.4 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.3 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.1 spec/models/shop_packing_spec.rb
radiant-shop-extension-0.11.0 spec/models/shop_packing_spec.rb