I am using the request routing plugin to route some stuff based on subdomains. In one particular case, I have http://www.mysite.com/specialaction/:id route to :controller => "mycontroller", :action => "myaction". The route checks the requirement that the subdomain is "www" So, what I want to do is test that this specific route is handled correctly. Once, while fiddling around, I rearranged the order of some routes and my routing broke. I want to make sure this doesn''t happen again. Is this a functional test? Or is this an integration test? Jake -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Functional test only works within one controller and any attempt to go between controls will cause Rails to throw an exception. My feeling on this would be, it seems like, an integration test since you won''t be working with raw URLs. In order to test your routes you''ll have to translate raw URLs into calls on your controller so if you can''t specify URLs then you can''t test it. I haven''t done integration tests yet so take it with a grain of salt. Charlie Jake Janovetz wrote:> I am using the request routing plugin to route some stuff based on > subdomains. > > In one particular case, I have http://www.mysite.com/specialaction/:id > route to :controller => "mycontroller", :action => "myaction". The > route checks the requirement that the subdomain is "www" > > So, what I want to do is test that this specific route is handled > correctly. Once, while fiddling around, I rearranged the order of some > routes and my routing broke. I want to make sure this doesn''t happen > again. > > Is this a functional test? Or is this an integration test? > > Jake-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
There is an assert_routing function for integration tests. What I''ve been doing is creating a seperate routing_test integration just to test the routing. For your case: assert_routing ''/specialaction/4'', :controller => ''mycontroller'', :action => ''myaction'', :id => 4 and assert_equal ''/specialaction/4'', url_for(:only_path => true, :controller => ''mycontroller'', :action => ''myaction'', :id => 4) I''m sure there''s a key to check for certain subdomains. Never done that so I would have to look it up. I''ve learned that routing is easily the most fragile part of a rails app, and can be a PIA to debug. Make sure you''ve got integration tests for it. Jason On 8/30/06, Charlie Hubbard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Functional test only works within one controller and any attempt to go > between controls will cause Rails to throw an exception. My feeling on > this would be, it seems like, an integration test since you won''t be > working with raw URLs. In order to test your routes you''ll have to > translate raw URLs into calls on your controller so if you can''t specify > URLs then you can''t test it. I haven''t done integration tests yet so > take it with a grain of salt. > > Charlie > > Jake Janovetz wrote: > > I am using the request routing plugin to route some stuff based on > > subdomains. > > > > In one particular case, I have http://www.mysite.com/specialaction/:id > > route to :controller => "mycontroller", :action => "myaction". The > > route checks the requirement that the subdomain is "www" > > > > So, what I want to do is test that this specific route is handled > > correctly. Once, while fiddling around, I rearranged the order of some > > routes and my routing broke. I want to make sure this doesn''t happen > > again. > > > > Is this a functional test? Or is this an integration test? > > > > Jake > > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I ended up building the check into my integration tests. It works well there and I can check all sorts of things like remote address, various subdomains, protocol, etc. Jason Roelofs wrote:> I''ve learned that routing is easily the most fragile part of a rails > app, > and can be a PIA to debug. Make sure you''ve got integration tests for > it.I, too, have found this to be the case. Integration tests certainly help. Jake -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---