0

I'm writing an integration test using capybara and capybara-webkit where I need to compare two times and it randomly fails because sometimes the second passes and I have failures like

expected: "Sep 01 2015 @ 04:49:17 employee_1"
     got: "Sep 01 2015 @ 04:49:18 employee_1" 

In the non-integration test where I have to deal with time I use Timecop.freeze but if I try here I get

Capybara::FrozenInTime:

time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead

However, from my understanding time traveling doesn't fix my issue since the difference between times is always 1 sec.

Is there a way I can ensure the time does not change during test execution?

Thanks

1 Answer 1

1

If you upgrade to Capybara 2.5 and are using Ruby 2.0+ then Timecop.freeze should be usable. This is because Capybara 2.5 will now use the system monotonic clock for its waiting behavior if it is available, allowing for freezing of the ruby time methods.

2
  • Unfortunately Capybara 2.5 brakes some test I have and I do not have time to deal with that so I have manually frozen the time on my spec helper
    – Sig
    Sep 4, 2015 at 4:17
  • What version Capybara are you running? 2.4.x to 2.5 shouldn't break anything. Sep 4, 2015 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.