rylwin's blog

coding for results

Simulate Timeouts for Testing Devise/Warden With Capybara

I found myself wanting to test some custom behavior that runs when the user’s session times out. Instead of sleep User.timeout_in, here’s the solution we are using to simulate a user timeout:

1
2
3
4
Warden.on_next_request do |proxy|
  session = proxy.env['rack.session']['warden.user.user.session']
  session['last_request_at'] -= User.timeout_in
end

Comments