Some of my feature specs are failing intermittently. Our specs are setting the base-line to be in the past. I have found the following:
- Error thrown is:
UncaughtThrowError (uncaught throw :warden):
[#B3FBC85E07A6] devise (4.3.0) lib/devise/hooks/timeoutable.rb:26:in 'throw'
[#B3FBC85E07A6] devise (4.3.0) lib/devise/hooks/timeoutable.rb:26:in 'block in '
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:15:in 'block in _run_callbacks'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:10:in 'each'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:10:in '_run_callbacks'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/manager.rb:52:in '_run_callbacks'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/proxy.rb:180:in 'set_user'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/test/helpers.rb:21:in 'block in login_as'
[#B3FBC85E07A6] warden (1.2.7) lib/warden.rb:40:in 'block in test_mode!'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:15:in 'block in _run_callbacks'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:10:in 'each'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/hooks.rb:10:in '_run_callbacks'
[#B3FBC85E07A6] warden (1.2.7) lib/warden/manager.rb:52:in '_run_callbacks'
...
- only fails where I use Timecop
Looking at the error (exception was thrown in timeoutable.rb) and the common use of Timecop, I figured that is what is responsible - but I cannot explain why it is happening nor why it is intermittent.
Here is a sample piece of code to further explain the problem:
Timecop.travel(10.weeks.from_now) do sign_in(user) visit some_path expect(page).to have_title('something') # ... and more end
Notice that the error still shows up sometimes despite signing in after time-travel.
Everything works fine normally, in fact this test (and a couple of other ones) fail 1 in every 50+ times at most.
Any help is much appreciated. Thanks in advance.
EDIT: error occurs when visitng a page, as per screenshot. This screenshot is from a Capybara fail, right after I attempt to visit a page.