Sha256: 1d47caf3e3d04d19b2a9615cbc14e068e9b54a984c15e66d124dd2e440ae7d43

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 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_response resp, ["john@doe.com"]
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_response resp, ["No email"]
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_response resp, ["No email"]
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cuba-3.4.0 test/param.rb
cuba-3.3.0 test/param.rb
cuba-3.2.0 test/param.rb
cuba-3.1.1 test/param.rb
cuba-3.1.0 test/param.rb
cuba-3.1.0.rc2 test/param.rb
cuba-3.1.0.rc1 test/param.rb
cuba-3.0.1.rc2 test/param.rb
cuba-3.0.1.rc1 test/param.rb
cuba-3.0.0 test/param.rb
cuba-3.0.0.rc5 test/param.rb
cuba-3.0.0.rc4 test/param.rb
cuba-3.0.0.rc3 test/param.rb