Hey, I''m trying to add some more tests to my application and was wondering what''s the best way to test all my routes/views of my application. I''m using HAML which can lead to some typos since I''m new to it and of course the Ruby code itself in the views. How would you test the views? Does it make sense to somehow extract all routes and "surf" on every possible route to check if it''s a 200 or not? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Zoran, On Fri, 2010-09-17 at 09:28 +0200, Zoran Szagaski wrote:> Hey, > > I''m trying to add some more tests to my application and was wondering > what''s the best way to test all my routes/views of my application. I''m > using HAML which can lead to some typos since I''m new to it and of > course the Ruby code itself in the views. > > How would you test the views? Does it make sense to somehow extract all > routes and "surf" on every possible route to check if it''s a 200 or not?I would recommend building up a set of integration tests using Cucumber or similar: http://cukes.info/. This will allow you to check that all the "moving parts" of your applications are working together correctly, including that your routes/redirections/views are free from errors. You can find a list of tutorials here: http://wiki.github.com/aslakhellesoy/cucumber/tutorials-and-related-blog-posts Cheers, Jon -- http://jonathanleighton.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m not sure how to get all routes (I guess you wanna test all routes from "rake routes"?) but route testing is quite easy. Should look somehow like this: test "should route to post" do assert_routing ''/pages/1'', { :controller => "pages", :action => "show", :id => "1" } end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s not really what I was looking for but I''ll give it a shot. Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jon Leighton wrote:> I would recommend building up a set of integration tests using Cucumber > or similar: http://cukes.info/. This will allow you to check that all > the "moving parts" of your applications are working together correctly, > including that your routes/redirections/views are free from errors. You > can find a list of tutorials here: > http://wiki.github.com/aslakhellesoy/cucumber/tutorials-and-related-blog-postsAn alternative, or more likely in combination with cucumber stories, RSSpec provides routing expectations: Examples: route_for(:controller => "hello", :action => "world").should == "/hello/world" params_from(:get, "/hello/world").should == {:controller => "hello", :action => "world"} So one could list all routes with "rake routes" and then write RSpec examples to test them. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker wrote:> An alternative, or more likely in combination with cucumber stories, > RSSpec provides routing expectations: > > Examples: > route_for(:controller => "hello", :action => "world").should == > "/hello/world" > params_from(:get, "/hello/world").should == {:controller => "hello", > :action => "world"} > > So one could list all routes with "rake routes" and then write RSpec > examples to test them.Alright, thank you. But there''s no way to let it test all routes automatically extracted from "rake routes"? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.