I'm a bit stumped on how (and where) to write some rspec tests for the "stay signed in" functionality you see all over, including on the google login.
The examples I found on the web weren't much help. Specifically I want to test these two scenarios.
1
- a) user signs in with valid credentials without having clicked "stay signed in"
- b) user closes the browser, re-opens it and requests a protect page.
- The user should not see the protected page.
- The user should see the page asking them to signed in.
2
- a) user signs in with valid credentials and having clicked "stay signed in"
- b) user closes the browser, re-opens it and requests a protected page.
- The user should not see the page asking them to sign in.
- The user should be taken to the protected page.
My first attempt at solving the problem involved simulating a browser close by deleting the user_id I stored in the session (since it gets deleted on browser close). However, these tests failed because I was working in the request spec folder and have no access there to the session variables. My earlier related question: session available in some rspec files and not others. how come?
What is the best way to do these test with rspec?