I have a Rails 6 app deployed to Heroku and working fine. I've just started adding an API to the app, and this is also working fine locally, with all tests passing locally.
When I deploy to Heroku, the app responds correctly to curl.
However, my tests are failing with TypeError: no implicit conversion of nil into String during authorisation of the JWT token. I've identified the root cause, which is that the DEVISE_JWT_SECRET_KEY environment variable isn't being loaded for my tests.
This variable is defined as a Heroku environment variable, and works fine when I test the actual app using curl, as I mentioned. Running
heroku config:get DEVISE_JWT_SECRET_KEY -a [APP_NAME]
returns the correct key.
When I add a line to my tests to check for the variable, the raise is executed when the tests run, showing that the variable is missing.
raise if ENV['DEVISE_JWT_SECRET_KEY'].nil?
Can anyone suggest why environment variables aren't loading when I run my tests on Heroku?
Aucun commentaire:
Enregistrer un commentaire