2008-03-28 17:33:26 -04:00
|
|
|
require File.dirname(__FILE__) + '/helper'
|
|
|
|
|
|
|
|
context "Rendering in file templates" do
|
|
|
|
|
|
|
|
setup do
|
|
|
|
Sinatra.application = nil
|
|
|
|
use_in_file_templates!
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
specify "should set template" do
|
|
|
|
assert Sinatra.application.templates[:foo]
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
specify "should set layout" do
|
|
|
|
assert Sinatra.application.templates[:layout]
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
specify "should render without layout if specified" do
|
|
|
|
get '/' do
|
|
|
|
haml :foo, :layout => false
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
get_it '/'
|
|
|
|
assert_equal "this is foo\n", body
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
specify "should render with layout if specified" do
|
|
|
|
get '/' do
|
|
|
|
haml :foo
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
get_it '/'
|
|
|
|
assert_equal "X\nthis is foo\nX\n", body
|
|
|
|
end
|
2008-08-31 03:39:26 -04:00
|
|
|
|
2008-03-28 17:33:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
__END__
|
|
|
|
|
2008-04-26 23:03:12 -04:00
|
|
|
@@ foo
|
2008-03-28 17:33:26 -04:00
|
|
|
this is foo
|
|
|
|
|
2008-04-26 23:03:12 -04:00
|
|
|
@@ layout
|
2008-03-28 17:33:26 -04:00
|
|
|
X
|
|
|
|
= yield
|
|
|
|
X
|
|
|
|
|