rufus-scheduler
lib allows us to schedule tasks
https://github.com/jmettraux/rufus-scheduler
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
scheduler.cron '* * * * *' do
# do something every minute
end
In fact, when you want to test your app on top of rufus-scheduler
you will need to sleep real 1 min
which is too much for typical tests.
For example, in Reactor(Java)
they provide StepVerifier.withVirtualTime
in order to avoid long-running tests.`:
https://projectreactor.io/docs/core/release/reference/#_manipulating_time
RxJava - https://medium.com/@vanniktech/taking-control-of-the-time-when-testing-rxjava-code-91b2e5e88bdf
Are there any options for time manipulation within tests for rufus-scheduler
or Ruby
itself?
Current solution
rufus-scheduler
has type in
, thus for verification of app skeleton I'm using in=0.001s
and sleep 0.4
.
Yes, it takes half-of a second in the test but this is much better than 1 minute.
Have a look at
or other "time travel" tools.
I second @spickermann on "only test your own code".