require "./spec_helper" macro render_with_base_and_layout(filename) render "#{__DIR__}/asset/#{{{filename}}}", "#{__DIR__}/asset/layout.ecr" end describe "Views" do it "renders file" do get "/view/:name" do |env| name = env.params.url["name"] render "#{__DIR__}/asset/hello.ecr" end request = HTTP::Request.new("GET", "/view/world") client_response = call_request_on_app(request) client_response.body.should contain("Hello world") end it "renders file with dynamic variables" do get "/view/:name" do |env| name = env.params.url["name"] render_with_base_and_layout "hello.ecr" end request = HTTP::Request.new("GET", "/view/world") client_response = call_request_on_app(request) client_response.body.strip.should eq("
Hello world\n