mikker / passwordless

🗝 Authentication for your Rails app without the icky-ness of passwords
MIT License
1.26k stars 87 forks source link

Add passwordless test helpers #90

Closed rickychilcott closed 3 years ago

rickychilcott commented 3 years ago

This is a PR to add test helpers for test unit and rspec. I tried this locally on a project I'm using and it works ok, but I'm only using rspec. Someone who has a good example test unit project should try this or some tests can be integrated into a passwordless example app.

This takes a lot of code and ideas from #71 so no credit is taken here, just trying to pull together to get to this as part of a 1.0 release (#89).

Close #71 and address #29

rickychilcott commented 3 years ago

Thanks @mikker. I made the requested changes.

I was modeling some of the syntax off of https://github.com/thoughtbot/clearance#controller-test-helpers but I looked too quickly and didn't realize that they effectively shim the current_user if you just did a sign_in without doing sign_in_as(user), so I dropped my weird overloading of the passwordless_sign_in/passwordless_sign_in(user) form.

Let me know if you'd like any other changes.