I have the following code in my app:
def timeout_tasks
10.times do
# Work...
sleep 2
end
end
I would like to test this method, but need to stub sleep
to I don't have to wait that much for the test to finish.
How can I do this? I am aware of the allow(Object).to receive(:sleep)
but I'm not sure what the Object
is. Or is there any other better approach?