How can I check basic auth in my rspec controller examples?

I have several rails controllers that use authenticate_or_request_with_http_basic- how can I set user / pass in my rspec examples?

I am surprised that I could not find it elsewhere on the Internet, so maybe I am using the wrong conditions? “I found some very old things, or something that seems very complicated to me.” It seems that at this point rspec will either have direct support for this, or a neat idiomatic solution.

+5
source share
1 answer

it works. thanks to @zetetic pointing me in the right direction

before do
  @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
end
+6
source

All Articles