I have a helper page_title_default
in ApplicationHelper
:
def page_title_default(options = {})
t '.title', options
end
Now I want to test it like this:
describe '#page_title' do
subject { page_title }
it { ... }
end
end
This results in the following error:
Cannot use t(".title") shortcut because path is not available
According to this post it should be possible to stub the @virtual_path
variable like this:
helper.instance_variable_set(:@virtual_path, "admin.path.form")
But this doesn't seem to help: While I am able to stub it and then to call something like helper.t '.something'
directly in the test, it doesn't work for the translation helper which is used in the page_title_default
method (which still has @virtual_path
set to nil
). So it seems it's not the same instance of translation helper. But how can I find the page_title_default
method one's?