Sha256: e1a759f1ab735faf1ed66ccc9074e0502b26e8f4566bde0fe85043dd2e3dcdfa

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

class TestComposite
  include Trackman::Assets::CompositeAsset
  
  def path 
    'parent'
  end

  def asset_from(virtual, physical)
    TestAsset.new(:virtual_path => virtual.dup, :path => translate(physical, self.path))  
  end
end

class TestAsset < Trackman::Assets::Asset
  def validate_path?
    false
  end    
end

describe Trackman::Assets::CompositeAsset do
  before :each do
    @composite = TestComposite.new
  end
  
  it "has children" do
    asset = Asset.create(:path => 'spec/test_data/css/with-asset.css')
    asset.assets.should == [Asset.create(:path => 'spec/test_data/css/imported.css', :virtual_path => 'imported.css')] 
  end

  it "removes the translated assets that are nil" do
    def @composite.children_paths 
      ['a', 'b', 'c']
    end
    def @composite.translate(url, parent_url)
      return nil if url == 'b'
      url
    end
    
    expected = ['a', 'c'].map{|p| TestAsset.new(:virtual_path => p, :path => p)}
    @composite.assets.should == expected
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trackman-0.6.18 spec/composite_asset_spec.rb
trackman-0.6.17 spec/composite_asset_spec.rb
trackman-0.6.16 spec/composite_asset_spec.rb
trackman-0.6.15 spec/composite_asset_spec.rb
trackman-0.6.14 spec/composite_asset_spec.rb
trackman-0.6.13 spec/composite_asset_spec.rb
trackman-0.6.12 spec/composite_asset_spec.rb
trackman-0.6.11 spec/composite_asset_spec.rb
trackman-0.6.10 spec/composite_asset_spec.rb