test/render.rb in cuba-3.1.1 vs test/render.rb in cuba-3.2.0
- old
+ new
@@ -26,10 +26,14 @@
end
on "about" do
res.write partial("about", title: "About Cuba")
end
+
+ on "render" do
+ render("about", title: "About Cuba")
+ end
end
end
test "partial" do
_, _, body = Cuba.call({ "PATH_INFO" => "/about", "SCRIPT_NAME" => "/" })
@@ -41,10 +45,16 @@
_, _, body = Cuba.call({ "PATH_INFO" => "/home", "SCRIPT_NAME" => "/" })
assert_response body, ["<title>Cuba: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>\n"]
end
+ test "render" do
+ _, _, body = Cuba.call({ "PATH_INFO" => "/render", "SCRIPT_NAME" => "/" })
+
+ assert_response body, ["<title>Cuba: About Cuba</title>\n<h1>About Cuba</h1>\n"]
+ end
+
test "partial with str as engine" do
Cuba.settings[:render][:template_engine] = "str"
_, _, body = Cuba.call({ "PATH_INFO" => "/about", "SCRIPT_NAME" => "/" })
@@ -83,25 +93,9 @@
10.times do |i|
_, _, resp = Cuba.call({ "PATH_INFO" => "/foo/#{i}", "SCRIPT_NAME" => "" })
end
assert_equal 1, Thread.current[:_cache].instance_variable_get(:@cache).size
-end
-
-test "simple layout support" do
- Cuba.plugin Cuba::Render
-
- Cuba.define do
- on true do
- res.write render("test/views/layout-yield.erb") {
- render("test/views/content-yield.erb")
- }
- end
- end
-
- _, _, resp = Cuba.call({})
-
- assert_response resp, ["Header\nThis is the actual content.\nFooter\n"]
end
test "overrides layout" do
Cuba.plugin Cuba::Render
Cuba.settings[:render][:views] = "./test/views"