This project is archived and is in readonly mode.

#4344 ✓invalid

Threre is no way to test routing with constraints

Reported by saks | April 8th, 2010 @ 11:50 AM | in 3.0.2

I did not find any way to test how my routing works with constraints. Methods


do not accept any options related to constraints

Comments and changes to this ticket

  • saks

    saks April 9th, 2010 @ 01:22 PM

    • Tag changed from routing testing constraints to routing, testing

    I have no any idea about how to test these routes:

    constraints(:host => /^catalog\./) do
        get 'categories'           => 'categories#index'
        get 'categories/:url_name' => 'categories#show'

    becauses i don't see the way to change host for this request. It is hardcoded to be '':

    # Return the Rack environment used for a request to +uri+.
    def self.env_for(uri="", opts={})
      uri = URI(uri)
      uri.path = "/#{uri.path}" unless uri.path[0] == ?/
      env = DEFAULT_ENV.dup
      env["REQUEST_METHOD"] = opts[:method] ? opts[:method].to_s.upcase : "GET"
      env["SERVER_NAME"] = || ""
  • saks

    saks April 9th, 2010 @ 01:31 PM

    • Tag changed from routing, testing to constraints, routing, testing

    def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)

        expected_path = "/#{expected_path}" unless expected_path[0] == ?/
        # Load routes.rb if it hasn't been loaded.

    "/#{expected_path}... does not allow to pass path like "", That's why URI(uri) cannot parse host

  • saks

    saks April 9th, 2010 @ 01:36 PM

    • Assigned user set to “DHH”
  • Anil Wadghule

    Anil Wadghule April 9th, 2010 @ 05:24 PM

    • Title changed from “Threre is no way to test roting with constraints” to “Threre is no way to test routing with constraints”
  • José Valim

    José Valim April 10th, 2010 @ 12:26 PM

    • Assigned user changed from “DHH” to “josh”
    • Milestone cleared.

    @saks, please don't assign users. Wait until someone comes and assign it properly.

  • josh

    josh April 11th, 2010 @ 07:09 PM

    • State changed from “new” to “invalid”
  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
    • Importance changed from “” to “Medium”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>