Created
August 11, 2012 14:49
-
-
Save tuzz/3325042 to your computer and use it in GitHub Desktop.
Bread and butter http basic authentication method for both ActionController and Capybara
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def http_authenticate | |
user, pass = ENV['USERNAME'], ENV['PASSWORD'] | |
if request | |
basic = ActionController::HttpAuthentication::Basic | |
request.env['HTTP_AUTHORIZATION'] = basic.encode_credentials(user, pass) | |
end | |
page.driver.browser.authorize user, pass | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment