Sha256: 258940b42d069fb2d9d33f7641373a392fa6fd2e05c71d4f5f97c405e968835c
Contents?: true
Size: 1.06 KB
Versions: 9
Compression:
Stored size: 1.06 KB
Contents
require File.expand_path("helper", File.dirname(__FILE__)) require "stringio" prepare do Cuba.define do on get, "signup", param("email") do |email| res.write email end on default do res.write "No email" end end end test "yields a param" do env = { "REQUEST_METHOD" => "GET", "PATH_INFO" => "/signup", "SCRIPT_NAME" => "/", "rack.input" => StringIO.new, "QUERY_STRING" => "email=john@doe.com" } _, _, resp = Cuba.call(env) assert_equal ["john@doe.com"], resp.body end test "doesn't yield a missing param" do env = { "REQUEST_METHOD" => "GET", "PATH_INFO" => "/signup", "SCRIPT_NAME" => "/", "rack.input" => StringIO.new, "QUERY_STRING" => "" } _, _, resp = Cuba.call(env) assert_equal ["No email"], resp.body end test "doesn't yield an empty param" do env = { "REQUEST_METHOD" => "GET", "PATH_INFO" => "/signup", "SCRIPT_NAME" => "/", "rack.input" => StringIO.new, "QUERY_STRING" => "email=" } _, _, resp = Cuba.call(env) assert_equal ["No email"], resp.body end
Version data entries
9 entries across 9 versions & 1 rubygems