te7cag
Last Updated: February 25, 2016
·
1.277K
· descentintomael

Time traveling in cucumber

Using the following step, I can use ActiveSupport's time helpers and Timecop to travel around in time.

When /^wait (\d+) (\w+)$/ do |time_amount, time_units|
  Timecop.travel time_amount.send(time_units.to_sym)
end

With this, I can write steps like "And wait 2 hours" to test things like expiration dates and timeouts.

1 Response
Add your response

14933

Exactly what I needed! Thank you!

over 1 year ago ·