Skip to content

routing tests grouped #3

@rkh

Description

@rkh

CONTEXT: basic '/' route

  • returns 201 as a status
  • returns the complete body as string
  • sets a header as foo
  • /hello routes gets hello route

CONTEXT: returning an IO-like object

  • returns 200 as Status
  • returns the object's body

CONTEXT: body responses

  • returns empty array when body is nil

CONTEXT: missing routes

  • 404s and sets X-Cascade header when no route satisfies the request
  • 404s and does not set X-Cascade header when no route satisfies the request and x_cascade has been disabled

CONTEXT: 404

  • recalculates body length correctly for 404 response

CONTEXT: unicode

  • allows using unicode
  • it handles encoded slashes correctly
  • overrides the content-type in error handlers

CONTEXT: PATH_INFO

  • matches empty PATH_INFO to "/" if no route is defined for ""
  • matches empty PATH_INFO to "" if a route is defined for ""

CONTEXT: takes multiple definitions of a route

  • takes multiple definitions of a route

CONTEXT: params

  • supports named params like /hello/:person
  • exposes params with indifferent hash
  • merges named params and query string params in params
  • supports optional named params like /?:foo?/?:bar?
  • exposes nested params with indifferent hash
  • exposes params nested within arrays with indifferent hash
  • supports arrays within params
  • supports deeply nested params
  • preserves non-nested params

CONTEXT: route flow

  • returns response immediately on halt
  • halts with a response tuple
  • halts with an array of strings
  • sets response.status with halt
  • transitions to the next matching route on pass
  • transitions to 404 when passed and no subsequent route matches
  • transitions to 404 and sets X-Cascade header when passed and no subsequent route matches
  • uses optional block passed to pass as route block if no other route is found
  • matches routes defined in superclasses
  • matches routes in subclasses before superclasses
  • allows using call to fire another request internally
  • plays well with other routing middleware

CONTEXT: conditions

  • passes to next route when condition calls pass explicitly
  • passes when matching condition returns false
  • does not pass when matching condition returns nil
  • allows custom route-conditions to be set via route options

CONTEXT: host condition

  • passes to the next route when host_name does not match

CONTEXT: agent condition

  • passes to the next route when user_agent does not match
  • treats missing user agent like an empty string
  • makes captures in user agent pattern available in params[:agent]
  • adds hostname condition when it is in options

Context: provides condition

  • matches mime_types with dots, hyphens and plus signs
  • filters by accept header
  • filters by current Content-Type
  • allows multiple mime types for accept header
  • respects user agent preferences for the content type
  • accepts generic types
  • prefers concrete over partly generic types
  • prefers concrete over fully generic types
  • prefers partly generic over fully generic types
  • respects quality with generic types
  • supplies a default quality of 1.0
  • orders types with equal quality by parameter count
  • ignores the quality parameter when ordering by parameter count
  • properly handles quoted strings in parameters
  • accepts both text/javascript and application/javascript for js
  • accepts both text/xml and application/xml for xml

CONTEXT: pattern matching

  • supports named captures like %r{/hello/(?[^/?#]+)}
  • supports optional named captures like %r{/page(?.[^/?#]+)?}
  • does not concatenate params with the same name
  • supports single splat params like /*
  • supports mixing multiple splat params like //foo//*
  • supports mixing named and splat params like /:foo/*
  • supports basic nested params
  • URL decodes named parameters and splats
  • supports regular expressions
  • makes regular expression captures available in params[:captures]
  • supports regular expression look-alike routes
  • raises a TypeError when pattern is not a String or Regexp

CONTEXT: route invocation

  • passes a single url param as block parameters when one param is specified
  • passes multiple params as block parameters when many are specified
  • passes regular expression captures as block parameters
  • supports mixing multiple splat params like //foo//* as block parameters
  • raises an ArgumentError with block arity > 1 and too many values
  • raises an ArgumentError with block param arity > 1 and too few values
  • succeeds if no block parameters are specified
  • passes all params with block param arity -1 (splat args)
  • raises an ArgumentError with block param arity 1 and no values
  • raises an ArgumentError with block param arity 1 and too many values

CONTEXT: special characters

  • matches a dot ('.') as part of a named param
  • matches a literal dot ('.') outside of named param
  • literally matches dot in paths
  • literally matches dollar sign in paths
  • literally matches plus sign in paths
  • does not convert plus sign into space as the value of a named param
  • literally matches parens in paths
  • matches paths that include spaces encoded with %20
  • matches paths that include spaces encoded with +
  • matches paths that include ampersands

CONTEXT: route internals

  • returns the route signature (no longer a requirement)
  • sets env['sinatra.route'] to the matched route

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions