Sha256: 8e0fcfcc34486bc9ab6ae6bc34db39874e07a9ea7696a1238d1aad522ae2d575
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
require 'spec/spec_helper' describe ShopLineItem do dataset :shop_line_items, :shop_products it 'should calculate a weight' do shop_line_items(:one).weight.should === (shop_line_items(:one).item.weight * shop_line_items(:one).quantity).to_f shop_line_items(:two).weight.should === (shop_line_items(:two).item.weight * shop_line_items(:two).quantity).to_f end it 'should calculate the price' do shop_line_items(:one).price.should === (shop_line_items(:one).item.price * shop_line_items(:one).quantity).to_f shop_line_items(:two).price.should === (shop_line_items(:two).item.price * shop_line_items(:two).quantity).to_f end it 'should have a set of standard parameters' do ShopLineItem.params.should === [ :id, :quantity ] end it 'should adjust quantity to 1 if less than' do s = ShopLineItem.new({ :item => shop_products(:crusty_bread), :quantity => 0 }) s.valid? s.quantity.should === 1 s = ShopLineItem.new({ :item => shop_products(:crusty_bread), :quantity => 1 }) s.valid? s.quantity.should === 1 s = ShopLineItem.new({ :item => shop_products(:crusty_bread), :quantity => -100 }) s.valid? s.quantity.should === 1 s = ShopLineItem.new({ :item => shop_products(:crusty_bread), :quantity => 100 }) s.valid? s.quantity.should === 100 end end
Version data entries
5 entries across 5 versions & 1 rubygems