Thank's for you response Iain.

I want to raise an exception only in test environnement, so, I prefer
to use my own helper method.
So in my test_helper.rb, I add some hack in #translate method from
module TranslationHelper like in  http://gist.github.com/472463

In my view I have #t method to call translation but they didn't raise
exception too.

Why my #translate method doesn't raise exception ?

Best regards,

Mickaël.

You are right, view helpers will always rescue the exception and

On 12 juil, 14:55, Iain Hecker <[email protected]> wrote:
> Hi!
>
> Unfortunately, you cannot raise in your views, because the default
> view helpers will always rescue the exception:
>
> http://github.com/rails/rails/blob/master/actionpack/lib/action_view/...
>
> t/translate as defined in the views is not just a shortcut/alias to
> I18n.t, but does a lot of stuff around it.
>
> Either redefine this method in your own helper or use I18n.t if you
> don't want it. There seems to be no other way.
>
> Iain
>
> On Mon, Jul 12, 2010 at 14:42, Mickaël <[email protected]> wrote:
> > Hi folks,
>
> > I have read some documentation about I18n and exceptions, but I need
> > your help.
>
> > My idea is to implement an exception when my functional test watch a
> > missing translation like what I'm seeing in "Rails
> > Internationalization (I18n) API Guide" (http://guides.rubyonrails.org/
> > i18n.html#using-different-exception-handlers). The documentation seem
> > to be old.
>
> > I try some context.
>
> > Gist number 1 (http://gist.github.com/472395) works with #t method and
> > a correct translation key.
>
> > Gist number 2 (http://gist.github.com/472404) doesn't raise an
> > exception with #t method.
>
> > Gist number 3 (http://gist.github.com/472423) raise an exception but I
> > must specify I18n.t method to translate.
>
> > Questions are :
>
> > How to implement a raise with #t helper method ?
> > And, how to specify the right exception ?
>
> > Thank's for your patience and your help.
>
> > Best regards,
>
> > Mickaël.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "rails-i18n" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/rails-i18n?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"rails-i18n" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-i18n?hl=en.

Reply via email to