Follow Along as I Stumble on the Path to Learning RoR

HTTP_REFERER Error in RSpec

If you find that you get this error in RSpec:

No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].

Then you have to specify this in your spec:

request.env[“HTTP_REFERER”] = “where_i_came_from”

based on this answer in StackOverflow (it of course doesn’t necessarily have to equal “where_i_came_from”).  This can happen if you redirect :back in your code.

Advertisements

Comments are closed.