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-4.0.3 test/segment.rb
cuba-4.0.1 test/segment.rb
cuba-4.0.0 test/segment.rb
cuba-3.9.3 test/segment.rb
cuba-3.9.2 test/segment.rb
cuba-3.9.1 test/segment.rb
cuba-3.9.0 test/segment.rb
cuba-3.8.1 test/segment.rb
cuba-3.8.0 test/segment.rb
cuba-3.7.0 test/segment.rb
cuba-3.6.0 test/segment.rb
cuba-3.5.0 test/segment.rb
cuba-3.4.0 test/segment.rb
cuba-3.3.0 test/segment.rb
cuba-3.2.0 test/segment.rb
cuba-3.1.1 test/segment.rb
cuba-3.1.0 test/segment.rb
cuba-3.1.0.rc2 test/segment.rb
cuba-3.1.0.rc1 test/segment.rb
cuba-3.0.1.rc2 test/segment.rb