Sha256: 91d55c765c26dd2a18f790db995638a422a58b8e605341303976867ebe0694d0
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
require File.expand_path("helper", File.dirname(__FILE__)) test "executes on true" do Cuba.define do on true do res.write "+1" end end _, _, resp = Cuba.call({}) assert_equal ["+1"], resp.body end test "executes on non-false" do Cuba.define do on "123" do res.write "+1" end end _, _, resp = Cuba.call({ "PATH_INFO" => "/123", "SCRIPT_NAME" => "/" }) assert_equal ["+1"], resp.body end test "restores SCRIPT_NAME and PATH_INFO" do Cuba.define do on true do env["SCRIPT_NAME"] = "foo" env["PATH_INFO"] = "/hello" raise "Something went wrong" end end env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/hello" } begin _, _, resp = Cuba.call(env) rescue end assert_equal "/", env["SCRIPT_NAME"] assert_equal "/hello", env["PATH_INFO"] end test "ensures SCRIPT_NAME and PATH_INFO are reverted" do Cuba.define do on lambda { env["SCRIPT_NAME"] = "/hello"; false } do res.write "Unreachable" end end env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/hello" } _, _, resp = Cuba.call(env) assert_equal "/", env["SCRIPT_NAME"] assert_equal "/hello", env["PATH_INFO"] assert_equal [], resp.body end test "skips consecutive matches" do Cuba.define do on true do env["foo"] = "foo" res.write "foo" end on true do env["bar"] = "bar" res.write "bar" end end env = {} _, _, resp = Cuba.call(env) assert_equal "foo", env["foo"] assert_equal ["foo"], resp.body assert ! env["bar"] end test "finds first match available" do Cuba.define do on false do res.write "foo" end on true do res.write "bar" end end _, _, resp = Cuba.call({}) assert_equal ["bar"], resp.body end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cuba-2.0.0.rc2 | test/on.rb |
cuba-2.0.0.rc1 | test/on.rb |