views:

35

answers:

2

Hello,

I need to use the functionality of params_from, which was deprecated. Now route_to combines behavior of params_from and route_for. But I do not want to test that the route generates the path, because it does not and this is intentional (for backward compatability in old emails, I need to "alias" old path to the correct controller/action, but path generated by the new route will be different. I know, confusing ;)

When using params_from and route_to, I get conflicting results (maybe params_for is broken?):

# params_from(:get, 'user/tasks').should == { :controller => 'user', :action => 'tasks' }
No route matches "user/tasks" with {:method=>:get} 

# { :get => 'user/tasks' }.should_not be_routable
Expected 'GET user/tasks' to fail, but it routed to {"action"=>"tasks", "controller"=>"user"} instead

The route does exist, I can use the path via UI successfully.

IMO this combination of params_from and route_for is a bad idea, unless the seperate matches are still supported. But maybe I've missed something obvious ;)

Thank you.

A: 

This is what I was looking for, and found it while hacking the source code: assert_recognizes({ :controller => 'user', :action => 'tasks'}, 'user/tasks', {}, nil)

I will probably wrap it under params_for matcher.

JobGovernor
A: 

What's the value of testing your routeset explicitly?

You should probably get this for free if you write even a minimal functional test for your controllers.

Winfield