mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add test to make custom renderer macros for projects.
Add documentation
This commit is contained in:
parent
7b85aa2b45
commit
2d4edc83dc
2 changed files with 56 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
|||
require "./spec_helper"
|
||||
|
||||
macro render_with_base_and_layout(filename)
|
||||
render "spec/asset/#{{{filename}}}", "spec/asset/layout.ecr"
|
||||
end
|
||||
|
||||
describe "Views" do
|
||||
it "renders file" do
|
||||
kemal = Kemal::Handler.new
|
||||
|
@ -11,6 +15,16 @@ describe "Views" do
|
|||
response.body.should contain("Hello world")
|
||||
end
|
||||
|
||||
it "renders file with dynamic variables" do
|
||||
kemal = Kemal::Handler.new
|
||||
kemal.add_route "GET", "/view/:name" do |env|
|
||||
render_with_base_and_layout "hello.ecr"
|
||||
end
|
||||
request = HTTP::Request.new("GET", "/view/world")
|
||||
response = kemal.call(request)
|
||||
response.body.should contain("Hello world")
|
||||
end
|
||||
|
||||
it "renders layout" do
|
||||
kemal = Kemal::Handler.new
|
||||
kemal.add_route "GET", "/view/:name" do |env|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue