# encoding: utf-8
require 'spec_helper'
require 'spec_config_helper'
require 'sinatra/classy_assets'
class ClassySinatraApp < Sinatra::Base
register Sinatra::ClassyAssets
get "/stylesheet_tag" do
slim :stylesheet_tag
end
get "/stylesheet_tag_media" do
slim :stylesheet_tag_media
end
get "/javascript_tag" do
slim :javascript_tag
end
template :index do
"| Classy Assets"
end
template :layout do
"html\n\tbody\n\t\t==yield\n"
end
template :stylesheet_tag do
"==stylesheet_tag('application')"
end
template :stylesheet_tag_media do
"==stylesheet_tag('application', media: 'print')"
end
template :javascript_tag do
"==javascript_tag('application')"
end
end
def app
ClassySinatraApp.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 "/stylesheet_tag"
last_response.body.must_match(//)
end
it "outputs the stylesheet tag with the correct media attribute" do
get "/stylesheet_tag_media"
last_response.body.must_match(//)
end
it "outputs a javascript tag" do
get "/javascript_tag"
last_response.body.must_match(/