I am creating a separate backend for my class project. I have a rails app with the api flag as I want to build this out to end points to be consumed with React or React Native. I was able to test authenticating or creating a user through the api endpoint. Now I'm trying to find a way to test the logout feature. I know how to check to make sure the login call back works. Without views to check for current path or page content, how can I test to ensure that the user is logged out successfully?
I ended up using this.
it 'can log out user' do
get '/api/v1/auth/google_oauth2/callback', params: stub_omniauth
user = JSON.parse(response.body)
expect(request.session[:user_id]).to_not be_nil
expect(user['name']).to eq('Rick Astley')
expect(User.last.name).to eq('Rick Astley')
get '/api/v1/signout'
expect(request.session[:user_id]).to be_nil
end