Skip to content

Instantly share code, notes, and snippets.

@narath
Created October 28, 2017 22:30
Show Gist options
  • Save narath/d4885b00f6dafc559b3ed22f27cd6ba4 to your computer and use it in GitHub Desktop.
Save narath/d4885b00f6dafc559b3ed22f27cd6ba4 to your computer and use it in GitHub Desktop.
LoginHelper for Basic Auth with Rspec and Rails
module LoginHelper
def login(user="test",pw="test")
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
RSpec.configure do |config|
config.include LoginHelper, type: :controller
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment