Sha256: 2f1c875ba64ddbf8fd81f4d80f31cb30aeb3c03f834a335f7dfa38af5e6d524a

Contents?: true

Size: 1012 Bytes

Versions: 8

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'

class TestComposite
  include Trackman::Assets::Components::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::Components::CompositeAsset do
  before :each do
    @composite = TestComposite.new
  end
  it "has children" do
    asset = CssAsset.new(:path => 'spec/test_data/css/with-asset.css')
    asset.assets.should == [CssAsset.new(:path => 'spec/test_data/css/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

8 entries across 8 versions & 1 rubygems

Version Path
trackman-0.4.2 spec/composite_asset_spec.rb
trackman-0.4.1 spec/composite_asset_spec.rb
trackman-0.4.0 spec/composite_asset_spec.rb
trackman-0.3.5 spec/composite_asset_spec.rb
trackman-0.3.4 spec/composite_asset_spec.rb
trackman-0.3.2 spec/composite_asset_spec.rb
trackman-0.3.1 spec/composite_asset_spec.rb
trackman-0.3.0 spec/composite_asset_spec.rb