Sha256: 27d24763c17f6c64e5c156425dc65b6cc4095d1b45184b1f33c568c317129632
Contents?: true
Size: 1.43 KB
Versions: 25
Compression:
Stored size: 1.43 KB
Contents
require File.expand_path("helper", File.dirname(__FILE__)) setup do { "SCRIPT_NAME" => "/", "PATH_INFO" => "/posts/123" } end test "text-book example" do |env| Cuba.define do on "posts/:id" do |id| res.write id end end _, _, resp = Cuba.call(env) assert_response resp, ["123"] end test "multi-param" do |env| Cuba.define do on "u/:uid/posts/:id" do |uid, id| res.write uid res.write id end end env["PATH_INFO"] = "/u/jdoe/posts/123" _, _, resp = Cuba.call(env) assert_response resp, ["jdoe", "123"] end test "regex nesting" do |env| Cuba.define do on(/u\/(\w+)/) do |uid| res.write uid on(/posts\/(\d+)/) do |id| res.write id end end end env["PATH_INFO"] = "/u/jdoe/posts/123" _, _, resp = Cuba.call(env) assert_response resp, ["jdoe", "123"] end test "regex nesting colon param style" do |env| Cuba.define do on(/u:(\w+)/) do |uid| res.write uid on(/posts:(\d+)/) do |id| res.write id end end end env["PATH_INFO"] = "/u:jdoe/posts:123" _, _, resp = Cuba.call(env) assert_response resp, ["jdoe", "123"] end test "symbol matching" do |env| Cuba.define do on "user", :id do |uid| res.write uid on "posts", :pid do |id| res.write id end end end env["PATH_INFO"] = "/user/jdoe/posts/123" _, _, resp = Cuba.call(env) assert_response resp, ["jdoe", "123"] end
Version data entries
25 entries across 25 versions & 1 rubygems
Version | Path |
---|---|
cuba-3.0.1.rc1 | test/match.rb |
cuba-3.0.0 | test/match.rb |
cuba-3.0.0.rc5 | test/match.rb |
cuba-3.0.0.rc4 | test/match.rb |
cuba-3.0.0.rc3 | test/match.rb |