Sha256: 228f135bd6af534b168fc1d647066505e7111416815b225f0edf7c678bf93e9d

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'classy_assets'

describe ClassyAssets do
  before do
    @root_path = File.expand_path('../support', __FILE__)
    ClassyAssets::Configuration.configure do |config|
      config.root_path = @root_path
    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::Configuration.debug_mode = true
    end

    after do
      ClassyAssets::Configuration.debug_mode = 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::Configuration.asset_digest = true
      @digest = ClassyAssets::Configuration.sprockets.digest
    end

    after do
      ClassyAssets::Configuration.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/application-#{@digest}.js"
    end
  end

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

    after do
      ClassyAssets::Configuration.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

1 entries across 1 versions & 1 rubygems

Version Path
classy_assets-0.4.0 spec/classy_assets_spec.rb