# 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