Sha256: ae00328ac9ac9420423bce08416ba533e3535611d8596042b1add67f422d77f0

Contents?: true

Size: 826 Bytes

Versions: 25

Compression:

Stored size: 826 Bytes

Contents

require File.expand_path("helper", File.dirname(__FILE__))

setup do
  Cuba.define do
    on "post" do
      on :id do |id|
        res.write id
      end
    end
  end

  { "SCRIPT_NAME" => "/", "PATH_INFO" => "/post" }
end

test "matches numeric ids" do |env|
  env["PATH_INFO"] += "/1"

  _, _, resp = Cuba.call(env)

  assert_response resp, ["1"]
end

test "matches decimal numbers" do |env|
  env["PATH_INFO"] += "/1.1"

  _, _, resp = Cuba.call(env)

  assert_response resp, ["1.1"]
end

test "matches slugs" do |env|
  env["PATH_INFO"] += "/my-blog-post-about-cuba"

  _, _, resp = Cuba.call(env)

  assert_response resp, ["my-blog-post-about-cuba"]
end

test "matches only the first segment available" do |env|
  env["PATH_INFO"] += "/one/two/three"

  _, _, resp = Cuba.call(env)

  assert_response resp, ["one"]
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cuba-3.0.1.rc1 test/segment.rb
cuba-3.0.0 test/segment.rb
cuba-3.0.0.rc5 test/segment.rb
cuba-3.0.0.rc4 test/segment.rb
cuba-3.0.0.rc3 test/segment.rb