Sha256: 2330fa61bf492290b7e4df592bb35d81f4ceef199209c5455bbe68ca894ff75a
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
require 'rails_helper' RSpec.describe TbCommerce::ProductSku, type: :model do before(:each) do @product = FactoryGirl.create(:tb_commerce_product, :with_options) @set = @product.option_sets.first @sku = FactoryGirl.create(:tb_commerce_product_sku, :product => @product, :options => [@set.options.first]) end describe '#description' do it 'should return the parent product description' do expect(@sku.description).to eq(@product.description) end end describe '#price' do it 'should return the base price' do expect(@sku.price).to eq(@product.price) end it 'should return the base price plus additional price' do @sku.add_price = 1.99 expect(@sku.price).to eq(@product.price + @sku.add_price) end end describe '.with_option_ids' do it 'should return the sku' do result = TbCommerce::ProductSku.with_option_ids([@set.option_ids.first]) expect(result.first).to eq(@sku) end it 'should not return the sku' do result = TbCommerce::ProductSku.with_option_ids([@set.option_ids.second]) expect(result).to eq([]) end end describe '.has_options?' do it 'should return true' do expect(@sku.has_options?([@set.option_ids.first])).to eq(true) end it 'should return false' do expect(@sku.has_options?([@set.option_ids.second])).to eq(false) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tb_commerce-0.0.4 | spec/models/tb_commerce/product_sku_spec.rb |
tb_commerce-0.0.3 | spec/models/tb_commerce/product_sku_spec.rb |
tb_commerce-0.0.2 | spec/models/tb_commerce/product_sku_spec.rb |