This project is archived and is in readonly mode.

#5005 ✓resolved
Bruno Michel

Error on assert_recognizes when used on a route with constraint

Reported by Bruno Michel | June 29th, 2010 @ 02:50 PM | in 3.0.2

Hi,

I've tried to use assert_recognizes to test a route with a constraint on it, but it generates an error.

The route is:

constraints :subdomain => "api" do
  get "/news(.:format)" => "news#index", :as => "news_index"
end

The assertion :

assert_recognizes({:controller => 'news', :action => 'index'}, {:method => :get, :path => 'news'})

The backtrace:

undefined method `subdomain' for #<Rack::Request:0xb60b8b1c>
# /home/bruno/.rvm/gems/ruby-1.8.7-p299/gems/rack-mount-0.6.6/lib/rack/mount/code_generation.rb:65:in `optimized_each'
# /home/bruno/.rvm/gems/ruby-1.8.7-p299/gems/rack-mount-0.6.6/lib/rack/mount/code_generation.rb:88:in `recognize'
# /home/bruno/.rvm/gems/ruby-1.8.7-p299/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb:471:in `recognize_path'
# /home/bruno/.rvm/gems/ruby-1.8.7-p299/gems/actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/routing.rb:189:in `recognized_request_for'
# /home/bruno/.rvm/gems/ruby-1.8.7-p299/gems/actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/routing.rb:50:in `assert_recognizes

The error is on Rails-3.0.0.beta4 and on rails-master.

Comments and changes to this ticket

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments