We have about 2000 specs (RSpec) for one of the platforms. Some are model others are system. There are also some request specs left there.
Specs are regularly run with --order random. Sometime in the spec we do
but we are still logged in from the previous specs. Sometimes. One in 10K specs does this and it is not always the same and it can not be reproduced with --seed XXX.
My question is - have you experienced this? have you tried to resolve it? How did you manage? Is there a way to make sure there are no users logged in before a spec is run.
In the spec helper before every spec we do
config.before(:each) do Warden.test_reset! logout end
My hope was that this will reset/logout and make sure there are no users logged in. But on next spec we are logged in. We have saved a png, we have save an html. They both contain a “You are already signed in.” flash message.
Update: I did find ruby - Rails 3 with Devise and rspec: Warden test helpers unreliable - Stack Overflow which is from 9 years ago and is probably the same problem. Devise has a how to for Warden, Capybara and Tests - How To: Test with Capybara · heartcombo/devise Wiki · GitHub There is also great discussion at clarification with login_as helper · Issue #99 · wardencommunity/warden · GitHub, but I still can’t figure out how to resolve it.