Rails 7.1 Authentication From Scratch - Test Helpers
I've implemented the Rails authentication in my 7.1 app but was wondering how to go about stubbing the current_user
or session
in my RSpec Request specs.
I'm normally used to have a Devise or Clearance helper that does this.
Anyone know how to do this?
For controller & integration tests, you'll make a POST request to log the user in:
class ActiveSupport::TestCase
def login(user, password: "password")
post login_path, params: {
email: user.email,
password: password
}
end
end