mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Better view_specs for layout variables
This commit is contained in:
parent
e6e70fe222
commit
24e0824a9b
3 changed files with 29 additions and 4 deletions
|
@ -1,3 +1,6 @@
|
|||
<html><%= content %></html>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<%= content %>
|
||||
<%= yield_content "custom" %>
|
||||
</body>
|
||||
</html>
|
8
spec/asset/layout_with_yield_and_vars.ecr
Normal file
8
spec/asset/layout_with_yield_and_vars.ecr
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
<%= content %>
|
||||
<%= yield_content "custom" %>
|
||||
<%= var1 %>
|
||||
<%= var2 %>
|
||||
</body>
|
||||
</html>
|
|
@ -35,6 +35,20 @@ describe "Views" do
|
|||
client_response.body.should contain("<html>Hello world")
|
||||
end
|
||||
|
||||
it "renders layout with variables" do
|
||||
get "/view/:name" do |env|
|
||||
name = env.params.url["name"]
|
||||
var1 = "serdar"
|
||||
var2 = "kemal"
|
||||
render "spec/asset/hello_with_content_for.ecr", "spec/asset/layout_with_yield_and_vars.ecr"
|
||||
end
|
||||
request = HTTP::Request.new("GET", "/view/world")
|
||||
client_response = call_request_on_app(request)
|
||||
client_response.body.should contain("Hello world")
|
||||
client_response.body.should contain("serdar")
|
||||
client_response.body.should contain("kemal")
|
||||
end
|
||||
|
||||
it "renders layout with content_for" do
|
||||
get "/view/:name" do |env|
|
||||
name = env.params.url["name"]
|
||||
|
@ -42,7 +56,7 @@ describe "Views" do
|
|||
end
|
||||
request = HTTP::Request.new("GET", "/view/world")
|
||||
client_response = call_request_on_app(request)
|
||||
client_response.body.should contain("<html>Hello world")
|
||||
client_response.body.should contain("Hello world")
|
||||
client_response.body.should contain("<h1>Hello from otherside</h1>")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue