How can one get a hand on responses of a Rails application to arbitrary requests to perform tests? So far I found a testing method assert_routing but I feel a direct test may be more robust I''d rather look at the response directly, such as get ''this/url/doesn''t/exist'' assert_equal @response.headers[''Status''], ''404'' get ''this!/!ur\l/doesn''t/exist'' assert_equal @response.headers[''Status''], ''404'' # maybe even assert_template :controller => ''error_handler'', :action => ''error_page'' -- without specifying any controller. Thanks Stephan -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Stephan Wehner wrote:> > How can one get a hand on responses of a Rails application to arbitrary > requests to perform tests? > > So far I found a testing method > > assert_routing > > but I feel a direct test may be more robust > > I''d rather look at the response directly, such as > > > get ''this/url/doesn''t/exist'' > assert_equal @response.headers[''Status''], ''404'' > > get ''this!/!ur\l/doesn''t/exist'' > assert_equal @response.headers[''Status''], ''404'' > # maybe even > assert_template :controller => ''error_handler'', :action => ''error_page''You can use assert_response to check the response header after the get request as in: get ''missing/url'' assert_response :missing or get ''missing/url'' assert_response 404 You can also check the template returned using assert_template and giving it a file system path to template file relative to the app/views directory and without the .rhtml. So if you had a template file as: app/views/error_handler/error_page.rhtml you could use: assert_template ''error_handler/error_page'' -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---