Forum: Ruby on Rails How can I test a "magic" route ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
peter.fitzgibbons (Guest)
on 2005-12-07 21:02
(Received via mailing list)
Hello,
I have this in routes.rb:

  map.connect 'UserLogin.jsp', :controller=>"user", :action=>"login"

This does what it should at runtime.  I would love to unit-test it.  I
can't
figure how?

Any Ideas are appreciated!

--
technoweenie (Guest)
on 2005-12-07 21:10
(Received via mailing list)
On 12/7/05, Peter F. <removed_email_address@domain.invalid> wrote:
> Hello,
> I have this in routes.rb:
>
>   map.connect 'UserLogin.jsp', :controller=>"user", :action=>"login"
>
> This does what it should at runtime.  I would love to unit-test it.  I can't
> figure how?
>
> Any Ideas are appreciated!

In your functional test for UserController:

assert_routing
http://rails.rubyonrails.com/classes/Test/Unit/Ass...

assert_routing really calls assert_generates and assert_recognizes

--
rick
http://techno-weenie.net
peter.fitzgibbons (Guest)
on 2005-12-07 21:19
(Received via mailing list)
On 12/7/05, Rick O. <removed_email_address@domain.invalid> wrote:
> >
> rick
> http://techno-weenie.net
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

Except that the url "/UserLogin.jsp" is not a proper rails segment, and
is
not really reversible in the routing hierarchy (user/login resolves to /
in
subsequent routing.

Here's the entire table :

ActionController::Routing::Routes.draw do |map|
  map.connect '', :controller => "user", :action => "login"

  map.connect 'UserLogin.jsp', :controller=>"user", :action=>"login"

  map.connect ':controller/service.wsdl', :action => 'wsdl'

  map.connect ':controller/:action/:id'

end

--
technoweenie (Guest)
on 2005-12-07 21:23
(Received via mailing list)
>
>   map.connect ':controller/service.wsdl', :action => 'wsdl'
>
>   map.connect ':controller/:action/:id'
>
> end

assert_routing tests both ways by calling assert_recognizes and
assert_generates.  I'm guessing you just want assert_recognizes then.

--
rick
http://techno-weenie.net
This topic is locked and can not be replied to.