def rescue_action_in_public(exception) case exception when LoginException headers["Status"] = "401 Unauthorized" goto_login .... so I def login! .... raise LoginException end but I don''t know how to test it under functionals test when ran rake test:functionals always show me exception so can''t to test step 2 goto_login --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can use ruby''s assert_raise method assert_raise LoginException do # whatever end More info can be found here http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html -- Thiago Jackiw http://www.railsfreaks.com On May 6, 6:51 pm, ChandleWEi <chandle....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> def rescue_action_in_public(exception) > case exception > when LoginException > headers["Status"] = "401 Unauthorized" > goto_login > .... > > so I > > def login! > .... > raise LoginException > end > > but I don''t know how to test it under functionals test > > when ran rake test:functionals always show me exception so can''t to test > step 2 goto_login--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thx It''s very useful for me 在 2008-05-06二的 19:16 -0700,Thiago Jackiw写道:> You can use ruby''s assert_raise method > > assert_raise LoginException do > # whatever > end > > More info can be found here http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html > > -- > Thiago Jackiw > http://www.railsfreaks.com > > > On May 6, 6:51 pm, ChandleWEi <chandle....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > def rescue_action_in_public(exception) > > case exception > > when LoginException > > headers["Status"] = "401 Unauthorized" > > goto_login > > .... > > > > so I > > > > def login! > > .... > > raise LoginException > > end > > > > but I don''t know how to test it under functionals test > > > > when ran rake test:functionals always show me exception so can''t to test > > step 2 goto_login > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---