require File.expand_path('../test_helper', __FILE__) describe Renee::Render do describe "#render" do after { remove_views } it "should allow rendering string with engine" do mock_app { path("/a") { get { inline! "
test
", :erb } } path("/b") { get { inline! "<%= foo %>
", :erb, :locals => { :foo => "bar" } } } path("/c") { get { halt inline("<%= foo %>
", :erb, :locals => { :foo => "bar" }) } } } get('/a') assert_equal 200, response.status assert_equal "test
", response.body get('/b') assert_equal 200, response.status assert_equal "bar
", response.body get('/c') assert_equal 200, response.status assert_equal "bar
", response.body end # string, with engine it "should allow rendering template file with engine" do create_view :index, "%p test", :haml create_view :foo, "%p= foo", :haml mock_app { path("/a") { get { render! 'index', :haml } } path("/b") { get { render! 'foo', :haml, :locals => { :foo => "bar" } } } path("/c") { get { halt render('foo', :haml, :locals => { :foo => "bar" }) } } } get('/a') assert_equal 200, response.status assert_equal "test
\n", response.body get('/b') assert_equal 200, response.status assert_equal "bar
\n", response.body get('/c') assert_equal 200, response.status assert_equal "bar
\n", response.body end # template, with engine it "should allow rendering template file with unspecified engine" do create_view :index, "%p test", :haml create_view :foo, "%p= foo", :haml mock_app { path("/a") { get { render! "index" } } path("/b") { get { render! "foo.haml", :locals => { :foo => "bar" } } } } get('/a') assert_equal 200, response.status assert_equal "test
\n", response.body get('/b') assert_equal 200, response.status assert_equal "bar
\n", response.body end # template, unspecified engine it "should allow rendering template file with engine and layout" do create_view :index, "%p test", :haml create_view :foo, "%p= foo", :haml create_view :layout, "%div.wrapper= yield", :haml mock_app { path("/a") { get { render! 'index', :haml, :layout => :layout } } path("/b") { get { render! 'foo', :layout => :layout, :locals => { :foo => "bar" } } } } get('/a') assert_equal 200, response.status assert_equal %Q{test
bar
test
\nbar
\n