Farrel
2008-Jan-20 20:52 UTC
Functional test with exception_notification fails when run with rake, passes when run with Ruby
I''ve got a wierd problem with a functional test that passes when run individually (''ruby test/functional/exception_notifier.rb'') but fails when run as part of ''rake test:functionals''. I''m testing whether a broken page is handled by the exception_notification plugin. Using Mocha (http://agilewebdevelopment.com/plugins/mocha) I set a method called from a partial to throw a RuntimeError so that exception_notification will handle it. The test is as follows: def test_broken_home # plan our exception around a failing testimonial call Testimonial.expects( :active_testimonials ).raises( RuntimeError ) # make sure we''re not seen as a local request HomeController.consider_all_requests_local = false # count our mails base_mails = ActionMailer::Base.deliveries.size bg_mails = ActionMailer::Background.background_deliveries.size # get our page get :index # make sure its an error assert_response :error # count our mails assert_equal base_mails + 1, ActionMailer::Base.deliveries.size assert_equal bg_mails, ActionMailer::Background.background_deliveries.size end When run as an individual test everything passes, the exception is handled a 500 is returned and the appropriate mails are sent. When called as part of the functional test suite the RuntimeError causes an error in the test and the response code is 0 with no mails being sent (I put the get :index in a begin rescue block to check this). I assume the problem is due either to the environment that rake sets up that either prevents exception_notification from handling the exception but I have no ideas at the Has anyone handled an issue like this before? Any ideas on what to change? Farrel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Keynan Pratt
2008-Jan-21 08:23 UTC
Re: Functional test with exception_notification fails when r
The most likely reason for the difference is you are not declaring a fixture. -- 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 -~----------~----~----~----~------~----~------~--~---