Sha256: e148807bd20b6a730d4fa3a42895cfa7c28032c8577355ed003129f1aefda6d5

Contents?: true

Size: 1.89 KB

Versions: 18

Compression:

Stored size: 1.89 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'sinatra/classy_assets'

class ClassySinatraApp < Sinatra::Base
  use Rack::ClassyAssets
  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
  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 "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(/<link href="\/assets\/application.css" media="screen" rel="stylesheet">/)
    end

    it "outputs the stylesheet tag with the correct media attribute" do
      get "/stylesheet_tag_media"
      last_response.body.must_match(/<link href="\/assets\/application.css" media="print" rel="stylesheet">/)
    end

    it "outputs a javascript tag" do
      get "/javascript_tag"
      last_response.body.must_match(/<script src="\/assets\/application.js"><\/script>/)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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