Where to test routes in ruby on rails? unit tests? functional tests? integration tests?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Routes should be done as part of integration tests. Integration tests are where you test the important work flows of your application – more specifically whether a URL is defined or not seems to be an important workflow.
Your integration test would look like any normal integration test:
As to @jemminger‘s response of not testing routes – While it is Rail’s tests that verify that routes.rb works, it’s not Rail’s responsibility to test whether
http://yoursite.com/usersis defined in your routes. The caveat is that most route testing could be done in existing integration tests, so specific tests for routes could be redundant.The specific use case I can think of are all the people that have already, or are going to upgrade from Rails 2 to Rails 3. The code to define routes has changed significantly, and it’s better to find out from tests that the routes were upgraded correctly, than from users when they report 404 errors.