Skip to content

Instantly share code, notes, and snippets.

View xam7247's full-sized avatar

Saumya Negi xam7247

View GitHub Profile
@xam7247
xam7247 / async_helper.txt
Last active March 31, 2021 12:59 — forked from mattwynne/gist:1228927
eventually helper method for making assertions against asynchronous systems
# usage:
# it "should return a result of 5" do
# eventually { long_running_thing.result.should eq(5) }
# end
module AsyncHelper
def eventually(options = {})
timeout = options[:timeout] || 2
interval = options[:interval] || 0.1
time_limit = Time.now + timeout