require File.dirname(__FILE__) + '/helper' describe Frank::Render do include Rack::Test::Methods def app proj_dir = File.join(File.dirname(__FILE__), 'template') settings = YAML.load_file(File.join(proj_dir, 'settings.yml')) Frank.new do settings.each do |name, value| set name.to_s, value end set :environment, :test set :proj_dir, proj_dir end end before(:all) do @app = app end it 'renders a template using layout' do template = @app.render('index.haml') template.should == "
/
\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 == "
/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

hello worlds

\n

/

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

hello worlds

\n

hello from partial

\n
\n" end it 'renders sass template' do template = @app.render('sass.sass') template.should == "#hello-worlds {\n background: red; }\n" end it 'renders coffee template' do template = @app.render('coffee.coffee') template.should == "(function(){\n var greeting;\n greeting = \"Hello CoffeeScript\";\n})();" end it 'renders erb template' do template = @app.render('erb.erb') template.should == "

hello worlds

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

hello worlds

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

hello worlds

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

hello worlds

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

hello worlds

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

hello worlds

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