I ran into a little issue while writing functional tests in Rails 2.0, using the included HTTP authentication I’d find my controllers returning 401 errors since they weren’t authenticated. After poking around, I found a solution:
1 2 3 4 5 | class Test::Unit::TestCase def http_auth @request.env[”HTTP_AUTHORIZATION”] = “Basic #{Base64.encode64(”foo:bar”)}” end end |
Then, in my actual tests I could call:
1 | http_auth |
Add New Comment
Viewing 7 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment