Skip to content

Instantly share code, notes, and snippets.

@tuzz
Created August 11, 2012 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuzz/3325042 to your computer and use it in GitHub Desktop.
Save tuzz/3325042 to your computer and use it in GitHub Desktop.
Bread and butter http basic authentication method for both ActionController and Capybara
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