# encoding: utf-8 require 'spec_helper' require 'sinatra/classy_assets' class ClassyApp < Sinatra::Base configure do ClassyAssets::Configuration.configure do |config| config.root_path = File.expand_path('../../support', __FILE__) end end register Sinatra::ClassyAssets get "/with_css" do slim :index, layout: :layout_css end get "/with_media_option" do slim :index, layout: :layout_media end get "/with_js" do slim :index, layout: :layout_js end template :layout_css do "html\n\thead\n\t\t==stylesheet_tag('application')\n\tbody\n\t\t==yield\n" end template :layout_media do "html\n\thead\n\t\t==stylesheet_tag('application', media: 'print')\n\tbody\n\t\t==yield\n" end template :layout_js do "html\n\thead\n\tbody\n\t\t==javascript_tag('application')\n==yield\n" end template :index do "| Classy Assets" end end def app ClassyApp.new end describe Sinatra::ClassyAssets do context "sprockets.context_class" do it "resolves the url to the asset" do get "/assets/application.css" last_response.body.must_match(/background-url: "\/assets\/image.png";/) end end context "Helpers" do it "outputs a stylesheet link tag" do get "/with_css" last_response.body.must_match(//) end it "outputs the stylesheet tag with the correct media attribute" do get "/with_media_option" last_response.body.must_match(//) end it "outputs a javascript tag" do get "/with_js" last_response.body.must_match(/