test/param.rb in cuba-3.4.0 vs test/param.rb in cuba-3.5.0
- old
+ new
@@ -5,10 +5,14 @@
Cuba.define do
on get, "signup", param("email") do |email|
res.write email
end
+ on get, "login", param("username", "guest") do |username|
+ res.write username
+ end
+
on default do
res.write "No email"
end
end
end
@@ -39,6 +43,24 @@
"QUERY_STRING" => "email=" }
_, _, resp = Cuba.call(env)
assert_response resp, ["No email"]
+end
+
+test "yields a default param" do
+ env = { "REQUEST_METHOD" => "GET", "PATH_INFO" => "/login",
+ "SCRIPT_NAME" => "/", "rack.input" => StringIO.new,
+ "QUERY_STRING" => "username=john" }
+
+ _, _, resp = Cuba.call(env)
+
+ assert_response resp, ["john"]
+
+ env = { "REQUEST_METHOD" => "GET", "PATH_INFO" => "/login",
+ "SCRIPT_NAME" => "/", "rack.input" => StringIO.new,
+ "QUERY_STRING" => "" }
+
+ _, _, resp = Cuba.call(env)
+
+ assert_response resp, ["guest"]
end