I have a shared view component that changes state based on the current URI. I'm currently accessing that information via request.env['PATH_INFO']
, as this seems to be the convention as far as I can tell. However, when running unit tests, this always seems to be nil
. This is an issue, because it causes any view with this component to explode.
Setting @request.env['PATH_INFO']
in the body of the test doesn't work, and I'm glad it doesn't because that would be hideous.
How can I access the current URI within a view or controller during testing?
I'm using vanilla Rails unit testing, so answers that don't require me to change my testing framework would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire