Sha256: 8f0794fbb0aeb083e62777f87b6f96526b2ce56610e9bef0905cb379e2eb933c

Contents?: true

Size: 1.72 KB

Versions: 27

Compression:

Stored size: 1.72 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'classy_assets'

describe ClassyAssets do
  before do
    ClassyAssets.config do |config|
      config.asset_root = File.expand_path('../support', __FILE__)
      config.asset_debug = false
      config.asset_digest = false
      config.asset_host = nil
      config.asset_paths = Dir.glob(File.join(config.asset_root, config.asset_prefix, '*'))
    end
  end

  context "default configuration" do
    it "returns the url to the asset" do
      asset_url = ClassyAssets.asset_url_for 'application.js'
      asset_url.must_equal '/assets/application.js'
    end
  end

  context "debug mode" do
    before do
      ClassyAssets.config.asset_debug = true
    end

    after do
      ClassyAssets.config.asset_debug = false
    end

    it "returns the debug url to the asset" do
      asset_url = ClassyAssets.asset_url_for 'application.js'
      asset_url.must_equal '/assets/application.js?body=1'
    end
  end

  context "digest" do
    before do
      ClassyAssets.config.asset_digest = true
      @digest = ClassyAssets.sprockets.digest
    end

    after do
      ClassyAssets.config.asset_digest = false
    end

    it "returns the digest url to the asset" do
      asset_url = ClassyAssets.asset_url_for 'application.js'
      asset_url.must_equal "/assets/#{ClassyAssets.sprockets['application.js'].digest_path}"
    end
  end

  context "asset host" do
    before do
      ClassyAssets.config.asset_host = 'http://example.com'
    end

    after do
      ClassyAssets.config.asset_host = nil 
    end

    it "returns the digest url to the asset" do
      asset_url = ClassyAssets.asset_url_for 'application.js'
      asset_url.must_equal "http://example.com/assets/application.js"
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
classy_assets-0.14.5 spec/classy_assets_spec.rb
classy_assets-0.14.4 spec/classy_assets_spec.rb
classy_assets-0.14.2 spec/classy_assets_spec.rb
classy_assets-0.14.1 spec/classy_assets_spec.rb
classy_assets-0.14.0 spec/classy_assets_spec.rb
classy_assets-0.13.0 spec/classy_assets_spec.rb
classy_assets-0.12.0 spec/classy_assets_spec.rb
classy_assets-0.11.4 spec/classy_assets_spec.rb
classy_assets-0.11.3 spec/classy_assets_spec.rb
classy_assets-0.11.2 spec/classy_assets_spec.rb
classy_assets-0.11.1 spec/classy_assets_spec.rb
classy_assets-0.11.0 spec/classy_assets_spec.rb
classy_assets-0.10.0 spec/classy_assets_spec.rb
classy_assets-0.9.4 spec/classy_assets_spec.rb
classy_assets-0.9.3 spec/classy_assets_spec.rb
classy_assets-0.9.2 spec/classy_assets_spec.rb
classy_assets-0.9.1 spec/classy_assets_spec.rb
classy_assets-0.9.0 spec/classy_assets_spec.rb
classy_assets-0.8.2 spec/classy_assets_spec.rb
classy_assets-0.8.1 spec/classy_assets_spec.rb