Use Kernel.sleep() rather than sleep() so that you can flexmock it.
Don't do this
sleep(10)
Instead do this
Kernel.sleep(10)
So that you can do this
it 'can skip sleeping when testing' do
flexmock(Kernel).should_receive(:sleep)
end
Written by Ryan Geyer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#