require File.dirname(__FILE__) + '/spec_helper' describe Frank::Render do include Rack::Test::Methods def app Frank.bootstrap(File.join(File.dirname(__FILE__), 'template')) Frank.new end before(:all) do @app = app end it 'renders a template using layout' do template = @app.render('index.haml') template.should == "\n
/
\n
\n

hello worlds

\n

/

\n
\n" end it 'renders a template using layout2' do template = @app.render('layout2_test.haml') template.should == "
\n

hi inside layout2

\n
\n" end it 'renders a markdown template inside haml layout' do template = @app.render('markdown_in_haml.md') template.should == "\n
/markdown_in_haml
\n
\n

hi inside layout

\n
\n" end it 'renders a nested template with a nested layout' do template = @app.render('/nested/child.haml') template.should == "
\n

hello from child

\n
\n" end it 'renders a deeply nested template with a nested layout' do template = @app.render('/nested/deeper/deep.haml') template.should == "
\n

really deep

\n
\n" end it 'renders a haml template with no layout' do template = @app.render('no_layout.haml') template.should == "

i have no layout

\n" end it 'renders haml template' do template = @app.render('index.haml') template.should == "\n
/
\n
\n

hello worlds

\n

/

\n
\n" end it 'renders haml template with a haml partial' do template = @app.render('partial_test.haml') template.should == "\n
/partial_test
\n
\n

hello worlds

\n

/partial_test

\n

hello from partial

\n
\n" end it 'renders a partial with locals' do template = @app.render('partial_locals_test.haml') template.should == "\n
/partial_locals_test
\n
\n

hello worlds

\n

/partial_locals_test

\n

hello from local

\n
\n" end it 'renders less template' do template = @app.render('stylesheets/less.less') template.should include("#hello-worlds { background: red; }") end it 'renders sass template' do template = @app.render('stylesheets/sass.sass') template.should include("#hello-worlds {\n background: red;\n}\n") end it 'renders sass with compass reset' do template = @app.render('stylesheets/sass_with_compass.sass') template.should include("h1, h2, h3, h4, h5, h6, p, blockquote, pre,\n") end it 'renders scss with compass mixin' do template = @app.render('stylesheets/scss_with_compass.scss') template.should include("-moz-border-radius: 5px;\n") template.should include("-webkit-border-radius: 5px;\n") template.should include("border-radius: 5px;\n") end it 'renders coffee template' do template = @app.render('coffee.coffee') template.should == "(function() {\n ({\n greeting: \"Hello CoffeeScript\"\n });\n}).call(this);\n" end it 'renders erb template' do template = @app.render('erb.erb') template.should == "\n
/erb
\n
\n

hello worlds

\n
\n" end it 'renders redcloth template' do template = @app.render('redcloth.textile') template.should == "\n
/redcloth
\n
\n

hello worlds

\n
\n" end it 'renders rdiscount template' do template = @app.render('markdown.md') template.should == "\n
/markdown
\n
\n

hello worlds

\n
\n" end it 'renders liquid template' do template = @app.render('liquid.liquid') template.should == "\n
/liquid
\n
\n

hello worlds

\n
\n" end it 'renders builder template' do template = @app.render('builder.builder') template.should == "\n
/builder
\n
\n

hello worlds

\n
\n" end it 'raise template error' do lambda { @app.render('not_a.template') }.should raise_error(Frank::TemplateError) end end