1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/compat/sass_test.rb
Ryan Tomayko 49adaa5362 Sane template options [#191]
* The options hash now takes the :views, :layout, and :locals
  options but also any template-specific options. The generic
  options are removed before calling the template specific render
  method.

* The haml ":options" and ":haml" options are deprecated. These
  should be merged in directly with the options hash.

* The sass ":sass" option is deprecated. Merge directly with the
  options hash instead.

* All template engines have an app-level option named the same as
  their engine (erb, haml, sass, etc.). This must be a hash and is
  merged with the options passed to the render method.

* The :views_directory option is deprecated; renamed :views.
2009-03-31 01:58:47 -07:00

67 lines
1.5 KiB
Ruby

require File.dirname(__FILE__) + '/helper'
context "Sass" do
setup do
Sinatra.application = nil
end
context "Templates (in general)" do
setup do
Sinatra.application = nil
end
specify "are read from files if Symbols" do
get '/from_file' do
sass :foo, :views_directory => File.dirname(__FILE__) + "/views"
end
get_it '/from_file'
should.be.ok
body.should.equal "#sass {\n background_color: #FFF; }\n"
end
specify "raise an error if template not found" do
get '/' do
sass :not_found
end
lambda { get_it '/' }.should.raise(Errno::ENOENT)
end
specify "ignore default layout file with .sass extension" do
get '/' do
sass :foo, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
end
get_it '/'
should.be.ok
body.should.equal "#sass {\n background_color: #FFF; }\n"
end
specify "ignore explicitly specified layout file" do
get '/' do
sass :foo, :layout => :layout, :views_directory => File.dirname(__FILE__) + "/views/layout_test"
end
get_it '/'
should.be.ok
body.should.equal "#sass {\n background_color: #FFF; }\n"
end
it "passes :sass option to the Sass engine" do
get '/' do
sass "#sass\n :background-color #FFF\n :color #000\n", :sass => {:style => :compact}
end
get_it '/'
should.be.ok
body.should.equal "#sass { background-color: #FFF; color: #000; }\n"
end
end
end