Sha256: dc77a0379a2ffddddfd9f8e00dc0b7cff77537e3ac7c109ae71642bf1201e933

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Trackman::Assets::Components::AssetFactory do
  class TestFactory
    extend Trackman::Assets::Components::AssetFactory
  end
  
  before :all do
    class Trackman::Assets::Asset
      def validate_path?
        false
      end
    end
  end  
  after :each do
    begin
      Object.send(:remove_const, :Rails)
    rescue
    end
  end
  after :all do
    class Trackman::Assets::Asset
      def validate_path?
        true
      end
    end
  end

  it "returns an HtmlAsset" do
    asset = TestFactory.create(:path => 'spec/test_data/sample.html')
    
    asset.should be_a_kind_of HtmlAsset
  end


  it "returns a Rails32 when asset pipeline is configured to be used" do  
    module Rails
      def self.application
        Rails::App.new
      end
      
      class App
        def assets
          Rails::Assets.new
        end
        def config
          Rails::Config.new
        end
      end

      class Config
        def assets
          Rails::Assets.new
        end 
      end

      class Assets
        def enabled
          true
        end
      end
    end
    
    TestFactory.asset_pipeline_enabled?.should be_true
  end

  it "returns a normal asset if asset pipepeline is not defined or not used" do

    TestFactory.asset_pipeline_enabled?.should be_false
    asset = TestFactory.create(:path => 'x.css')
    asset.should_not be_a_kind_of Rails32PathResolver 
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
trackman-0.5.4 spec/asset_factory_spec.rb
trackman-0.5.3 spec/asset_factory_spec.rb
trackman-0.5.2 spec/asset_factory_spec.rb
trackman-0.5.1 spec/asset_factory_spec.rb
trackman-0.5.0 spec/asset_factory_spec.rb
trackman-0.4.8 spec/asset_factory_spec.rb
trackman-0.4.7 spec/asset_factory_spec.rb
trackman-0.4.6 spec/asset_factory_spec.rb
trackman-0.4.5 spec/asset_factory_spec.rb
trackman-0.4.4 spec/asset_factory_spec.rb
trackman-0.4.3 spec/asset_factory_spec.rb