Sha256: 7e1e8753459b08f1640107b37a64cbc54a4229b43a3cbb0156c60470ab71fc5f

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

require 'spec/spec_helper'

describe ShopVariants::Tags::Helpers do
  
  dataset :pages, :tags, :shop_products, :shop_product_variants
  
  before :all do
    @page = pages(:home)
  end
  
  before(:each) do
    mock_valid_tag_for_helper
  end
  
  describe '#current_product_variants' do
    before :each do
      @product = shop_products(:crusty_bread)
    end
  
    context 'existing product variant' do
      it 'should return that existing line item' do
        @tag.locals.shop_product = @product
      
        result = ShopVariants::Tags::Helpers.current_product_variants(@tag)
        result.should == @product.variants
      end
    end
  
    context 'nothing sent or available' do
      it 'should return nil' do
        result = ShopVariants::Tags::Helpers.current_product_variants(@tag)
        result.should be_nil
      end
    end
  end

  describe '#current_product_variant' do
    before :each do
      @variant = shop_product_variants(:mouldy_crusty_bread)
    end
  
    context 'existing product variant' do
      it 'should return that existing variant' do
        @tag.locals.shop_product_variant = @variant
      
        result = ShopVariants::Tags::Helpers.current_product_variant(@tag)
        result.should == @variant
      end
    end
  
    context 'nothing sent or available' do
      it 'should return nil' do
        result = ShopVariants::Tags::Helpers.current_product_variant(@tag)
        result.should be_nil
      end
    end
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radiant-shop_variants-extension-0.1.3 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.1.2 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.1.1 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.1.0 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.0.4 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.0.3 spec/lib/shop_variants/tags/helpers_spec.rb
radiant-shop_variants-extension-0.0.1 spec/lib/shop_variants/tags/helpers_spec.rb