The Rails 3 application I'm working on contains some logic that calls the following code (which I cannot change):
Rails.application.routes.recognize_path("/customers", :method => :get)
"/ customers", of course, is a variable.
I am writing an associated Rspec test that calls code containing the specified logic, and the test has a complete Rails environment. When I bring up the following:
Rails.application.routes.routes.inspect
it contains the correct routes (for example, one of the routes that it has is "GET / customers").
When I run the test, the logic leads to the following:
No route matches "/customers"
Do the following:
@routes = Rails.application.routes assert_recognizes({:controller => "customers", :action => "index"}, "/customers")
leads to the same error.
As part of an auxiliary test:
# this succeeds and returns "/customers" x = helper.customers_path Rails.application.routes.recognize_path(x, :method => :get)
repeats the same error again (no route matches "/ customers")
I am 100% sure that Rails.application.routes contains the correct routes.
Does anyone know what is the reason for this?
Thanks!