Sha256: d82450fdcbd88fd5a3631c18365d332b5d40eadc0b5423602793595adbb2d61e

Contents?: true

Size: 1.21 KB

Versions: 23

Compression:

Stored size: 1.21 KB

Contents

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

test "matching an empty segment" do
  Cuba.define do
    on "" do
      res.write req.path
    end
  end

  env = {
    "SCRIPT_NAME" => "",
    "PATH_INFO" => "/"
  }

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

  assert_response resp, ["/"]
end

test "nested empty segments" do
  Cuba.define do
    on "" do
      on "" do
        on "1" do
          res.write "IT WORKS!"
          res.write req.path
        end
      end
    end
  end

  env = {
    "SCRIPT_NAME" => "",
    "PATH_INFO" => "///1"
  }

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

  assert_response resp, ["IT WORKS!", "///1"]
end

test "/events/? scenario" do
  class Events < Cuba
    define do
      on root do
        res.write "Hooray"
      end
    end
  end

  Cuba.define do
    on "events" do
      run Events
    end
  end

  env = {
    "SCRIPT_NAME" => "",
    "PATH_INFO" => "/events"
  }

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

  assert_response resp, ["Hooray"]

  env = {
    "SCRIPT_NAME" => "",
    "PATH_INFO" => "/events/"
  }

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

  assert_response resp, ["Hooray"]

  env = {
    "SCRIPT_NAME" => "",
    "PATH_INFO" => "/events/a"
  }

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

  assert_response resp, []
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
cuba-4.0.3 test/root.rb
cuba-4.0.1 test/root.rb
cuba-4.0.0 test/root.rb
cuba-3.9.3 test/root.rb
cuba-3.9.2 test/root.rb
cuba-3.9.1 test/root.rb
cuba-3.9.0 test/root.rb
cuba-3.8.1 test/root.rb
cuba-3.8.0 test/root.rb
cuba-3.7.0 test/root.rb
cuba-3.6.0 test/root.rb
cuba-3.5.0 test/root.rb
cuba-3.4.0 test/root.rb
cuba-3.3.0 test/root.rb
cuba-3.2.0 test/root.rb
cuba-3.1.1 test/root.rb
cuba-3.1.0 test/root.rb
cuba-3.1.0.rc2 test/root.rb
cuba-3.1.0.rc1 test/root.rb
cuba-3.0.1.rc2 test/root.rb