Testing Rails 3.1 Basic Auth - 05 Apr 2012
Testing http_basic_authenticate_with
is pretty simple. When testing successful tests, you’ll want to ‘login’ first. This can be done with the following code.
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic .encode_credentials( name, password )
I’d recommend adding this to a support method as well.