According to the RoR testing guide I should be able to set a custom header in a functional test.
If I set it this way
@request.headers["Authorization"] = "Bearer ....."
everything works just.
If I try to dynamically compute header value and assign it to @request.headers["Authorization"]
jwt_token = AuthToken.encode('some string')
bearer = "Bearer #{jwt_token}"
@request.headers["Authorization"] = bearer
I get following error
NoMethodError: undefined method `request=' for nil:NilClass
Why does this happen? How can I avoid this problem?
Aucun commentaire:
Enregistrer un commentaire