Created
October 28, 2017 22:30
-
-
Save narath/d4885b00f6dafc559b3ed22f27cd6ba4 to your computer and use it in GitHub Desktop.
LoginHelper for Basic Auth with Rspec and Rails
This file contains hidden or 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
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